Creating a usable heightmap | 3DEP Dataset (US) - ballisticfox/MapTheEarth-KSP GitHub Wiki

This tutorial is specifically for the 3DEP Dataset and areas within the US. To create this I will be following my process that I followed for developing the Vandenberg Spaceforce Base, tile n35w121.

Requirements:


Creating a Heightmap

The first thing you're going to need to do is make an account with TNM. After doing this, select the area that you wish to download. For the dataset we're using select 3DEP Elevation Products and select the 1/3 arc-second DEM, hit search products and it'll give you the one you need. Download the tiff and copy it to your workspace.

Opening the tiff at this point will yield an image with a variety of layers, coastlines may have some detail but a vast majority will be pure white. This is because the tiffs are stored with the max value being the real world height in meters, gimp likes to use a scale of 0-1 and really doesn't like values over that, so it will display most of the image as pure white. image

To fix the issue we'll need to normalize the values using imagemagick, luckily you can do this pretty easily without really thinking. The first command we're going to use is a info command to get the min and max values of the image. To open a command prompt window in your workspace click on the filepath bar and type 'cmd'.

magick -quiet *FILENAME*[0] -define quantum:format=floating-point -verbose info:

To break this command down for future reference: call magic, suppress errors, select file, [0] defines layer 0 only, define special characteristic, floating point format, detailed info. In my case I will use:

magick -quiet USGS_13_n35w121_20210301.tif[0] -define quantum:format=floating-point -verbose info:

This will give us quite a bit of information but we're only really interested in this part

image

The min and mean values don't mean much but the max value is what we're after, I also highly suggest you save this for later as you'll need it for the model.

Next, let's normalize it

magick -quiet *FILENAME*[0] -define quantum:format=floating-point -evaluate divide *MAXHEIGHT* -clamp *NEW FILENAME*

Once again to break it down, call magic, suppress errors, select file, layer 0, define as floating point, perform math operation: divide by MAXHEIGHT, clamp the minimum value to 0, new filename being the output file.

In my case I will use:

magick -quiet USGS_13_n35w121_20210301.tif[0] -define quantum:format=floating-point -evaluate divide 1471.98 -clamp n35w121_height.tif

image Now that looks a lot more like a heightmap!

Continue on to: Meshing your heightmap.