Geographic Information Systems Asked on October 3, 2021
I am attempting to polygonize a raster using GDALPolygonize() in a Python script. The script began polygonizing yesterday at 5pm and is still polygonizing now at 9:30 am. I have no clue how far along it is, but I know it is still going because when I refresh my Windows explorer I can see the file size change for the output shapefile.
My raster is rather large, but I still don’t expect it to take this long. My raster is 35,486 Columns and 23,682 Rows with a 1 meter cell size. It is a binary raster where a value of 1 represents data and 0 is NoData.
When I polygonized in ArcGIS using Raster to Polygon in the Conversion Toolbox it took 56 seconds. The resulting shapefile is 200mb while the shapefile still being created by GDALPolygonize is still only 100mb. That makes me think GDAL is about half way done after running all night.
Specs:
Windows 7 64bit,
8gb RAM,
GDAL 1.10 64bit,
ArcGIS Desktop 10.2,
64bit Background Geoprocessing for ArcGIS Desktop,
Python 2.7.3 64bit
UPDATE
Day 2 – GDALPolygonize is still running. It has gone overnight 2 nights in a row and through a whole day without completing. ArcGIS took 56 seconds.
I have the same experience. The algorithm is really slow for huge rasters, although quite fast for smaller ones. There is one possible workaround:
gdalwarp -te 12.08 48.5 12.5 51.1 original_file.tif part1.tif
gdal_polygonize.py part1.tif -f "ESRI Shapefile" part1.shp
ogr2ogr -f "ESRI Shapefile" -update -append merge.shp part1.shp -nln merge
ogr2ogr "output.shp" "input.shp" -dialect sqlite -sql "SELECT ST_Union(geometry), field FROM input GROUP BY field"
The final time was way faster.
Answered by Stanislav Dušek on October 3, 2021
I had the same problem of polygonize a huge raster image of 29728x121912 pixels, it took 19654s or 5.5 hours to terminate the job. I swithed to QGIS Desktop 3.14 with GRASS 7.8.3. In the processing toolbox I used GRASS tool r.to.vect to polygonize the same raster image in 375s or 52 times faster than GDAL.
In addition:
When you use GRASS with QGIS the later will hide the complexity to use GRASS (import and export data in native GRASS format).
GRASS has a simplify parameter that creates an excellent polygonization but with less vertice (smaller output file).
GRASS has a "region cell size" parameter that will accelerate the polygonization if you want a coarser polygonization (it's a float value, the coarser the faster).
If you want to batch your polygonization starting with QGIS 3.14, there is a real batch mode. It's called qgis_process. See the change log
Answered by D Pilon on October 3, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP