Giter VIP home page Giter VIP logo

Comments (7)

constantinius avatar constantinius commented on June 6, 2024

Hi @mattijn

unfortunately this functionality is not (yet) part of the geotiff library, but (fortunately) can be solved outside of it.

Here are some thoughts regarding point or line sampling.

First off, you have to consider interpolation when you are dealing with sub-pixel coordinates. The easiest way would be to round to the nearest integer which would result in a nearest neighbor "interpolation" (not really interpolating), which is fine for some applications but not for all. Another fairly easy option would be bilinear interpolation, where you get the nearest 4 pixels and then linearly interpolate.

When you are not reading the full image into one array, but a subset, then you have to take the offset of the subset window to the full image into consideration as-well.

Also you have to choose whether you want to sample the original data, or the plotty-rendered RGB.

Does this help you?
Do you think point or line sampling would be a good addition to geotiff.js functions?

from geotiff.js.

mattijn avatar mattijn commented on June 6, 2024

Currently I plot a raster on a leaflet map using geotiff.js and plotty.js. This works great. No need for geoserver or mapserver. I think thats a big plus.

Next step for me is to interact with the raster once a user clicks somewhere on raster in the map, For point sampling I now use gdallocationinfo to get the specific point in the raster by querying the tif (in lat/lon) on the server-side.
With a dedicated function I could make this to work as well for line sampling, but I haven't done it yet.

But, thats all server-side, while I got my raster loaded in my clients browser through geotiff.js. You mention that you can choose to sample the original data or the RGB, I didn't realize that is possible. For me I would think to sample the original data as I otherwise have to translate the RGB values to numbers, isn't it?

Your thoughts definitely helps! For me, I think it would be a great to be able to do point or line sampling on the client side, while I'm not sure if it should be included in geotiff.js, as it is not so much an tif encoding issue. Might be a potential side library?

from geotiff.js.

constantinius avatar constantinius commented on June 6, 2024

Currently, the "geo" part of geotiff.js is somewhat neglected. Sure, the geo-keys are read and decoded, but not used any further. I think it would be beneficial to interpret them to allow a translation of geo-coordinates (eg: lat-lon) to pixel coordinates. The main issue here is that there are a lot of possibilities to encode the geo referencing within the geotiff (tie-points, custom CRS definitions, ... you name it).

I think I could implement a function to allow pixel lookups for images with simple affine transformations and include it in geotiff.js. I'm not sure when I will be able to do so, though.

But, thats all server-side, while I got my raster loaded in my clients browser through geotiff.js. You mention that you can choose to sample the original data or the RGB, I didn't realize that is possible. For me I would think to sample the original data as I otherwise have to translate the RGB values to numbers, isn't it?

Well, the array you read using readRaster is the "raw" data, which is passed to plotty to generate the RGB version. So, if you have a simple case (e.g: where the image CRS is equal to your leaflet map CRS for example) you could quite easily transform the coordinates to pixel space and then query this retrieved array and get your real pixel value.

from geotiff.js.

VictorVelarde avatar VictorVelarde commented on June 6, 2024

Hi there @mattijn @constantinius

I'm currently developing a Leaflet plugin that might be interesting for this use case. It uses geotiff.js, but also reads ASCII Grid files, and allows onclick to identify values.

Have a look at it : https://github.com/IHCantabria/Leaflet.CanvasLayer.Field
And here there are some examples: https://ihcantabria.github.io/Leaflet.CanvasLayer.Field/

It is a work in progress, so any feedback is welcome!

from geotiff.js.

constantinius avatar constantinius commented on June 6, 2024

@VictorVelarde: This looks really nice, and is a good example how to query raster values at a given coordinate. Nice job with the animated layers, they look gorgeous!

from geotiff.js.

VictorVelarde avatar VictorVelarde commented on June 6, 2024

Thanks @constantinius
Your library has been an important boost for it!

from geotiff.js.

VictorVelarde avatar VictorVelarde commented on June 6, 2024

Hi!, this issue should be probably closed!

from geotiff.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.