Comments (7)
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.
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.
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.
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.
@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.
Thanks @constantinius
Your library has been an important boost for it!
from geotiff.js.
Hi!, this issue should be probably closed!
from geotiff.js.
Related Issues (20)
- The exports `package.json` needs a new paint job HOT 3
- How do I use compression? HOT 3
- Typescript compilation error in BaseClient HOT 14
- Writing GeoTiffs HOT 3
- Reading files larger than 4gb? HOT 1
- image.readRasters() HOT 3
- Exceeds max_safe_integer. Precision may be lost. HOT 2
- Type error at build time HOT 1
- Abort signal should be extended to `getImage` when performing slice's fetch action
- Property 'headers' does not exist on type '{}'
- Pool workers lead to memory leak? HOT 3
- using geotiff.js with react-native HOT 6
- 请升级一下lerc依赖 HOT 2
- credentials option is ignored HOT 3
- idenify does not work on GeoTiff float (Digitales Höhenmodell Oberfläche NRW) HOT 2
- Generating a geotiff from an image and a list of ground control points.
- readRGB() does not always return an interleaved array HOT 2
- Support also CommonJS HOT 4
- BlockedSource: Duplicated HTTP range requests
- capturing world coordinates form the tiff imaegs using geotiff.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geotiff.js.