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

rolandh at uni-muenster.de rolandh at uni-muenster.de
Thu Nov 24 15:02:36 CET 2016


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 ...

Cheers,
Roland

marta azores schrieb am 2016-11-24:
> 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]]

> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list