4

Given a topographic GIS raster of one country:

Given an elevation threshold n = 50 (meters)

How to polygonize pixels when z >= n ?

gdal_polygonize.py is not clear on this point. It states This utility creates vector polygons for all connected regions of pixels in the raster sharing a common pixel value. So I guess it MUST be like z = something and only this. I don't understand where to state the condition.


Current workflow details:

# download:
curl -o ETOPO1.zip 'http://www.ngdc.noaa.gov/mgg/global/relief/ETOPO1/data/ice_surface/grid_registered/georeferenced_tiff/ETOPO1_Ice_g_geotiff.zip'
# unzip:
unzip ETOPO1.zip
# crop:
gdal_translate -projwin -005.50 051.30 10.00 041.00 ETOPO1_Ice_g_geotiff.tif crop.tif

Related to: Topography: How to convert raster into vector layers?, Get a pixel value.

8

Given your crop.tif raster layer, you can filter its pixels whose elevation is above the threshold (50 m) using gdal_calc.py:

gdal_calc.py -A crop.tif --outfile=result.tif --calc="A>=50" --NoDataValue=0

The result.tif will be made of 1 where the condition is satisfied, 0 otherwise. Then, it will be possible to vectorize result.tif using gdal_polygonize.py:

gdal_polygonize.py result.tif result.shp

Finally, you can filter only the polygon(s) you need creating a new shapefile:

ogr2ogr filtered_result.shp result.shp -where "Value=1"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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