An easy-to-use MATLAB library for working with terrain elevation from the USGS in 1/3 arc-second resolution. Supports automatic download and synthesization of multiple 1x1 degree cells, elevation data sampling, easy conversion from latitude/longitude to cartesian coordinates, and terrain visualization.
This library works in all of the mainland United States, Hawaii, and most of Alaska. It depends on the MATLAB Mapping Toolbox.
% Download the USGS 1/3 arc-second data covering northwestern Wyoming, from
% 42.5 to 45 latitude and from -111.05 to -108.6 longitude
region = fetchregion([42.5, 45], [-111.05, -108.6], 'display', true);
% Read the elevation data for Yellowstone National Park (the indicated
% latitude and longitude range), sampling at 1/20th of the maximum
% resolution (i.e., 6 arc-seconds).
yellowstoneElevData = region.readelevation([44.255813, 44.649888], [-110.861772, -110.183366], 'sampleFactor', 20, 'display', true);
% Graph the elevation data for Yellowstone, using latitude and longitude
% for the x and y coordinates
dispelev(yellowstoneElevData, 'mode', 'latlong');
% Read the elevation data for the Jackson Hole resort (the indicated
% latitude and longitude range), sampling all data points (1/3 arc-seconds)
jacksonElevData = region.readelevation([43.450467, 43.546597], [-110.837225, -110.732854], 'SampleFactor', 1, 'display', true);
% Graph the elevation data for Jackson Hole, using meters for the x and y
% coordinates and specifying roughly 50 grid lines
dispelev(jacksonElevData, 'mode', 'cartesian', 'gridLines', 50);
Samuel Pfrommer (2021). Terrain Elevation (https://github.com/spfrommer/terrain-elevation), GitHub. Retrieved .
Sorry for the late notice--I just ran an example and it seems to be working. Make sure you have the mapping toolbox installed, and feel free to share the code you used to get the error.
I was quite excited to see this! Thanks for posting.
Unfortunately, the links seem to have expired.. :(
URL_FORMAT1 = 'https://prd-tnm.s3.amazonaws.com/StagedProducts/Elevation/13/GridFloat/USGS_NED_13_n%dw%03d_GridFloat.zip';
URL_FORMAT2 = 'https://prd-tnm.s3.amazonaws.com/StagedProducts/Elevation/13/GridFloat/n%dw%03d.zip';
DATAFILE_FORMAT1 = '/usgs_ned_13_n%dw%03d_gridfloat.flt';
DATAFILE_FORMAT2 = '/floatn%dw%03d_13.flt';
Great function! Works well.
Be aware - Only US Data!
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!