I've been trying to batch convert raster files to polygons then delete areas <100m2 before clipping the raster to the filtered polygons.
I have referred to both the below posts:
- Is there any way to add an area column to new shapefile created from raster with gdal's polygonize in the same step?
I have tried to use the desired command in its simplest form:
ogr2ogr ouput.shp input.shp -sql "SELECT *, OGR_GEOM_AREA AS area FROM input"
Despite this I still get the error "ERROR 1: SELECT from table input failed, no such table/featureclass."
I know that the input.shp exists and is in the same directory as my batch file, so I can only assume that the OGR_GEOM_AREA can not be found.
I notice that the gdal_polygonize step I use prior writes the output in GML format: "Creating output input.shp of format GML."
Could this be the source of the issue?
If so I have not been able to find how to change the polygonize output format to something more ogr friendly.
I did some tests and can confirm that the issue is definitely the GML format being output by gdal_polygonize