weiji14 / zen3geo

The 🌏 data science library you've been waiting for~
http://zen3geo.rtfd.io/en/latest/walkthrough.html
GNU Lesser General Public License v3.0
77 stars 3 forks source link

:sparkles: RasterioRasterizer for burning vector shapes to xarray grids #32

Closed weiji14 closed 2 years ago

weiji14 commented 2 years ago

An iterable-style DataPipe for turning vector geometries into raster images! Uses rasterio to do the rasterization.

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

Note that I had thought about using a vendored version of rasterio.features.rasterize from another library. These are some bullet points:

Alternatively, rasterization can also be done using datashader which is super fast as it uses numba (see e.g. code snippet at https://github.com/weiji14/deepicedrain/blob/41917ea515edbe548975e2a25c25ff55c6eb4b1a/deepicedrain/spatiotemporal.py#L109-L133). However, on the dependencies front:

That said, the turning point to switch to datashader-based rasterization might be when shapely 2.0 gets released and matures enough to the point that the geospatial vector Python ecosystem starts using it.

TODO:

weiji14 commented 2 years ago

Closing as superseded by datashader-based method #34 and #35 which offers a faster and more customizable (albeit more steps) way of performing rasterization.