Dear list,
apologize for the unusual question.  I am new and I have some problems with
some of the terminology.
I had my codes running but only after trial and error rather than with a
full understanding of what is what and this does not entirely satisfy me.

I have a data frame (call it grid1) containing X, Y coordinates along with
other variables
Locations are spaced 500 m apart on on a grid. Here an example with random
data:

##-------------
X1 <- rep(seq(0,20000, by=500)
          , each=45)
Y1 <- rep(seq(0,20000, by=500)
          , 45)
grid1 <- data.frame(X1,Y1,
                    value=rep("val", length(X1)))
plot(grid1$X1,grid1$Y1, cex=0.1)
##--------------


I want to extract from grid 1 only those locations, and relative values,
that are spaced 2500 m apart, so basically those locations that overlap
with a second data frame (call it grid2). In other words those locations
where dots overlap with circles (cfr. the plot in the codes below)

##--------------
X2 <- rep(seq(0,20000, by=2500)
         , each=9)
Y2 <- rep(seq(0,20000, by=2500)
         , 9)
grid2 <- data.frame(X2,Y2)
points(grid2$X2,grid2$Y2)
##----------------


I believe this can be easily achieved with the over() function in {sp} :

##----------------
over(grid2,grid1)
##---------------

But I see that arguments of the form "data.frame" cannot be passed to
over() that instead accept arguments of the form SpatialPoints,
SpatialGridsDataFrame and so on.

I passed the arguments in the form SpatialPoints and SpatialPointsDataFrame
yet I do not fully grasp the difference with (say) SpatialGrid.


##-------------
over(SpatialPoints(coords=coordinates(grid2)),
       SpatialPointsDataFrame(coords=grid1[c("X1", "Y1")], data=grid1))
##-------------

I am reading:        http://cran.r-project.org/web/packages/sp/sp.pdf
but still I am struggling to fully understand.

Any comments on the terminology and the best approach to solve my problem
would be appreciated.
Hopefully this will be of any use for other list members.

Gabriele




-- 
Botswana Predator Conservation Trust
Gabriel Cozzi
Private Bag 13
Maun - Botswana
E-mail: gab.cozzi@gmail.com
Mobile: +26774259312


Institute of Environmental Sciences
Gabriel Cozzi
Zurich University
Winterthurerstr. 190
8057 Zurich - Switzerland
E-mail: gab.cozzi@uwinst.uzh.ch
Phone: ++4(0)446355204
Fax: ++41(0)16355711
http://www.uzh.ch/uwinst
http://african-carnivores.com

	[[alternative HTML version deleted]]

