I am attempting to polygonize a raster using GDAL C API. The input rasters can contain nodata pixels. My current method (see the code below) produces a new polygon vector, but the output also includes polygons representing nodata pixels. Is there a way to exclude nodata pixels from being polygonized or to remove new nodata polygons after polygonization?
driver = GDALGetDriverByName("ESRI Shapefile"); dh = GDALCreate(driver, vector_fname, 0, 0, 0, GDT_Unknown, NULL ); OGRSpatialReferenceH srs = OSRNewSpatialReference(srs_txt); layer = GDALDatasetCreateLayer(dh, "new_layer", srs, wkbMultiPolygon, NULL ); field = OGR_Fld_Create("new_field", OFTInteger); OGR_L_CreateField(layer, field, TRUE) OGR_Fld_Destroy(field); GDALPolygonize(hBand, NULL, layer, 0, NULL, NULL, NULL); GDALClose(dh);