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 from rasterio/gdal to pyproj #58

Merged
merged 16 commits into from
Sep 9, 2021
Merged

Conversation

vincentsarago
Copy link
Member

as seen in #56 and #57 we are constantly fighting with change in rasterio/gdal/proj. The main problem is that we used rasterio (which is a raster library) to access Proj C libs via GDAL. It worked ok, and we choose this to avoid mixing PROJ version used in the code base (for a long time rasterio wheels where using PROJ 6 while pyproj was already using PROJ>=7).

This PR replace any rasterio calls by pyproj.

⚠️ this is a highly breaking change ⚠️

@@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyproj only supports >=3.7

morecantile/commons.py Outdated Show resolved Hide resolved
@@ -56,4 +56,4 @@ def register(
return TileMatrixSets({**self.tms, **new_tms})


tms = TileMatrixSets(deepcopy(default_tms)) # noqa
tms = TileMatrixSets(copy(default_tms)) # noqa
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deepcopy complained about the pyproj Transformer. Used copy and it worked 🤷‍♂️

morecantile/models.py Outdated Show resolved Hide resolved
@@ -121,13 +124,25 @@ class TileMatrixSet(BaseModel):
wellKnownScaleSet: Optional[AnyHttpUrl] = None
boundingBox: Optional[TMSBoundingBox]
tileMatrix: List[TileMatrix]
_to_wgs84: Transformer = PrivateAttr()
_from_wgs84: Transformer = PrivateAttr()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we initialize the transformers once!

tms = morecantile.tms.get("WebMercatorQuad")
with pytest.warns(PointOutsideTMSBounds):
xy = tms.xy(0.0, -90)
assert xy.x == float("inf")
assert xy.y == float("-inf")
assert xy.y == float("inf")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inf or -inf 🤷‍♂️

morecantile/models.py Outdated Show resolved Hide resolved
morecantile/models.py Outdated Show resolved Hide resolved
@vincentsarago vincentsarago mentioned this pull request Aug 19, 2021
@vincentsarago vincentsarago marked this pull request as ready for review August 23, 2021 12:13
morecantile/models.py Outdated Show resolved Hide resolved
@vincentsarago vincentsarago changed the title [PROPOSAL] switch from rasterio/gdal to pyproj switch from rasterio/gdal to pyproj Aug 23, 2021
@vincentsarago vincentsarago merged commit e3874ad into master Sep 9, 2021
@vincentsarago vincentsarago deleted the FromRasterioToPyProj branch September 9, 2021 09:24
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

Successfully merging this pull request may close these issues.

2 participants