Convert binary mask to shapefile

I have a large (20,000 x 25,000) binary mask that defines the shape of an island.

What’s the best way to convert the mask into a polygon and and save it as a shapefile?

I think Qgis is convenient to do so.

here is a manual about how to convert raster to polygon.shp

https://docs.qgis.org/

1 Like

Thanks, @sidpku. So no way to do it in Julia? I’ve got about 600 masks to convert to shapefiles, currently in the form of a 20000x25000x600 data cube in a NetCDF. I was hoping to write a Julia workflow that could do this automatically. Dreaming of a function like

mask2shapefile(x, y, mask, filename="mynewfile.shp", epsg_code=1234)

@chadagreene we didn’t try our algorithms with such large images yet, but we have a transform called Potrace (polygon tracing) in the GeoStats.jl stack:

using GeoStats

# georeference mask image
dat = georef((mask=mask,))

# trace shape from mask variable
shape = dat |> Potrace(:mask)

Please let us know if you find performance bottlenecks.

This algorithm was quite tricky to implement correctly. It handles any arbitrary number of nested holes in the shape.

1 Like

ok, I’ll give it a shot!

1 Like