[R-sig-Geo] Selecting polygons into buffer given center

Tom Gottfried tom.gottfried at tum.de
Wed Sep 7 14:35:48 CEST 2011


 From your initial question I suspect that what you want to do is

I <- gIntersects(b, comuniUTM, byID=TRUE)

Though this will probably rise the same error, which I suspect comes from the fact, that the 
polygons in comuniUTM are topologically not correct. You might want to clean them e.g. in GRASS. 
Others might correct me if there is an implementation for such a task in R.

Tom

Am 07.09.2011 13:59, schrieb luca candeloro:
> Thank you,
> I tried the following code:
>
> UTM32WGS84<- CRS("+proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +no_defs")
> comuniUTM=spTransform(comuni, UTM32WGS84) #where comuni is a
> SpatialPolygonDataFrame
> puntoUTM<- spTransform(punto, UTM32WGS84) #where punto is a
> SpatialPointDataFrame
>
> #I create the spatial polygon whit the buffer of 4 km around the point using function gbuffer from
> rgeos library (better than before)
> b=gBuffer(puntoUTM,width=4000,quadsegs=50)
>
> #Try to get intersection but an error occurs
> I=gIntersection(b,comuniUTM
>
> Errore in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, "rgeos_intersection") :
> TopologyException: found non-noded intersection between LINESTRING (759692 4.85308e+006, 759729
> 4.85308e+006) and LINESTRING (759729 4.85308e+006, 759692 4.85308e+006) at 759723 4.85308e+006
>
> Do you konw about this error?
> Bye,
> Luca.
>
>
>
> 2011/9/7 Tom Gottfried <tom.gottfried at tum.de <mailto:tom.gottfried at tum.de>>
>
>     Hi Luca,
>
>     have a look at the functions in package rgeos.
>
>     regards,
>     Tom
>
>     Am 07.09.2011 13:12, schrieb luca candeloro:
>
>         Hello,
>         I'd like to select, given a SpatialPolygonDataframe and a point (of known
>         coordinates), which are the polygons into the buffer (of a given distance)
>         around the point.
>         I tried the following code, but I don't know how to end it...
>
>         UTM32WGS84<- CRS("+proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +no_defs")
>         comuniUTM=spTransform(comuni, UTM32WGS84) #where comuni is a
>         SpatialPolygonDataFrame
>         puntoUTM<- spTransform(punto, UTM32WGS84) #where punto is a
>         SpatialPointDataFrame
>         #I create the spatial polygon whit the buffer of 4 km around the point using
>         function disc() and converting it into a SpatialPolygons...
>         discbuff<-disc(radius=4000, centre=puntoUTM at coords[,])
>         discpoly<-Polygon(rbind(cbind(__discbuff$bdry[[1]]$x,
>         y=discbuff$bdry[[1]]$y), c(discbuff$bdry[[1]]$x[1],
>         y=discbuff$bdry[[1]]$y[1])))
>         discpoly=list(discpoly)
>         discbuff<-Polygons(list(__discpoly[[1]]), ID=1)
>         discbuffSP=SpatialPolygons(__list(discbuff))
>         proj4string(discbuffSP)=__UTM32WGS84
>
>         #Does anyone konw how can I get the polygons in comuniUTM intersecting the
>         discbuffSP?
>
>         Thanks a lot,
>         Luca.
>
>         [[alternative HTML version deleted]]
>
>         _________________________________________________
>         R-sig-Geo mailing list
>         R-sig-Geo at r-project.org <mailto:R-sig-Geo at r-project.org>
>         https://stat.ethz.ch/mailman/__listinfo/r-sig-geo
>         <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>
>
>     --
>     Technische Universität München
>     Department für Pflanzenwissenschaften
>     Lehrstuhl für Grünlandlehre
>     Alte Akademie 12
>     85350 Freising / Germany
>     Phone: ++49 (0)8161 715324 <tel:%2B%2B49%20%280%298161%20715324>
>     Fax: ++49 (0)8161 713243 <tel:%2B%2B49%20%280%298161%20713243>
>     email: tom.gottfried at wzw.tum.de <mailto:tom.gottfried at wzw.tum.de>
>     http://www.wzw.tum.de/__gruenland <http://www.wzw.tum.de/gruenland>
>
>     _________________________________________________
>     R-sig-Geo mailing list
>     R-sig-Geo at r-project.org <mailto:R-sig-Geo at r-project.org>
>     https://stat.ethz.ch/mailman/__listinfo/r-sig-geo <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>
>

-- 
Technische Universität München
Department für Pflanzenwissenschaften
Lehrstuhl für Grünlandlehre
Alte Akademie 12
85350 Freising / Germany
Phone: ++49 (0)8161 715324
Fax:   ++49 (0)8161 713243
email: tom.gottfried at wzw.tum.de
http://www.wzw.tum.de/gruenland



More information about the R-sig-Geo mailing list