On Thu, 24 Nov 2016, rolandh at uni-muenster.de wrote:
Hi Marta,
by ?sp::over you will see that SpatialLines are not supported.
Moreover it says:
"over methods that involve SpatialLines objects, or pairs of
SpatialPolygons require package rgeos, and use gIntersects."
So, try gIntersects ...
Right, and note that the precision model will bite painfully (the points
may appear to be on the lines, but given the precision model may not
actually intersect in the default representation (think one thousandth of a
millimetre). You may need to buffer either points or lines to get the
intersections you expect.
Roger
Cheers,
Roland
marta azores schrieb am 2016-11-24:
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.
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)#
#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)
ptsdf = SpatialPointsDataFrame(pts, boatdf)#data frame barcos
Sptsdf = SpatialPointsDataFrame(Spts, sghtdf)#data frame species
line<-as(ptsdf, "SpatialLines")
#extract values
over(Sptsdf, line)# NA?
[[alternative HTML version deleted]]