Professional Documents
Culture Documents
NKKNK
NKKNK
com
(949) 386-2277
Objective 2
Objective
The purpose of this document is to get elevation data from the USGS for areas in the United
States and make that data usable for Terrain Awareness in the DJI Phantom 4 RTK.
There are GIS applications, like Global Mapper, that can assist in this endeavor. But, you have
to pay for those tools. This workflow is FREE.
To do this we will go to the USGS website to get data from what is called the 3DEP (3D
Elevation Program). Formally known as the NED (National Elevation Dataset) the purpose of
this dataset is:
... to systematically collect 3D elevation data in the form of light detection and ranging
(lidar) data for the conterminous United States, Hawaii, and the U.S. territories, with data
acquired over an 8-year period. Interferometric synthetic aperture radar (IfSAR) data is
being acquired for Alaska, where cloud cover and remote locations preclude the use of
lidar in much of the State.
See: h ttps://www.usgs.gov/core-science-systems/ngp/3dep/what-is-3dep
Use the address bar or navigate to the area where we will need elevation data for the flight
using the map on the right.
Clicking “Find Products” will move you from the “Datasets” tab to the “Products” tab. You will
now see the products that USGS has available for that area. If your area is big enough, you may
have more than one product available.
Next, we will need to add these products to our cart. Click the + button next to the products you
want and click the “View Cart” button circled in red.
This should move you from the “Products” tab to the “Cart” tab.
To download the data, you just need to click the “Download” button highlighted below. This
should download a .zip file.
You will need to unzip the .zip file. Once you have unzipped the .zip file, you will find a bunch of
files and folders inside the unzipped folder.
Navigate to the folder that starts with “grdn..” in that folder, you will find some files with the .adf
file type. These are your actual DEM’s. But, those DEM’s are too big and they are not
usable, yet. We need to convert the files in order to make them small enough to work with
the P4RTK.
In order to covert and clip the data we downloaded from USGS, we will need to use a GIS
program.
We recommend a free open-source program called QGIS. We will be using QGIS in this tutorial.
You can also use programs such as ArcGIS and GlobalMapper and the steps outlined here will
be very similar as most GIS programs are built off the same open-source libraries.
Download QGIS
We strongly recommend downloading from the “Long term release repository” as it is far more
stable than the other options.
Go through the set-up wizard and open the program. In my case, it put the program in a folder
on my Desktop. Select the highlighted program below. QGIS Desktop 3.4.8
We will also be using OSGeo4W Shell later so go ahead and keep this window open for now.
Open QGIS
Once open, you can go ahead and drag and drop the largest file from your downloaded “grdn..”
folder inside the downloaded folder into the main window of QGIS.
A simple drag and drop is all you need. You should now see the elevation data in your viewer in
a black and white gradient. The Black being lower elevation and the white being higher.
Next, we need to add a base map so we can orient ourselves on the map. To do this double
click the “OpenStreetMap” under the “XYZ Tiles” drop-down in the Browser on the Left of QGIS.
You should see a new layer called “OpenStreetMap” in your layers pane in the bottom left. Go
ahead and use the viewer to find your project area. Zoom in by using the scroll wheel on your
mouse and click and drag the mouse to move around in the viewer.
Once you are zoomed in on your project area, we will need to draw a polygon to “clip” the data
we want out of the larger DEM. To do this we need to go the “Layer” tab in the very top bar of
QGIS. In the layer drop down, click the “Create New Layer” option and the “New Shapefile
Layer”. You should see a pop-up like the one below. First, we need to give the shapefile a
location where we want to save, click the three dots “...” to the right of the file name box.
This should open a finder window, from here we are going to navigate to our Desktop and make
a new folder called “DEM”. You can do this by right-clicking in the finder window, going down to
“New” and clicking “Folder”. Give the folder a name, we chose “DEM” for this demo, but you can
make it whatever you like.
Open this folder in the finder window. Then go ahead and name the file whatever you like, for
this demo, we chose “ClipBox”.
In the “New Shapefile Layer” pop-up, change the Geometry Type from Point to Polygon, and
name the field, we used “1” because it does not really matter. Leave the Coordinate system to
its default. Check everything is set properly and hit “OK”.
This should add a new layer to your layer pane in the bottom left called whatever you named the
Shapefile layer in the step above, for this example, we named the layer “ClipBox”. Right click
that new layer in the layer pane in the bottom left and hit the “toggle editing” option. We are now
able to edit on that layer.
Click the “New Polygon” button in the 3rd-row bar from the top.
You should now be able to draw a polygon around your flight area. It is strongly recommended
to draw a polygon much bigger than your site, as you do not want to run out of data. The data,
when we are done, is also going to be very small, so it doesn't hurt to have more.
Left-click once for a vertex of your polygon and right-click to end the polygon. When done you
will get a pop-up asking you to give the polygon an id, go ahead and hit anything, we used 1.
You should now see your polygon in the viewer. Right-click the “ClipBox” layer in the layer pane
and hit the “save layer edits” option, then right click again and hit the “toggle editing” option.
Now we are ready to clip the data from USGS using this polygon we just created.
To do this we will need to go to the ”Raster” tab in the top bar of QGIS, then click the
“Extraction” option, and the “Clip Raster by Mask Layer… “. This should make the Clip Raster by
Mask Layer pop-up appear. In that pop-up, we will need to change the “Input Layer” to our DEM
from USGS for this Demo that is “grdn34w118_13” and the “Mask Layer” to our “ClipBox”
polygon layer.
Scroll to the bottom of the pop-up and find the “Clipped (mask)” option, we will need to change
this from a temporary file to a file of our choosing. Do this by clicking the three dots to the right
of the “Clipped Mask” option and select “Save to File” from the drop-down.
In the “Save File” pop-up, we will want to navigate to the folder we created earlier on our
Desktop called “DEM”, then we will need to name the file, for this example, we choose
“Clipped_DEM”. It is very good practice to stay away from using spaces or periods in your
naming conventions for folders and files. Doing so may prevent you from completing the next
step.
Once everything looks like the screenshot below, you can go ahead and click “Run”.
You should now see the DEM in the viewer. We are now done with QGIS.
Go ahead and open the other program we mentioned earlier called “OSGeo4W Shell” that was
in the same folder as QGIS. This should open a command-line type shell.
The first thing we will need to do in the shell is navigate to our folder on our desktop where we
created our clipped DEM above. Right-click the “Clipped_DEM.tif” we created and select the
“Properties” option. Copy the “Location” file path as we will need it in the OSGeo4 Shell.
In the OS4Geo4 Shell type in “CD C:\Users\sean\Desktop\DEM” without the quotes and with the
file path from the step before and not the one from this demo and hit enter. This should take you
to your folder on the Desktop with your Clipped_DEM.
Then we will need to type in “listgeo -tfw Clipped_DEM.tif” and hit enter. The part that says
Clipped_DEM.tif will need to be replaced with whatever you called the DEM two steps ago, for
this Demo, we called the exported TIF “Clipped_DEM.tif”. This should create the .tfw that we
need in addition to the TIF for the P4RTK. You will probably get a warning about an unknown
field and that is perfectly fine.
If at any step above you have spaces in the file path or file names, you can enclose them in
quotes and the shell will treat it as one object instead of two. For example, if I named my TIF
“Clip DEM.tif” for example, and the command fails I can just run it as: listgeo -tfw “Clip DEM.tif”
to get around the space issue.
Now you have the DEM (.tif) and the World file (.tfw) ready to be put on the SD card and loaded
onto the drone.
Within the “DJI” folder, create a “DSM” folder, and within that, create a folder for the TIF and
TFW file, name it whatever your project is named.
Now drag and drop your TIF and TFW into this project named subfolder.
Now remove the SD card from the computer and insert it into the lower right-hand compartment
on the DJI controller.
Power on the controller and tap the three lines in the upper left-hand corner of the screen.
Be sure “DSM File” is selected from the top drop-down, and select the DSM folder name you
created previously, and tap “import”. The import should only take a few seconds but may take a
bit longer, be patient until it gives you feedback.
If successful, you will see this popup. Click ok and back out to the home screen and tap “Plan.”
Once the screen has loaded, scroll down on the right until you see your desired DSM, tap it and
you should see an orange-hued polygon pop up over your area of interest, the same shape as
the DSM you created earlier. Now tap “Plan Task.”
Now a white dashed border should pop up around the perimeter of the DSM.
Next, you will plan your mission as you normally would in the P4RTK. Tap to create a flight path
and adjust your parameters as necessary. See: Creating Flight Paths - Phantom 4 RTK
The one new thing you’ll notice is a flight profile at the bottom of the screen. Each white dot is
the end of a flight line. Cross-reference this profile with the flight lines and terrain under the flight
lines, as well as the projected altitude (*** keep in mind the P4RTK only shows height in
meters). You’ll want to make sure the selected height you chose is consistently represented
above the terrain (represented by the colored bottom portion of the flight profile graph.)
When you are satisfied, click “Save.” This flight plan will now be saved in the general menu
(three lines in the upper left of the home screen) under the middle drop down “Plan” for use
later.
You have successfully used free USGS elevation data to make the Terrain Awareness feature
work for the Phantom 4 RTK.