Hi R users

I am trying to create a spatial join between two datasets. 

The first data set is large and contains descriptive data including x
and y co-ordinates. 

The second dataset is small and has been selected spatially. The only
data contained within the second dataset is the x and y coordinates only
i.e. no descriptive data.

The aim of a join made between the two datasets is to select those
points (and hence all the descriptive data) from dataset one that has
the same x and y co-ordinates as dataset two.

x1<-c(1824615,1823650,1821910)
y1<-c(5980732,5983220,5990931)
descript<-c("cat", "dog", "horse")
dat1<-data.frame(x1,y1,descript)

x2<-c(1824615,1823650)
y2<-c(5980732,5983220)
dat2<-data.frame(x2,y2)

dat1
dat2

The aim of the join is to produce:

       x1      y1 descript
1 1824615 5980732      cat
2 1823650 5983220      dog

And therefore limit the data in dataset 1 to that which has the same x
and y co-ordinates as dataset 2. 

Any suggestions?

Regards

Andy


Andrew McFadden MVS BVSc
Incursion Investigator
Investigation & Diagnostic Centres - Wallaceville Biosecurity New 
Zealand Ministry of Agriculture and Forestry

Phone 04 894 5600 Fax 04 894 4973 Mobile 029 894 5611 Postal address: 
Investigation and Diagnostic Centre- Wallaceville Box 40742 Ward St 
Upper Hutt





########################################################################
This email message and any attachment(s) is intended solely for the
addressee(s) named above. The information it contains is confidential
and may be legally privileged.  Unauthorised use of the message, or the
information it contains, may be unlawful. If you have received this
message by mistake please call the sender immediately on 64 4 8940100
or notify us by return email and erase the original message and
attachments. Thank you.

The Ministry of Agriculture and Forestry accepts no responsibility for
changes made to this email or to any attachments after transmission from
the office.
########################################################################

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to