[GRASS-SVN] r33744 - grass-addons/vector/v.what.rast.buffer
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Oct 7 22:28:40 EDT 2008
Author: hamish
Date: 2008-10-07 22:28:40 -0400 (Tue, 07 Oct 2008)
New Revision: 33744
Modified:
grass-addons/vector/v.what.rast.buffer/v.what.rast.buffer
Log:
mo' better subregion calc
Modified: grass-addons/vector/v.what.rast.buffer/v.what.rast.buffer
===================================================================
--- grass-addons/vector/v.what.rast.buffer/v.what.rast.buffer 2008-10-08 00:05:36 UTC (rev 33743)
+++ grass-addons/vector/v.what.rast.buffer/v.what.rast.buffer 2008-10-08 02:28:40 UTC (rev 33744)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
############################################################################
#
# MODULE: v.what.rast.buffer
@@ -152,15 +152,7 @@
unset IFS
for POS in `v.out.ascii "$SITES_FILE"` ; do
# clear old values
- unset EASTING
- unset NORTHING
- unset ID
- unset val
- unset max
- unset min
- unset n
- unset mean
- unset stddev
+ unset EASTING NORTHING ID val max min n mean stddev
EASTING=`echo "$POS" | cut -f1 -d"|"`
NORTHING=`echo "$POS" | cut -f2 -d"|"`
@@ -173,29 +165,14 @@
# create subregion bounds centered on mark so we quickly process
# only the local area.
- if [ 0 -eq 1 ] ; then
- int_EASTING=`echo $EASTING | cut -f1 -d.`
- int_NORTHING=`echo $NORTHING | cut -f1 -d.`
- # change this to measure from center of cell the point lies in, or ...?
- # the following heavily relies on integer truncation.
- R_NORTH=`echo $(((($int_NORTHING / $RES) * $RES) + ((($BUFFER/$RES)+2) * $RES) ))`
- R_SOUTH=`echo $(((($int_NORTHING / $RES) * $RES) - ((($BUFFER/$RES)+2) * $RES) ))`
- R_EAST=`echo $(((($int_EASTING / $RES) * $RES) + ((($BUFFER/$RES)+2) * $RES) ))`
- R_WEST=`echo $(((($int_EASTING / $RES) * $RES) - ((($BUFFER/$RES)+2) * $RES) ))`
+ R_NORTH=`echo "$NORTHING $BUFFER $RES" | awk '{printf("%.8f", $1 + $2 + $3)}'`
+ R_SOUTH=`echo "$NORTHING $BUFFER $RES" | awk '{printf("%.8f", $1 - $2 - $3)}'`
+ R_EAST=`echo "$EASTING $BUFFER $RES" | awk '{printf("%.8f", $1 + $2 + $3)}'`
+ R_WEST=`echo "$EASTING $BUFFER $RES" | awk '{printf("%.8f", $1 - $2 - $3)}'`
- # zoom in on local region (for speed)
- g.region n=$R_NORTH s=$R_SOUTH e=$R_EAST w=$R_WEST res=$RES # -p
- else
- # alternate method: rely on g.region -a expansion
- R_NORTH=`echo $(($NORTHING + $BUFFER + $RES))`
- R_SOUTH=`echo $(($NORTHING - $BUFFER - $RES))`
- R_EAST=`echo $(($EASTING + $BUFFER + $RES))`
- R_WEST=`echo $(($EASTING - $BUFFER - $RES))`
+ # zoom in on local region (for speed)
+ g.region n=$R_NORTH s=$R_SOUTH e=$R_EAST w=$R_WEST res=$RES -a # -p
- # zoom in on local region (for speed)
- g.region n=$R_NORTH s=$R_SOUTH e=$R_EAST w=$R_WEST res=$RES -a # -p
- fi
-
# get stats about surrounding area, ${100}m radius
g.message -v " Building Buffer ..."
r.circle -b output=MASK coord="$EASTING,$NORTHING" min=0 max="$BUFFER" --quiet
More information about the grass-commit
mailing list