[R-sig-Geo] R help
vikram ranga
babuawara at gmail.com
Tue Jul 2 13:16:45 CEST 2013
Hi Kevin,
Thank you very much for your email and time.
I appreciate it greatly,
I worked with gDifference from rgeos, also suggested by Alex. It works
fine but it gives you SpatialPolygons instead of
SpatialPolygonsDataFrame.
In addition to that the row.names are lost which add to complexity in
matching and attaching the original data.
I figured out another way:- as my goal was to get information from
different rings at different distances.
therefore, I counted the number of points in one ring and substracted
the number from the lower buffer--gave me exclusive numbers for a
ring.
The column I got, was then used to do some arithmetics and results
came out fine. this is bit simpler (but took me longer to figure this
out).
Cheers,
Vikram.
On Tue, Jul 2, 2013 at 3:53 PM, Kevin Cazelles <kevin.cazelles at gmail.com> wrote:
> Hi Vikram,
>
>
> I am not sure this will help, but if the main issue is the overlap, try to
> use "gDiff".
> Here a complete example (I use locator(), to generate points, you just have
> to click on the plot !) :
>
> #------------------------------
> library(rgeos)
> #------------------------------
> plot(c(-10,10),c(-10,10), col=0, main="Points", xlab="", ylab="Latitude
> (°)")
> nbp <- 3
> coordpt <- locator(nbp)
> datapt <- runif(nbp, 1,4)
> points(coordpt, col=1, pch=20)
> #------------------------------
> ptsp <- SpatialPoints(cbind(coordpt$x, coordpt$y),
> proj4string=CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84
> +towgs84=0,0,0"))
> #------------------------------
>
> Diff1 <- gDifference(gBuffer(ptsp, width=2), gBuffer(ptsp, width=1.7))
> Diff2 <- gDifference(gBuffer(ptsp, width=1.5), gBuffer(ptsp, width=1.2))
> Diff3 <- gDifference(gBuffer(ptsp, width=1), gBuffer(ptsp, width=0.5))
>
> plot(Diff1, add=T, col=3)
> plot(Diff2, add=T, col=7)
> plot(Diff3, add=T, col=2)
>
>
> Have a nice day !
>
>
>
> =====================================
> Kevin Cazelles
> kevin.cazelles at gmail.com
> Pdh Student
> Institut des Sciences de Montpellier (ISEM)
> Université du Quebec à Rimouski (UQAR)
>
>
> "On n'est jamais trop vieux pour grandir."
>
> € €
> €€ €€
> €€ €€
> €€€ ________ €€€
> €€€ $$$ $$$ €€€
> €€€ ___ ___ €€€
> < ¥ €€€ _____ €€€ ¥ >
> < ¥___€€€ €€€___ ¥ >
> < ¥ ==== €€ €€ ==== ¥ >
> < ¥ / \ €€ €€ / \ ¥ >
> < ¥ | @ | €€ /\ €€ | @ | ¥ >
> < ¥ \ __ / €€ / _\ €€ \ __ / ¥ >
> < ¥ €€ \ / €€ ¥ >
> < ¥¥¥¥¥ __ \/ __ ¥¥¥¥¥ >
> $$$ +++ +++ $$$
> $$_____________$$
>
>
>
>
>
>
>
>
>
>
More information about the R-sig-Geo
mailing list