Skip to content

Instantly share code, notes, and snippets.

@sgillies
Created January 16, 2014 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sgillies/8465883 to your computer and use it in GitHub Desktop.
Save sgillies/8465883 to your computer and use it in GitHub Desktop.
polygonizing with rasterio and fiona
import rasterio
with rasterio.open(raster_filename, 'r') as src:
image = src.read_band(1) # read
features = rasterio.features.polygonize(image) # no I/O!
with fiona.open(vector_filename, 'w', **meta) as dst:
dst.writerecords(features) # write
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment