[GRASS-stats] Re: Problem with v.distance in spgrass6 package in R

toke tepp at life.ku.dk
Wed Nov 2 12:05:19 EDT 2011


Hi Roger and everybody else 

I finally found time to translate the problem into spearfish data. 

To recapitulate I would like to use the v.distance command to transfer
information from polygons to point data.
 
The problem is that the v.distance command do not update the column
specified to receive the calculation done by the v.distance command.  

Here is my script     

grass

g.gisenv
g.mapset mapset=user1

g.copy vect='fields at PERMANENT',fields1 # adding  polygon to mapset 

g.copy vect='archsites at PERMANENT',archsites1 # adding points to mapset 

v.db.addcol map=archsites1 columns="fields double precision"  # adding
column to points data 

v.distance from=archsites1 to=fields1 from_type=point
to_type=point,line,area dmax=1 upload=to_attr column=fields to_column=cat #
adding cat information from polygon to point data  

### v.distance works in GRASS  ### 

### trying to do the same thing in R ###

v.db.dropcol archsites1 column=fields ## removing column 

v.db.addcol map=archsites1 columns="fields double precision"  ## adding a
clean column  


R # starting R within grass 

library(spgrass6) # calling library 

gmeta6()

fields1<-readVECT6("fields1") # reading polygon into R  

archsites1<-readVECT6("archsites1") # reading points into R 

archsites1 # looking at data 

# Trying to do the same v.distance calculation in R. 
### The specified column is not updated ###

execGRASS("v.distance", from="archsites1", 
to="fields1", from_type="point", to_type="point,line,area",
dmax=as.integer(1),
upload="to_attr", column="fields", to_column="cat") 

 
### However if the flags “p” is add to the v.distance calculation it is
possible to see that v.distance 
### actually do the calculations. 
   
execGRASS("v.distance", flags="p", from="archsites1", 
to="fields1", from_type="point", to_type="point,line,area",
dmax=as.integer(1),
upload="to_attr", column="fields", to_column="cat")

### script finished ###

There seems to be a bug in spgrass6. 

 Cheers Toke 


--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Problem-with-v-distance-in-spgrass6-package-in-R-tp6939286p6955833.html
Sent from the Grass - Stats mailing list archive at Nabble.com.


More information about the grass-stats mailing list