Hi Mathieu,

I'm not sure why RStudio is crashing on you with that input, on my apple laptop 
with R 2.13.2 I get the following error when I run your sample code:

Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, "rgeos_intersection") : 
  TopologyException: no outgoing dirEdge found at 898287 6.27396e+06

Which is how things should be handled on a topology error. It seems like there 
is some geos issue with treating all the buildings as a single MULTIPOLYGON. 
geos can choke on some geometries for any number of reasons, but my guess is 
that two of the buildings overlap infinitesimally after the intersection 
operation.

My suggestion would be to use the byid option when calculating the intersection 
as this will find the intersection for each building separately and then wrap 
them back up together as a single SpatialPolygons, so for your purposes the end 
result should be the same.

The following code worked for me:

library(rgeos)

load("bati.cddtes.RData")
load("W.RData")

z = gIntersection(bati.cddtes, W, byid=TRUE)

plot(bati.cddtes)
plot(W,add=TRUE)
plot(z,add=TRUE,col='blue')

-Colin

On Oct 17, 2011, at 11:04 AM, Mathieu Rajerison wrote:

> I'm trying to calculate fragstats metrics, in particular fractal dimension 
> using spatstat package, raster package and rgeos.
> 
> Fractal dimension is here applied to buildings, so as to determine complexity 
> of shapes. I'm calculating it with a moving window (a circular disc shape).
> 
> There's no problem with the 27 first moving windows but my script causes 
> RStudio to crash when it's about to calculate the intersection of my 28th 
> disc and my buildings that intersect the latter.
> 
> So, I gave you two images of the couple disc + intersecting buildings in case 
> you'd see the problem, 
> and a zip containing disc.Rdata + bati.cddtes.Rdaya if yopu'd like to give it 
> a try 
> 
> The code:
> library(rgeos)
> 
> load("bati.cddtes.RData")
> load("W.RData")
> 
> gIntersection(bati.cddtes, W)
> 
> 
> Here are the images:
> http://hpics.li/b0a2086 -(zoomed on disc)
> http://hpics.li/7e6f780 - (zoomed on buildings)

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to