[GRASS-user] test raster or vector

Michaël Rabotin michaelrabotin at gmail.com
Thu Oct 26 10:22:56 EDT 2006


Thanks a lot for your responses
In the same way, is it a method to know for a vector map if it is a point, a
line or a polygon vector ?
because in a script I've to do an overlay but this command doesn't work for
point vector (so I've to use v.select) but before to use one of these
commands I've to know the type of geometry of my vector

Cheers

Mick

2006/10/26, Hamish <hamish_nospam at yahoo.com>:
>
> Michaël Rabotin wrote:
> > a basic question for a shell script in GRASS 6.0.1
> > In a part of my script, I ask the user to give the name of a map (a
> > vector or a raster)
> > and I want to test if the user give a raster or a vector.
> > Do you know how I can proceed to do this test ?
>
>
> first port of call: see the g.parser help page.
>   http://grass.ibiblio.org/grass63/manuals/html63_user/g.parser.html
>
>
> you might want to try
>   http://grass.ibiblio.org/grass63/manuals/html63_user/g.findfile.html
>   http://grass.ibiblio.org/grass63/manuals/html63_user/g.filename.html
>
>
> beware the case where there is a raster and a vector of the same name!
> (e.g. spearfish dataset)
>
> MAPNAME=roads
>
> #test for raster
> g.findfile element=cell file=$MAPNAME
>
> echo $?
> 0
>
>
> g.findfile element=cell file=${MAPNAME}2
>
> echo $?
> 1
>
> #find vector map
> g.findfile element=vector file=${MAPNAME}
>
>
>
> # example
> g.findfile element=cell file=${MAPNAME} > /dev/null
> if [ $? -eq 0 ] ; then
>   echo "raster [$MAPNAME] exists"
> fi
>
> g.findfile element=vector file=${MAPNAME} > /dev/null
> if [ $? -eq 0 ] ; then
>   echo "vector [$MAPNAME] exists"
> fi
>
>
> Hamish
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20061026/76168ae5/attachment.html


More information about the grass-user mailing list