Ogr split by attribute
✓ Published0🌍 Public
RRCura
Last edited Nov 14, 2012
Created on Nov 14, 2012
This example splits a road shapefile into multiple new shapefiles based on unique values in a chosen attribute field. Using the OGR library from GDAL, it first iterates through all features to collect distinct attribute values from the specified field (e.g., "Type"). For each unique value, it creates a new shapefile via `CreateDataSource` and `CopyLayer`, then applies an attribute filter with `SetAttributeFilter` to identify and delete all features that do not match that value. The result is one separate shapefile per attribute category, demonstrating a straightforward spatial data partitioning workflow.
AI-generated description