2

I need to do batch processing from a raster with 120 bands (GeoTIFF). I need 120 contour line shapefiles, but I get only one. I had no problem when the result is another raster file with all the bands, but the contour line is a shapefile, I don´t know if this is the problem...

1
  • You need to either generate contours from one band, or save each band to a temporary raster, and generate a contour from that.
    – Vince
    Commented Oct 18, 2019 at 15:33

1 Answer 1

4

with the commanline tool gdal_contour you can choose from which band the contour lines shall be created. In this example band 42:

gdal_contour -a elev dem.tif contour_band_42.shp -i 10.0 -b 42

This can be integrated in a batch file. On Unix it should be something like this:

for BAND in {1..120} 
do
  gdal_contour -a elev dem.tif contour_band_${BAND}.shp -i 10.0 -b ${BAND}
done
3
  • Thanks Jakob, It sounds correct, but is not posible to edit GDAL console. I try to run in python console the script but it dosen´t work, neither the one that GDAL create for one band
    – Caro
    Commented Oct 18, 2019 at 17:55
  • which operating system are you using? On Windows you have the GDAL commandline tools inside the OSGeo4W shell. There the syntax for the for loop might be slightly different than in my answer. Commented Oct 19, 2019 at 14:14
  • Yes, that was the problem!! Thanks
    – Caro
    Commented Oct 22, 2019 at 16:06

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.