[Rspatial-devel] SpatialLinesDataFrame/match.ID-bug

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon Jul 25 18:47:27 CEST 2011


I fixed this and committed to svn; it seems the same bug was there for
Points and Polygons as well. The line:

        row.names(data) = data[match.ID[1]]

did not what we hoped it did, as data[match.ID[1]] returns a data.frame
and not sth that can be coerced to a character vector. I changed this
for Lines, Points and Polygons into:

        row.names(data) = data[, match.ID[1]]

which does set the row.names properly.

Thanks for the clear report,


On 07/25/2011 05:39 PM, Thomas Schlesinger wrote:
> Hey.
> 
> My name is thomas Schlesinger and I found a bug in the match.ID paramater in
> sp:::SpatialLinesDataFrame. I'm writing the problem down:
> 
> bodSouth<-data.frame(lat=c(8.94,9.49,9.72), lon=c(47.73,47.48,47.50))
> bodNorth<-data.frame(lat=c(9.05,9.48,9.75), lon=c(47.8,47.65,47.51))
> bodSouthLine<-Line(bodSouth)
> bodNorthLine<-Line(bodNorth)
> bodLines<-Lines(list(bodSouthLine,bodNorthLine), ID="Bodensee")
> crs<- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
> SPBoden<-SpatialLines(list(bodLines), proj4string=crs)
> bodenData<-data.frame(name="Bodensee", deep=254, height=395)
> SPDFboden<-SpatialLinesDataFrame(SPBoden, bodenData, match.ID="name")
> It should match the ID "Bodensee" with the Lines-ID "Bodensee". but it
> doesn't.
> 
> I think the problem is solved if you change the 2nd line in the
> SpatialLinesDataFrame-function from
> row.names(data) = data[match.ID[1]]    (this is class data.frame)
> to
> row.names(data) = data[match.ID[1]][,1]   (this is class factor)
> 
> I hope this solves the problem. Please let me know, if it worked.
> 
> greetings :)
> Thomas
> 

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de


More information about the Rspatial-devel mailing list