/SRTM_to_STL

Converts NASA SRTM data into STL for 3D printing

Primary LanguagePythonMIT LicenseMIT

SRTM_to_CSV.py converts a NASA SRTM3 (3 arcsec) hgt file into csv format
The first line of the csv file contains the width, height and maximum_height
Each line after that is in the format east,north,height

UK data is converted to OSGB coordinates using WGS84toOSGB36
Data for the rest of the World is converted to UTM

The csv 'tiles' can then be:
joined together with CSV_Join.py
trimmed with CSV_Trim.py
healed with CSV_Heal.py (interpolates any missing data points)
converted to stl format for 3D printing with CSV_to_STL.py
and then displayed in 3D with 3D_CSV.py or 3D_STL.py (optional)

To create a trimmed stl file of the UK Lake District:
Download N54W004.hgt and N54W003.hgt
Put SRTM_to_CSV.py, CSV_Join.py, CSV_Trim.py, CSV_to_STL.py in the same directory
From the command line:
python SRTM_to_CSV.py N54W004.hgt y
python SRTM_to_CSV.py N54W003.hgt y
python CSV_Join.py N54W004.csv N54W003.csv
python CSV_Trim.py N54W004_join.csv 298000 363000 477000 542000
python CSV_Heal.py N54W004_join_trim.csv
python CSV_to_STL.py N54W004_join_trim_heal.csv 5.0 130.0 0.5 1.0

slic3r or MeshLab will display the STL files, but if you want to view one
using Python and MatPlotLib you can:
python 3D_CSV.py N54W004_join_trim_heal.csv 5.0 y
python 3D_STL.py N54W004_join_trim_heal.stl

Download the SRTM3 (3 arc-second) hgt files from:
http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/
The continent map is available at:
http://dds.cr.usgs.gov/srtm/version2_1/Documentation/Continent_def.gif

SRTMGL1 (1 arc-second) data can be downloaded from:
http://earthexplorer.usgs.gov/
(select the data set called
"NASA LPDAAC Collections \ NASA SRTM (SRTM 3) Collections \ NASA SRTM3 SRTMGL1")
and then converted to 3 arc-second using SRTM_resample:
python SRTM_resample.py N54W004.hgt
This is advantageous as the 1 arc-second data has been cleaned up but
avoids you having nine times as much data to process. Check out SRTM_to_STL_1
if you want to work with the 1 arc-second data at full resolution

The hgt filename refers to the lower left pixel or sample in the data
Sample spacing is 3 arc-seconds for SRTM3 data
Data is two byte signed integers (big endian)
First row in the file is the ***northernmost*** one

utm has been gratefully plagiarised from https://pypi.python.org/pypi/utm
and then modified to allow the UTM zone to be forced. This is essential if
the hgt data crosses or ends on a UTM zone boundary. See http://www.dmap.co.uk/utmworld.htm

WGS84toOSGB36 is gratefully plagiarised from:
http://hannahfry.co.uk/2012/02/01/converting-latitude-and-longitude-to-british-national-grid/

If you have enjoyed this code, please make a small donation to Keswick Mountain Rescue Team:
http://www.keswickmrt.org.uk/support_us.htm
http://www.keswickmrt.org.uk/