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...

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

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
  • 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 Oct 18 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. – Jakob Miksch Oct 19 at 14:14
  • Yes, that was the problem!! Thanks – Caro Oct 22 at 16:06

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.