masking a site list?

Jianping Xu jianp at ocean.rutgers.edu
Sun Mar 27 12:04:56 EST 1994


I have used a raster map to mask sites. 

Since it might be of general interest, I just put neccesory steps together
into a shell script today. It picks up sites falling in your raster MASK.
If the MASK doesn't exist, it simply copys your original sites into a new
sites file. 

***
Jianping Xu					 
Center for Remote Sensing and Spatial Analysis	 Email: jianp at ocean.rutgers.edu
Rutgers University			 	 Phone: (908) 932-9631
New Brunswick, NJ 08903-0231			 Fax:   (908) 932-8746

--------- cut here
#!/bin/sh
#############################################
# s.mask.sh
#
# Selects sites falling into a raster MASK
#
# Usage: s.mask.sh sites=name newsites=name
#
# Author: Jianping Xu, Rutgers University
# 3/27/94
##############################################

### help message
if [ $# -eq 0 ]
then
    echo
    echo "Usage: $0 sites=name newsites=name"
    exit 1
fi

### parsing command line
for i do
    case $i in
        sites=*)
            SITES=`echo $i | sed 's/sites=//'` ;;
        s=*)
            SITES=`echo $i | sed 's/s=//'` ;;
        newsites=*)
            NEW=`echo $i | sed 's/newsites=//'`  ;;
        n=*)
            NEW=`echo $i | sed 's/n=//'` ;;
        *)
            echo
            echo "Error: [$i] not recognized"
            echo "Usage: $0 sites=name newsites=name"
            exit 1 ;;
    esac
done

### processing
if [ -s $LOCATION/cell/MASK ]
then                                                    # use the raster MASK
    s.out.ascii -d sites=$SITES |                       # get x,y... for r.what\    r.what MASK |                                       # use the MASK         \    awk -F\| '$4 != 0 {printf "%s|%s|%s\n", $1, $2, $3}'                       \    > $LOCATION/site_lists/$NEW
else                                                    # just copy it
    echo "Warning: MASK does not exist, so ..."
    g.copy sites=$SITES,$NEW
fi



More information about the grass-user mailing list