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

✨ GeoPandasRectangleClipper for spatially subsetting vectors #52

Merged
merged 3 commits into from
Sep 5, 2022

Conversation

weiji14
Copy link
Owner

@weiji14 weiji14 commented Sep 5, 2022

An iterable-style DataPipe for clipping vector geometries with the rectangular bounding box extent of raster grids!

Preview at https://zen3geo--52.org.readthedocs.build/en/52/api.html#zen3geo.datapipes.GeoPandasRectangleClipper

Needed for #49

TODO:

  • Initial implementation
  • Add unit tests
  • On-the-fly reproject vector CRS to raster CRS if they don't match

Possible extensions in future PRs

An iterable-style DataPipe for clipping vector geometries with a raster grid! Uses the rectangular clip algorithm in geopandas.clip for the spatial subsetting. Included a doctest that ensures a geopandas.GeoDataFrame can be clipped by two xarray.DataArray grids. Added a new section in the API docs too.
@weiji14 weiji14 added the feature New feature or request label Sep 5, 2022
@weiji14 weiji14 added this to the 0.4.0 milestone Sep 5, 2022
@weiji14 weiji14 self-assigned this Sep 5, 2022
Ensure that a geopandas.Geoseries vector can be clipped using xarray.Dataset rasters, and that vector datapipes which are too long (len > 1) raise a NotImplementedError properly.
To handle raster images with different coordinate reference systems, do on-the-fly reprojection of the vector geopandas.GeoDataFrame to match the raster xarray.DataArray's coordinate reference system. Have added a unit test with EPSG:3857 and EPSG:32613 chips, and noted this automatic reprojection feature in the docstring. Need to refactor this basic implementation to be more efficient as the whole geodataframe is being reprojected rather than a subset only.
@weiji14 weiji14 marked this pull request as ready for review September 5, 2022 22:13
@weiji14 weiji14 merged commit b271aca into main Sep 5, 2022
@weiji14 weiji14 deleted the geopandas/clip_vector_with_rectangle branch September 5, 2022 22:21
weiji14 added a commit that referenced this pull request Sep 7, 2022
Just a random collection of mostly documentation-related patches. Patches type-hints in #52, isort imports in #35, mention functional name of IterDataPipe in walkthroughs #8 and #20, and remove mention of returned tuple to patch #33.

* 🏷️ Add specific type hints for mask_datapipe in geopandas.py

Should be either an xarray.DataArray or xarray.Dataset.

* 🚨 Sort spatialpandas imports in datashader.py

Ran isort to sort spatialpandas.geometry imports alphabetically. Also intersphinx linked the `.crs` attribute to geopandas.GeoDataFrame.crs.

* 💬 Mention functional name of IterDataPipe in walkthroughs

So people don't get confused on why the class-form like `Collator` is mentioned but `.collate` was used instead.

* 📝 Remove mention of tuple being returned in test_pyogrio_reader

Forgot to edit the unit test's docstring. Patches #33.

* 🍻 It's GeoPackage and GeoDataFrame, not GeoTIFF and DataArray

Need to be more careful when copying and pasting stuff.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant