[R] R version 3.3.2, Windows 10: How to identify the common coordinates in two different SpatialPixelDataFrame

Rathore, Saubhagya Singh saubhagya at gatech.edu
Mon Mar 27 16:07:30 CEST 2017

Hello Everyone,

I am resending this message as due to some reason, the message was not posted on the list before.

I have two SpatialPixelDataFrames (a and b) which have few common coordinates/locations. I need to identify these common coordinates and remove them from both the dataframes.

Though I have been able to identify and separate common coordinate points (an2 and bn2), but I feel my code is very inefficient. Is there is better way to do it. I have shared my code here.

Secondly, I am also not sure about how can I remove these locations from the original dataframes "a" and "b".

Thank You
#-----code starts---------------------

# separating the points with same coordinates

gridded(a) = ~x+y
gridded(b) = ~x+y

# comparing x coordinates
res <- outer(a at coords[,1], b at coords[,1], `==`)

# an and bn have common x coordinates
index.temp<-which(res,arr.ind = T)

#comparing y coordinates
res <- outer(an at coords[,2], bn at coords[,2], `==`)
index.temp<-which(res,arr.ind = T)

#an2 and bn2 have comon x and y coordinates

#--code ends-----------------------------------

Thank You

	[[alternative HTML version deleted]]

More information about the R-help mailing list