Open-EO / openeo-geotrellis-extensions

Java/Scala extensions for Geotrellis, for use with OpenEO GeoPySpark backend.
Apache License 2.0
5 stars 3 forks source link

consider using iso lines for raster to vector #301

Open JeroenVerstraelen opened 1 month ago

JeroenVerstraelen commented 1 month ago

Screenshot from 2024-06-04 16-24-16

The current implementation of raster_to_vector can cause quite a few problems in the output polygons that make them unusable for further processing. This is known problem that is usually solved by using iso lines.

cc @EmileSonneveld

EmileSonneveld commented 1 month ago

Perfectly parallel lines and polygons that touch perfectly aligned can cause some issues like considering polygons inside out, or unable to calculate overlaps. When taking iso-lines (or marching squares) tent to have less of those issues. Also they weight less.

I would propose a threshold argument: raster_cube.raster_to_vector(threshold=800)

For binary images, it would allow us to do: gaussian_blur(raster_cube, range=0.2).raster_to_vector(threshold=0.5) (A method used by ITK-Snap)

Downsides for doing this on binary images are that it would be less precise and that some might say that it is not true to the original data. But the differences are mostly on sub-pixel proportions.