geoblaze
geoblaze copied to clipboard
Clip Raster by Vector
Is your feature request related to a problem? Please describe.
A user should be able to clip a raster by a vector. In other words, the clip function should clip the raster by the geometry's bounding box and set all the remaining values outside of the geometry to No Data. It should also update the metadata for the raster.
Describe the solution you'd like A clear and concise description of what you want to happen. Create a clip module that takes in a georaster and geovector and returns the result as a georaster. The approach could include:
- Calculating bbox of geometry
- Getting insides of the geometry
- Iterating through rows of pixels, creating a new row starting at xmin of geometry, and adding NoData where outside geometry and current pixel value where inside the geometry
Describe alternatives you've considered None at the moment
Additional context
You'll need to borrow some logic from https://github.com/GeoTIFF/geoblaze/blob/master/src/intersect-polygon/intersect-polygon.module.js and potentially split out some of the code, creating a separate getInsides module
Probably want to look at georaster and maybe returning georaster with clipped values github.com/GeoTIFF/georaster