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

Switch to pyproj for new morecantile major release #62

Closed
vincentsarago opened this issue Aug 23, 2021 · 5 comments
Closed

Switch to pyproj for new morecantile major release #62

vincentsarago opened this issue Aug 23, 2021 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@vincentsarago
Copy link
Member

in #58 we are proposing a major change to this library.

When we started the development of morecantile we choose to use rasterio only to avoid adding requirements like pyproj (because morecantile was mostly made to work with rio-tiler). In addition for a long time rasterio wheels were stuck at proj 6 while pyproj were already using proj>=7, so we wanted to avoid using coordinates coming from 2 different proj version.

Now that rasterio wheels uses proj>=7, if think we are in a better place to switch to pyproj and thus remove rasterio from this libraries.

The main motivation is trying to avoid some weird behaviour with coordinate re-projection which seems to be better handled by proj (with rasterio, you use GDAL which use proj while with pyproj you directly use Proj).

The PR is ready and the CI passes (still trying to match mercantile tests)

What it means for libraries using morecantile

Mostly nothing. The biggest breaking change is the type of CRS being returned by morecantile.TileMatrixSet.crs property, which is now of type pyproj.CRS instead of rasterio.crs.CRS. This is used in rio-tiler for example (https://github.com/cogeotiff/rio-tiler/search?l=Python&q=tms.crs). To help with the transition we are adding morecantile.TileMatrixSet.rasterio_crs property which will return a rasterio.crs.CRS. This method will only be available is rasterio is installed.

import morecantile

# before
tms = morecantile.tms.get("WebMercatorQuad")
crs = tms.crs

# now 
tms = morecantile.tms.get("WebMercatorQuad")
crs = tms.rasterio_crs

If no negative feedback, we'll do a pre-release next week

@vincentsarago
Copy link
Member Author

I'm still not 💯 sure we should do this 🤷‍♂️
Moving to PyProj, still result in the same issues than GDAL (inconsistency with mercantile results) BUT I do think using pyproj could also help for the democratization of morecantile (pyproj is much lighter than rasterio)

Cons

  • Do not solve issues we had with rasterio
  • breaking change

Pro

  • Remove heavy rasterio dependency (+1 for project like timvt which doesn't need any rasterio methods)
  • simplify some of the internals
  • morecantile is not a raster library so IMO it makes sense to use pyproj

I would love if people could help me decide here 🙏

@vincentsarago vincentsarago added the help wanted Extra attention is needed label Aug 30, 2021
@whatnick
Copy link

I would prefer GDAL + PyProj over RasterIO. RasterIO is a useful abstraction and perhaps makes packaging GDAL easier, but removing it exposes much more GDAL internals and is very powerful overall.

@rodrigoalmeida94
Copy link

@vincentsarago here are my two cents:
I think conceptually, for this library to depend on rasterio is not ideal, since as you said, this library is not intended to work with rasters directly, so removing this dependency is a good idea in my opinion. I would also add that even tough it is a breaking change, it is a very minor one, and that I didn't make use of crs attributes in the project where I used morecantile. Hope this helps!

Background: I have used morecantile to access WMTS services from Intermap (they provide tiles in a weird non-standard tiling system that they have defined, and morecantile made it a breeze to access this data).

@benbovy
Copy link

benbovy commented Aug 30, 2021

I think that projects like xarray-leaflet or xpublish (xpublish-community/xpublish#88) may eventually benefit from morecantile without rasterio as dependency.

cc @davidbrochart

@vincentsarago
Copy link
Member Author

Thanks everyone 🙏

I would prefer GDAL + PyProj over RasterIO. RasterIO is a useful abstraction and perhaps makes packaging GDAL easier, but removing it exposes much more GDAL internals and is very powerful overall.

@whatnick

So rasterio comes with GDAL+PROJ compiled C lib but do not provide access to the functions directly. PyProj comes only with PROJ C libs but again you don't have direct access to it. For us, moving from rasterio to pyproj just remove the GDAL part, but if you really need it you can still install rasterio or GDAL. As I said earlier, morecantile use only the proj part within rasterio (no image utils) so I think it makes sense to use pyproj.

@rodrigoalmeida94 🙏

@benbovy @davidbrochart That's awesome, thanks for sharing 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants