I have a DEM that includes bathymetry and terrain elevation and I would like to split it at the coastline. Ideally, I would end up with one tif that's land and one tif that's bathymetry.

I have searched for this feature in GDAL commands and in QGIS but I can't find anything that extracts based on an elevation range.

  • 2
    do you have any python experience? this is a very simple task if you create two identical dimension rasters and copy the values to one if <= 0 and the other if >= 0. I can't see a tool for it straight away in GDAL, if you have access to ESRI you would be wanting extract by attributes (geoprocessing tool) Commented Apr 12, 2014 at 3:10
  • Thank you! I think I know enough python to figure this out.
    – jfact0ry
    Commented Apr 12, 2014 at 5:35
  • Awesome! It should be fairly straightforward but if you run into any difficulties there are plenty of 'GDAL in python' posts to help you through the bumpy bits. It's a bit of a shame that there's not an off-the-shelf solution for this, it seems like something that would be required occasionally. Commented Apr 13, 2014 at 4:59

1 Answer 1


Basically, you can make two rasters on the same extent, one with height and the other with bathymetry, but rasters are always rectangle so you will have a lot of "zeros". If you only use gdal tools, you could use gdal_calc, for example:

gdal_calc.py -A dem.tif --outfile=bathymetry.tif --calc="(A<=0)*A"

gdal_calc.py -A dem.tif --outfile=elevation.tif --calc="(A>=0)*A"

A<=0 will evaluate as 0 or 1.

Remark 1: Be careful that land surfaces are sometimes below the sea level, so a simple threshold is sometimes not sufficient.

Remark 2: I also suggest you to add '-co COMPRESS=LZW -co TILED=YES' as tif creation 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.