Skip to content
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

Change projection of rasters overlaid on Mapnik #158

Open
corinat opened this issue Dec 7, 2017 · 11 comments
Open

Change projection of rasters overlaid on Mapnik #158

corinat opened this issue Dec 7, 2017 · 11 comments

Comments

@corinat
Copy link

corinat commented Dec 7, 2017

Hello,
I am new to GeoNotebook, I am at the stage where I try to understand how GeoNotebook works, or more precisely what each of the python libraries that are used in GeoNotebook do.

What I didn't understand is how I can change the projection of the rasters overplayed in Mapnik? What is the library that does this, is it Mapnik or Rasterio? For the vectors, is Shapely, if I am not mistaken.

@jbeezley
Copy link

jbeezley commented Dec 7, 2017

At a low level, raster reprojection is handled by GDAL. Rasterio has functions that wrap GDAL and make it more palatable to use. To reproject a raster, you can either do it offline with a command-line tool like gdalwarp, or you can do it by generating a vrt file. gdalwarp can help in generating a vrt file by specifying the output format as "VRT".

For vectors, shapely has a function called transform that can perform an arbitrary transforms on all coordinates. See this stackoverflow answer for how it can be used with pyproj to reproject geometries. GDAL can also reproject vector files using the commandline tool ogr2ogr.

@corinat
Copy link
Author

corinat commented Dec 7, 2017

Actually my question is, changing the projection will change the aspect of the raster too? I can only see the raster from a side, not actually a rectangle, more like a diamond shape. If the shape is preserved (no matter the projection), that it is actually how Mapnik displays images?

@jbeezley
Copy link

jbeezley commented Dec 7, 2017

Mapnik (via GDAL) transparently reprojects the image while tiling if the projection is set correctly in the source image. Is the image actually projected correctly when you see it? I'm guessing the "diamond shape" is a result of reprojecting from a source image provided in a sinusoidal projection common among satellite imagery.

@corinat
Copy link
Author

corinat commented Dec 12, 2017

Probably it would have been better if I had said I am trying to reproject the images from the examples that come by default with GeoNotebook. But I had a closer look and I think the way images are displayed on Mapnik has nothing to do with the projection in this case, but more with the image itself, because the projection is 4326.

@jbeezley
Copy link

I see, you want to set the projection of the map on the client. It's possible to get mapnik to output tiles in other projections, but there isn't any code in geonotebook to handle this. In principle it could be done, but there are a lot of places in the code base that assume that the display projection is in web mercator.

@corinat
Copy link
Author

corinat commented Dec 12, 2017

Ah, I see. So it is necessarily a Mapnik issue, it is how GeoNotebook is set to display images. It would be nice to be able to change projection, at least for the most common ones. :)

@aashish24
Copy link
Member

@corinat what projection you are hoping to use inside GeoNotebook?

@corinat
Copy link
Author

corinat commented Dec 22, 2017

Hi @aashish24. I apologies for the late response. EPSG 4326 would be great.

@philnugent
Copy link

I've been looking for 4326 support in interactive map widgets and would like to see 4326 included as well. Of the three modules I've looked at (ipyleaflet, folium, GeoNotebook) only folium supports 4326.

@jbeezley
Copy link

jbeezley commented Feb 6, 2018

What is your motivation for displaying the map in 4326? In terms of visual distortion, it is worse than 3857 in every way. If you are just looking to display gridded that is given on a regular lat/lon grid, mapnik can seemlessly reproject them while generating the tiles for display. Many if not all of the examples that we have created use datasets given in 4326.

While displaying the map in an alternate projection is certainly something we can consider implementing, I want to make sure there isn't an easier option available for your use case. Also note that if the map were displayed in an alternate projection, you would have to find (or create) a base layer tile server that supports it. I don't know of any publicly accessible tile servers that provide 4326.

@philnugent
Copy link

philnugent commented Feb 8, 2018

@jbeezley Thanks for your response. We have large stores of imagery that are served only in 4326. I was working on a proof of concept/demonstration that would allow a user to search and display imagery from this source for which they could train and run ML models. We have moved on to another phase, but I would still be interested in any plans to add support for 4326 as I think this project is really valuable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants