I have a big raster file (129600 by 64800 pixel) with global water bodies (1 bit values 0 and 1) and try to extract ocean and inland water shorelines.
I've tried with ArcGIS and QGIS to convert from raster to polyline, but it takes ages.
Does anybody know a better/faster way (Python or R) or a better tool for this task?
- R: rasterToContour might be fast and precise but if you have a very large dataset like mine (8,398,080,000 pixels) you need either a very big amount of RAM (more than 16GB) or you force R to do more processing on the hard drive and it will also take ages.
- Python/GDAL: gdal_poligonize creates polygons instead of polylines
- R rasterToContour: rasterToContour does not deliver the wanted results. Compared to ArcGIS (raster to polygon followed by feature to line) it does not extract the exact pixel outline, as shown in the examples below.
Python/GDAL: I've run gdal_polygonize from command line against ArcGIS on a test dataset and the results were extremely clear:
- gdal: 49 seconds
- ArcGIS: 1.84 seconds