allenai / satlas

Apache License 2.0
184 stars 19 forks source link

Georeferanced ploygon masks as output #41

Closed pyaada closed 3 months ago

pyaada commented 4 months ago

I am following the custom inference document to apply the pretrained Solar Farm model on Sentinal 2 Imagery. The model inference works as expected, however, I am losing information when I convert the georeferenced jp2 image I get from Sentinal to a tif file and then to a numpy array. I want to export the output masks as a raster or shape file. What would be the easiest way to achieve this?

rbavery commented 3 months ago

https://rasterio.readthedocs.io/en/stable/api/rasterio.features.html#rasterio.features.shapes can extract connected shapes from an array and returns shapely polygons that can be converted to geojson or a shapefile.

favyen2 commented 3 months ago

To add on to that, unfortunately we don't have an easy way to do it, you would need to reference the original JP2 or GeoTIFF to transform the pixel values detected from the numpy array back to georeferenced coordinates. But the numpy/JP2 should match up so it should be possible to do this transformation.