[GRASS-SVN] r61393 - grass/branches/develbranch_6/scripts/r.in.srtm

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 24 17:16:19 PDT 2014


Author: hamish
Date: 2014-07-24 17:16:19 -0700 (Thu, 24 Jul 2014)
New Revision: 61393

Modified:
   grass/branches/develbranch_6/scripts/r.in.srtm/description.html
   grass/branches/develbranch_6/scripts/r.in.srtm/r.in.srtm
Log:
add support for srtm v3, quoting, sed cleanup

Modified: grass/branches/develbranch_6/scripts/r.in.srtm/description.html
===================================================================
--- grass/branches/develbranch_6/scripts/r.in.srtm/description.html	2014-07-24 22:23:56 UTC (rev 61392)
+++ grass/branches/develbranch_6/scripts/r.in.srtm/description.html	2014-07-25 00:16:19 UTC (rev 61393)
@@ -3,9 +3,13 @@
 <em>r.in.srtm</em> imports SRTM hgt files into GRASS.
 
 SRTM data sets can be downloaded from NASA at this FTP site (Version 1 and the
-improved Version 2):<br>
-<a href="http://dds.cr.usgs.gov/srtm/">http://dds.cr.usgs.gov/srtm/</a>
+improved Version 2.1):<br>
+<a href="http://dds.cr.usgs.gov/srtm/">http://dds.cr.usgs.gov/srtm/</a><br>
+<p>
+Version 3, with holes filled, can be downloaded from:<br>
+<a href="http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL3.003/">http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL3.003/</a>
 
+
 <h2>NOTES</h2>
 
 SRTM tiles are of 1 degree by 1 degree size. The SRTM filename contains the
@@ -40,4 +44,5 @@
 Markus Neteler<br>
 Improved by W. Kyngesburye and H. Bowman
 
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>

Modified: grass/branches/develbranch_6/scripts/r.in.srtm/r.in.srtm
===================================================================
--- grass/branches/develbranch_6/scripts/r.in.srtm/r.in.srtm	2014-07-24 22:23:56 UTC (rev 61392)
+++ grass/branches/develbranch_6/scripts/r.in.srtm/r.in.srtm	2014-07-25 00:16:19 UTC (rev 61393)
@@ -3,7 +3,7 @@
 #import of SRTM hgt files into GRASS
 # written by Markus Neteler 11/2003 neteler AT itc it
 #
-# COPYRIGHT:	(C) 2004, 2006 by the GRASS Development Team
+# COPYRIGHT:	(C) 2004-2014 by the GRASS Development Team
 #
 #		This program is free software under the GNU General Public
 #		License (>=v2). Read the file COPYING that comes with GRASS
@@ -16,6 +16,7 @@
 # June 2005: added flag to read in US 1-arcsec tiles (H. Bowman)
 # April 2006: links updated from ftp://e0dps01u.ecs.nasa.gov/srtm/             
 #             to current links below
+# July 2014: Support for SRTMv3 (H. Bowman)
 #########################
 #Derived from:
 # ftp://e0srp01u.ecs.nasa.gov/srtm/version1/Documentation/Notes_for_ARCInfo_users.txt
@@ -111,9 +112,9 @@
 fi
 
 # use these from now on:
-FILE=`echo "$GIS_OPT_INPUT" | sed 's+.hgt++'| sed 's+.zip++'`
-TILE=`echo "$FILE" | sed 's+^.*/++'`
-FDIR=`echo "$FILE" | sed 's+[^/]*$++'`
+FILE=`echo "$GIS_OPT_INPUT" | sed -e 's+\.hgt++' -e 's+\.zip++'`
+TILE=`echo "$FILE" | sed -e 's+^.*/++' -e 's+\.SRTMGL[13]++'`
+FDIR=`echo "$FILE" | sed -e 's+[^/]*$++'`
 
 if [ -z "$GIS_OPT_OUTPUT" ] ; then
   TILEOUT="$TILE"
@@ -168,7 +169,7 @@
 cd "$TMPDIR"
 
 
-if [ $IS_ZIP -eq 1 ] ; then
+if [ "$IS_ZIP" -eq 1 ] ; then
     #unzip & rename data file:
     g.message  "Extracting '$FILE'..."
     unzip "$FILE.hgt.zip"
@@ -179,30 +180,30 @@
 fi
 
 g.message "Converting input file to BIL..."
-mv "$TILE.hgt" "${TMPDIR}/$TILE.bil"
+mv "$TILE.hgt" "$TMPDIR/$TILE.bil"
 
-LL_LATITUDE=`echo $TILE  | cut -b2-3`
-LL_LONGITUDE=`echo $TILE | cut -b5-7`
+LL_LATITUDE=`echo "$TILE" | cut -b2-3`
+LL_LONGITUDE=`echo "$TILE" | cut -b5-7`
 
 #are we on the southern hemisphere? If yes, make LATITUDE negative.
-NORTH=`echo $TILE  | sed 's+.hgt++g' | cut -b1`
+NORTH=`echo "$TILE" | sed -e 's+\.hgt++g' | cut -b1`
 if [ "$NORTH" = "S" ] ; then
-   LL_LATITUDE=`echo $LL_LATITUDE | awk '{printf "%.10f", $1 * -1 }'`
+   LL_LATITUDE=`echo "$LL_LATITUDE" | awk '{printf "%.10f", $1 * -1 }'`
 fi
 
 #are we west of Greenwich? If yes, make LONGITUDE negative.
-EAST=`echo $TILE  | sed 's+.hgt++g' | cut -b4`
+EAST=`echo "$TILE" | sed -e 's+\.hgt++g' | cut -b4`
 if [ "$EAST" = "W" ] ; then
-   LL_LONGITUDE=`echo $LL_LONGITUDE | awk '{printf "%.10f", $1 * -1 }'`
+   LL_LONGITUDE=`echo "$LL_LONGITUDE" | awk '{printf "%.10f", $1 * -1 }'`
 fi
 
 # Calculate Upper Left from Lower Left
-ULXMAP=`echo $LL_LONGITUDE | awk '{printf "%.1f", $1}'`
+ULXMAP=`echo "$LL_LONGITUDE" | awk '{printf "%.1f", $1}'`
 # SRTM90 tile size is 1 deg:
-ULYMAP=`echo $LL_LATITUDE  | awk '{printf "%.1f", $1 + 1.0}'`
+ULYMAP=`echo "$LL_LATITUDE" | awk '{printf "%.1f", $1 + 1.0}'`
 
 
-if [ $GIS_FLAG_1 -ne 1 ] ; then
+if [ "$GIS_FLAG_1" -ne 1 ] ; then
   echo "BYTEORDER M
 LAYOUT BIL
 NROWS 1201
@@ -243,7 +244,8 @@
 r.in.gdal in="$TILE.bil" out="$TILEOUT"
 EXITCODE=$?
 
-\rm -f "$TILE.bil" "$TILE.hdr" "$TILE.prj" "$TILE.hgt.zip"
+rm -f "$TILE".*
+
 cd ..
 rmdir "$TMPDIR"
 
@@ -257,8 +259,8 @@
 r.colors color=srtm map="$TILEOUT"
 #g.region rast=$TILEOUT
 
-# write cmd history:
-r.support $TILEOUT history="${CMDLINE}"
+# write cmd history
+r.support "$TILEOUT" history="$CMDLINE"
 
 g.message "Done: generated map $TILEOUT"
 g.message "(Note: Holes in the data can be closed with 'r.fillnulls' using splines)"



More information about the grass-commit mailing list