-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GeoTiff reprojection from WGS84 to Mercator #15579
Comments
You need to prevent excessive overzooming of the original tiles during reprojection by limiting the
works in your CodeSandbox. You could attempt to calculate an appropriate setting based on |
Thanks for the quick response. At first the sugested solution looked good, but having a closer look I realized it interpolates between cells to get the pixel value. I forked the minimal example and added @mike-000's sugested solution. Unfortunatly I don't really get how setTileGridForProjection and createXYZ work, so I couldn't fix this problem. I could only play around and change the values, but it never happened to work out as excpected.
How could I calculate this? |
The unwanted interpolation is only seen in Firefox, see #14099. It can be fixed with a polyfill such as
|
Thanks a lot this did the deal. |
The aim would be to avoid having target (reprojected) tile grid resolutions which would result in source resolutions calculated by https://github.com/openlayers/openlayers/blob/main/src/ol/reproj.js#L104 being smaller than those available in the source. Maybe this could/should be attempted for all reprojections? However as in https://openlayers.org/en/latest/examples/geotiff-reprojection.html what might work well at the equator may not be suitable for polar regions or vice versa. |
Hmm even after hours of playing around with Here is my actual setup: codesandbox I tried setting |
In your case your source has non-square-pixels i.e. the rendered aspect ratio of tiles in the tile grid does not match the 256 : 256 ratio of their data. Reprojection only produces tiles with square pixels and scales up one dimension to achieve that. This code will maintain alignment of columns as in the unreprojected source, but the row alignment is not precise
|
Thanks a lot @mike-000 Thats a bit disapointing, but then maybe openlayer was not the tool to go. :-( |
The problem is that the tiles can't be reprojected to mercator without having non-square tiles, resulting in strange effects with openlayer. see openlayers/openlayers#15579
Just to show the resulting problem, I added some Polygons of the Grid shapes, where there border should be to the CodeSandbox. |
Yes, that is to be expected as your non-square pixels are being drawn as square pixels in a canvas stitch context optimised for one dimension only before reprojection. Ideally your GeoTIFF should have better resolution, e.g. instead of one tile with 256 x 256 pixels have 2560 x 2560 pixels in 100 tiles. While OpenLayers could potentially take an option to scale up before reprojecting (e.g. drawing 256 x 256 pixels as 2560 x 2560 pixels in a larger stitch context) that would use a lot of system resources compared with tiling for which GeoTIFFs can be optimised. |
Oh wow. I'm not completly sure, why this works now, but this was the missing tip. Thanks @mike-000 Interestingly it did only work with this specific pixel resolution (used now 4 times as many pixels as before). If I went up It sstoped working again. |
Describe the bug
Openlayers reprojection of a GeoTiff TileLayer from WGS84 (EPS:4326) to Mercator (EPSG:3857) is not working as expected.
The resulting grid has different cell widths. They somehow togle from wide to thin. So one column is wide and the next one is thin.
See the screenshot:
To Reproduce
Steps to reproduce the behavior:
Go to codesandbox of minimal example or checkout the minimal example repository
Expected behavior
The grid cells should have the same width as seen in this screenshot from QGIS of the same layer and the same map projection:
The text was updated successfully, but these errors were encountered: