1

I'd like to modify a DEM to approximate what an area looked like 3000 years ago, which primarily involves adjusting coastlines based on scattered core sample data. It doesn't have to be scientifically accurate, although that would be ideal, I'm mostly hoping to achieve this for the aesthetics of an eventual visualization.

I don't really want to go this route, but all I can come up with is photoshop.

  • 1
    Honestly, editing the DEM in e.g. Photoshop might be the easiest route. You'll probably need to convert it to a GeoTIFF, save the metadata with listgeo FILENAME.tif > FILENAME.metadata, edit it in Photoshop, save it as FILENAME.edited.tif, then restore the metadata with geotifcp -g FILENAME.metadata FILENAME.edited.tif FILENAME.final.tif. (Twiddle those commands as desired) – Alex Hajnal Nov 9 '18 at 21:24
  • Thanks, Alex. I hadn't even considered that i'd lose the metadata in the process. Would you mind walking me through the listgeo process a little more slowly? Is this something I can do from the python console within qgis? – BogBody Nov 9 '18 at 22:42
  • 1
    De nada. I'm not sure if Photoshop preserves GeoTIFF metadata but I know GIMP clobbers it on save. – Alex Hajnal Nov 9 '18 at 22:46
  • 1
    Those commands are run from the OS commandline (Ubuntu Linux in my case). The Ubuntu package is geotiff-tools; Windows and Mac binaries can be downloaded from here (I haven't vetted that source). Documentation links: geotiffcp listgeo – Alex Hajnal Nov 9 '18 at 22:59
  • 1
    To convert the DEM to a GeoTIFF use gdal_translate -of GTiff "FILENAME.dem" "FILENAME.tif" or just load the DEM into QGIS, right click on the layer, and choose Save as. The biggest problem you're likely to encounter is on the Photoshop side. You'll probably need to stretch the GeoTIFF's constrast before editing it then compress the contrast range back to what it was originally before saving it. Kind of clunky but I'm not sure there's a better solution outside of very specialized (read: expensive) software packages. – Alex Hajnal Nov 9 '18 at 23:12
2

Honestly, editing the DEM in e.g. Photoshop or GIMP might be the easiest route. Here's how you might go about it:

  • Convert the DEM to a GeoTIFF
    This can be done with
    gdal_translate -ot Float32 -of GTiff "FILENAME.dem" "FILENAME.tif" (for 32-bit floating point, recommended) or
    gdal_translate -ot UInt16 -of GTiff "FILENAME.dem" "FILENAME.tif" (for 16-bit unsigned integer)

    Other bit-depths are supported:
    Int16 UInt16 UInt32 Int32 Float32 Float64 CInt16 CInt32 CFloat32 CFloat64
    Note that only the various Float types have sub-meter precision; all of the Int types are accurate only to the meter in elevation.
    (I'm not positive as to what bit-depths/formats are supported by Photoshop and GIMP)

    Instead of using gdal_translate, you might be able to simply load the DEM into QGIS, right click on the layer, and choose Save as.

    Depending on the source, the original DEM might have a different extension e.g. FILENAME.img

  • The resulting GeoTIFF contains the elevation of each point in the DEM as a greyscale value with the value being the elevation in meters. For example, sea level would be 0 (black) while 1km elevation would be 1000 (a very dark grey).

  • Save the DEM's metadata
    listgeo FILENAME.tif > FILENAME.metadata

  • Open the GeoTIFF in an image editor
    This could be e.g. Photoshop or GIMP 2.10 (or later). The editor must support high bit-depth images.

  • Stretch the image's contrast
    The contrast should be stretched so that you can see what you're editing. e.g. if your DEM ranges in elevation from 100m to 200m you'll want to stretch the contrast so that 100 is mapped to black and 200 to white. Make sure that all of your spot elevations, etc. fall within this range. The GIMP tool for doing this is Colors → Levels; I don't know what the Photoshop equivalent would be.

  • Edit the image as desired
    The airbrush tool should be useful. Remember, the lighter the color, the higher the elevation. The image should be greyscale since you're only working with a single band of data (elevation).

    To convert a spot elevation (in meters, e.g. from a core) to a greyscale value use: grey_value_percent = 100.0 × ( spot_elevation - dem_low ) / ( dem_high - dem_low ) where dem_low and dem_high are the elevation extrema (in meters) that you used when stretching the image contrast.

  • Compress the image's contrast
    The contrast should be compressed back to what it was originally. If, for example, you changed 100m to black and 200m to white you'll want to adjust the image's contrast so that black is mapped to 100 and white is mapped to 200. The GIMP tool for doing this is Colors → Levels; I don't know what the Photoshop equivalent would be.

  • Save the edited file
    Save it as FILENAME.edited.tif

  • Restore metadata
    It's doubtful that the GeoTIFF's metadata survived the editing so restore it using:
    geotifcp -g FILENAME.metadata FILENAME.edited.tif FILENAME.final.tif

  • The resulting file (FILENAME.final.tif) can be used just as you would any other DEM.

All commands given above are run from the OS commandline.

This process is kind of clunky but I'm not sure there's a better solution outside of very specialized (read: expensive) software packages.

Note that some of what I described above is untested; kindly report any bugs or corrections as a comment below.

I'd also recommend doing a run-through of the entire process before doing any major image editing. That way if you run into any insurmountable snags you won't have lost a lot of work.

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.