[R-sig-Geo] package sp, extract values points-lines

marta azores martazores at gmail.com
Thu Nov 24 14:52:07 CET 2016


Hi everyone,

I need to join two datasets, one with survey boats and other with
sightings. There are different boats in the same area.
First I've created the tracks with the gps information, and give to each
track an ID number(column) .
Second, I would like to join by time and space the sightings with the track
of the boats.
I'm trying the"over" function of the package sp.

The first test was try to join only by space, but the function say there
aren't overlap. I don't know why, because the points of the sightings are
over the line.

Any idea?
Thanks in advance
Marta

#boat data
boat <- read.table("path/.csv", header=TRUE, sep=",", na.strings="NA",
dec=".", strip.white=TRUE)#
boatdf<-as.data.frame(boat)
#sighting data
sght <- read.table("path/.csv.csv", header=TRUE, sep=",", na.strings="NA",
dec=".", strip.white=TRUE)#

#Spatial points
#sightings
Sxy = cbind(sght$LONG,sght$LAT)
Spts = SpatialPoints(Sxy)
sghtdf<-as.data.frame(sght)
#boats
xy = cbind(boat$Long1,boat$Lat1)
pts = SpatialPoints(xy)

# dataframe
ptsdf = SpatialPointsDataFrame(pts, boatdf)#data frame barcos
Sptsdf = SpatialPointsDataFrame(Spts, sghtdf)#data frame species

#Line
line<-as(ptsdf, "SpatialLines")

#
#extract values
over(Sptsdf, line)# NA?

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list