[R-sig-Geo] rgeos distances
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Mon Nov 1 16:36:48 CET 2010
I tried rgeos to compute distances between a set of points and a
polygon, but don't get values I expected. Full output below; below my
signature is the clean script. Any ideas?
> library(sp)
> library(rgeos)
Loading required package: stringr
rgeos: (SVN revision (unknown))
GEOS runtime version: 3.2.2-CAPI-1.6.2
>
> data(meuse.riv)
> meuse.sr =
SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)),"meuse.riv")))
>
> data(meuse.grid)
> coordinates(meuse.grid) = c("x", "y")
> # gridded(meuse.grid) = TRUE
>
> crs = CRS(paste("+init=epsg:28992",
+
"+towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812"))
>
> proj4string(meuse.grid) = crs
> proj4string(meuse.sr) = crs
>
> ret = gDistance(meuse.sr, meuse.grid, byid=F, hausdorff=TRUE)
Warning message:
In RGEOSDistanceFunc(spgeom1, spgeom2, byid, "rgeos_hausdorffdistance") :
Polygons object missing comment attribute ignoring hole(s). See
function createSPComment.
> summary(ret)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0 0 0 0 0 0
> ret = gDistance(meuse.sr, meuse.grid, byid=T, hausdorff=FALSE)
Warning message:
In RGEOSDistanceFunc(spgeom1, spgeom2, byid, "rgeos_distance") :
Polygons object missing comment attribute ignoring hole(s). See
function createSPComment.
> summary(ret)
meuse.riv
Min. :1.798e+308
1st Qu.:1.798e+308
Median :1.798e+308
Mean :1.798e+308
3rd Qu.:1.798e+308
Max. :1.798e+308
>
>
--
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
library(sp)
library(rgeos)
data(meuse.riv)
meuse.riv = meuse.riv[nrow(meuse.riv):1,]
meuse.sr =
SpatialPolygons(list(Polygons(list(Polygon(meuse.riv)),"meuse.riv")))
data(meuse.grid)
coordinates(meuse.grid) = c("x", "y")
# gridded(meuse.grid) = TRUE
crs = CRS(paste("+init=epsg:28992",
"+towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812"))
proj4string(meuse.grid) = crs
proj4string(meuse.sr) = crs
ret = gDistance(meuse.sr, meuse.grid, byid=F, hausdorff=TRUE)
summary(ret)
ret = gDistance(meuse.sr, meuse.grid, byid=T, hausdorff=FALSE)
summary(ret)
More information about the R-sig-Geo
mailing list