I have a DEM, a.vrt from HEC-RAS model. It's massive. Approximately 100k X 100k pixels. I need to trace it's boundaries. So everywhere that's not NaN.

My current workflow is:

  1. Create new raster using gdal_calc.py (or calculator in QGIS) to create a boolean mask with non-NaN values.
  2. gdal_polygonize.py - in QGIS to get polygon outline.

Step 1 is taking forever. On pace for 7 hours processing time. Is there a way to run gdal_polygonize directly and skip Step 1? Perhaps an option or hack to polygonize NaN or non-NaN values?

enter image description here

  • VRT rasters are slow to process. I would write a python script to call your GDAL_Calc and GDAL_Polygonize on the source rasters using subprocess.Popen to perform the calc on as many cores as you have then merge and dissolve the vectors when that's all done. You could speed it up by omitting tiles that are definitely inside/outside the boundary - no need to process tiles that are either all good or all bad. Aug 4, 2023 at 0:13

1 Answer 1


Two options:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.