1

I'm using Python's folium library (which uses Leaflet) to display images over a map.

However, my original data uses EPSG:3035 and folium uses EPSG:4326 (WGS84). There is a rotation when converting from one to another.

With pyproj, I'm able to reproject the bounds into 4326 but folium's ImageOverlay function demands a bounds argument as follows : [[lat_min, lon_min], [lat_max, lon_max]] so I can only specify a "straight" rectangle.

The image below shows the result that I get and the rectangle which the image should fit into.

Current and expected results

Is it possible to rotate the bounds? How can I display my data at the right place?

0

Unless leaflet/folium can do this on-the-fly, you need to reproject your image to EPSG:4326. This involves a change of the grid system for your data, and is usually a lossy operation. Its unlikely this is a simple rotation, since you are transforming from a conical projection of the GRS80 ellipsoid to a lat-long coordinate system on the WGS84 ellipsoid.

I'd probably do this by using the gdalwarp command line tool, or its interface from QGIS, or similar tools in R. You'll end up with your rotated image within a larger rectangle filled with missing values, which should be rendered as transparent.

The Python rasterio package has functionality for raster warping: https://rasterio.readthedocs.io/en/latest/

  • gdalwarp can do it indeed. But I'm working with numpy arrays in notebooks and I'd like to do it in these notebooks, on the fly. Do you know of any library to do that? – Fx Stempfel Aug 10 '18 at 7:21
  • The reason why I want to do it on-the-fly is that I need to concatenate multiple tiles (which I do with numpy arrays) to build the image I display, which is easy with native projection but harder if each tile is warped beforehand. I guess I could create a temporary assembled image with GDAL and then warp it but I think the performance would not be great. – Fx Stempfel Aug 10 '18 at 7:45
  • Try rasterio? See edit. – Spacedman Aug 10 '18 at 8:02
  • Indeed, this can be done with rasterio. Thanks a lot! – Fx Stempfel Aug 10 '18 at 14:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.