I downloaded 30-arc-second SRTM (Shuttle Radar Topography Mission) .DEM tiles from USGS https://dds.cr.usgs.gov/srtm/version2_1/SRTM30/ and want to open them in r, ideally as rasters.
gdalinfo([file path and name].dem)
returns the message “’[file path and name].dem’ not recognized as a supported file format.” I don’t know much about gdal but the error message implies that a fairly current version is installed: “running command '"/Library/Frameworks/GDAL.framework/Versions/2.1/Programs/gdalinfo”…” Of course this means that gdal_translate fails too.
It also didn't work to open the .dem with plain
raster([file path and name])
How should I do this? I can’t imagine this is a unique question but I have found only questions based on the DEM being already in .tif or other standard raster format, or that involve using ArcGIS or other software than r.
I have not posted the large .dem file but if there is a good way I can provide a reproducible example pls let me know.
The .DEM files only contain the height data (as a simple integer matrix). You can import the matrix into R using readBin("filename.DEM", "integer", size = 2, signed = TRUE, n = NROWS * NCOLS, endian = "big")
. But if you want to import the file as a spatial raster, you also need to download the .hdr files from the same web folder location, because these contain the spatial reference. Once you have both files in the same directory, you can simply use
x = raster("filename.DEM")