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