GeoTIFF / georaster-layer-for-leaflet

Display GeoTIFFs and soon other types of raster on your Leaflet Map
https://geotiff.github.io/georaster-layer-for-leaflet-example/
Apache License 2.0
306 stars 58 forks source link

Question: What does resolution mean for the Raster layer? #51

Closed Nightsphere closed 3 years ago

Nightsphere commented 3 years ago

Hello again! You previously helped me with Issue #40 back in July, which allowed me to put out the first couple maps with raster information. Now I just have a question about what exactly the resolution option for a raster means. I tried looking into the code but couldn't discern it myself. The reason I ask is that some of the layers we display are meant to have 1 cell in the layer represent 40 acres (or something similar) on the Leaflet map, but depending on the resolution, those can look very blocky from far away.

Increasing the resolution will help with that obviously, but what does it mean? Is it just arbitrarily increasing resolution for the layer when changed from 32 to 64 for example, or is the resolution tied to something specific? Such as, if I wanted to show a cell as being 40 acres, would resolution be set to 40? I figure that's not how it works, but I hope you get my question.

Also, if a raster layer's opacity is less than one, you can see horizontal and/or vertical lines on the layer. I'm not sure if these are also arbitrary, or if they mean something, as they sometimes are differently spaced apart. For an example of this, the Colorado Counties map contains a raster layer where this occurs. Zooming into the map until at least zoom level 12.5 or more will show the lines.

Just out of curiosity, what is the highest resolution that a raster can be set to? I've seen some examples that use 512.

Thank you again for taking time out of your busy schedule to look into this! I'm still grateful to be able to use this awesome tool that allows us to create and show some pretty cool information.

DanielJDufour commented 3 years ago

Hi, @Nightsphere . Thank you for your issue. I'm glad that your are finding the library useful, and for such an awesome cause! I believe the line issue is caused because Leaflet by design slightly overlaps the tiles (and you are seeing the 1px wide overlap). I'll have to look into it more before proposing a solution. Also, always open to ideas and Pull Requests!

You probably wouldn't want to set the resolution higher than 512. The only real limitation is the memory and the CPU of the device rendering the map. If you audience is everyone, then you probably want to keep the resolution low like 64. If your audience is limited and people with more modern computers, you can set a higher resolution like 256. There's not hard rule, so you probably just want to experiment and see what works for you.

The resolution parameter is how many samples to take across and down from a dataset for each map tile. Typical tiles are 256 x 256 pixels (higher resolution are 512 x 512).

Technically, web mercator is in meters, so you could calculate the width of each tile sample area in meters if you wanted. However, the meters would double as you decrease your zoom level.

Happy to discuss more. Thank you for your interest and questions!

Nightsphere commented 3 years ago

Thank you again for answering so quickly! This information is helpful, and if I have any other questions and/or ideas for updates I'll let you know in the future. Closing the issue.