[GRASS-SVN] r38449 - in grass-addons/general: .
grass_create_location
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jul 17 16:55:59 EDT 2009
Author: neteler
Date: 2009-07-17 16:55:59 -0400 (Fri, 17 Jul 2009)
New Revision: 38449
Added:
grass-addons/general/grass_create_location/
grass-addons/general/grass_create_location/README.txt
grass-addons/general/grass_create_location/grass_create_location.sh
Log:
Script to generate GRASS location from outside GRASS from GIS file (e.g. geoTIFF or SHAPE), wktfile or EPSG code (todo: rewrite as Python)
Added: grass-addons/general/grass_create_location/README.txt
===================================================================
--- grass-addons/general/grass_create_location/README.txt (rev 0)
+++ grass-addons/general/grass_create_location/README.txt 2009-07-17 20:55:59 UTC (rev 38449)
@@ -0,0 +1,4 @@
+Script to generate GRASS location from outside GRASS
+from GIS file (e.g. geoTIFF or SHAPE), wktfile or EPSG code.
+
+TODO: rewrite as Python script
Property changes on: grass-addons/general/grass_create_location/README.txt
___________________________________________________________________
Added: svn:eol-style
+ native
Added: grass-addons/general/grass_create_location/grass_create_location.sh
===================================================================
--- grass-addons/general/grass_create_location/grass_create_location.sh (rev 0)
+++ grass-addons/general/grass_create_location/grass_create_location.sh 2009-07-17 20:55:59 UTC (rev 38449)
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+############################################################################
+#
+# MODULE: grass_create_location.sh
+# AUTHOR(S): Markus Neteler
+# PURPOSE: Calculates univariate statistics from a GRASS raster map
+# COPYRIGHT: (C) 2009 by the GRASS Development Team, Markus Neteler
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+# find GRASS installation
+if [ ! -x "`which grass64`" ] ; then
+ if [ ! -x "`which grass65`" ] ; then
+ echo "GRASS GIS installation is required, please install it first"
+ exit 1
+ else
+ GRASSSTART=`which grass65`
+ fi
+else
+ GRASSSTART=`which grass64`
+fi
+GRASSBINS=`grep "^GISBASE=" ${GRASSSTART} | cut -d'=' -f2 | sed 's+"++g'`
+echo "Using GRASS installation in <$GRASSBINS>"
+
+if test "$GISBASE" != ""; then
+ echo "You must run this script outside of a GRASS GIS session." >&2
+ exit 1
+fi
+
+if [ $# -ne 3 ] ; then
+ echo "Usage: $0 type file|epsgcode locationname"
+ echo ""
+ echo "type: gisfile,wktfile,epsgcode"
+ echo ""
+ echo "Example:"
+ echo " $0 epsgcode 4326 latlong"
+ exit 1
+fi
+
+TYPE=$1
+INPUT=$2
+LOCATION=$3
+
+# SET ONCE ONLY: path to GRASS binaries and libraries:
+export GISBASE=$GRASSBINS
+export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts
+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GISBASE/lib
+# ACTUAL SESSION: use process ID (PID) as lock file number:
+export GIS_LOCK=$$
+# path to GRASS settings file
+export GISRC=$HOME/.grassrc6
+
+# check if raster or vector
+if [ "$TYPE" = "gisfile" ] ; then
+ gdalinfo ${INPUT} 2>/dev/null
+ if [ $? -ne 0 ] ; then
+ ogrinfo ${INPUT} 2>/dev/null
+ if [ $? -ne 0 ] ; then
+ echo "ERROR: Cannot open data source (not GDAL/OGR supported file)"
+ exit 1
+ fi
+ fi
+else
+ echo ""
+fi
+
+# the real job
+if [ "$TYPE" = "gisfile" ] ; then
+ g.proj -c georef=$INPUT location=$LOCATION
+ if [ $? -ne 0 ] ; then
+ echo "ERROR: could not create GRASS location"
+ fi
+else
+ if [ "$TYPE" = "wktfile" ] ; then
+ g.proj -c wkt=$INPUT location=$LOCATION
+ else
+ if [ "$TYPE" = "epsgcode" ] ; then
+ g.proj -c epsg=$INPUT location=$LOCATION
+ else
+ echo "ERROR: No idea what you specified as 'type'"
+ exit 1
+ fi
+ fi
+fi
+
+exit 0
Property changes on: grass-addons/general/grass_create_location/grass_create_location.sh
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:eol-style
+ native
More information about the grass-commit
mailing list