[R-sig-Geo] gUnion error -> TopologyException: side location conflict at...

Michael Sumner mdsumner at gmail.com
Tue Oct 28 22:43:56 CET 2014


I've found you can get around this error from some rgeos functions
(like gIntersection) by using the byid = TRUE argument, and in the
extreme you can iterate over one or both sets individually and collate
the results. I haven't been able to construct a clear example to
isolate the cause of the problem.

Since it's a union perhaps you can gUnaryUnion each object together
first. But is that the goal? One big union object, or a per-ID union
matching objects from the two sets? (I think I understand this, but
again I'd like to build a set of examples that make it clear).

Cheers, Mike.

On Wed, Oct 29, 2014 at 1:12 AM, Marc Marí Dell'Olmo
<marceivissa at gmail.com> wrote:
> Dear all,
>
> I would like to join the polygons of two maps (with
> SpatialPolygonsDataFrame format). I was trying to use gUnion funcition
> (rgeos library) but I obtained the following error:
>
>> setwd("R:/CARTOGRAFIA/Barcelona")
>>
>> BCN.SC<-readShapeSpatial("barcelona_SC2001.shp")
>> proj4string(BCN.SC) <- CRS("+proj=merc +datum=WGS84 +units=m")
>> BCN.SC<- spTransform(BCN.SC, CRS("+init=epsg:23031")) #ED50
>> BCN.CP<-readShapeSpatial("Dist_postals_BCN.shp") #ED50
>> proj4string(BCN.CP) <- CRS("+init=epsg:23031")
>>
>> gIsValid(BCN.CP)
> [1] TRUE
>> gIsValid(BCN.SC)
> [1] TRUE
>>
>>
>> aux <- gUnion(BCN.SC,BCN.CP)
> Error in RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, drop_lower_td,
> "rgeos_union") :
>   TopologyException: side location conflict at 425106.60792063997
> 4583876.4374835696
>
> I can't understand what's happening, glsValid is true for both shp
> files. Moreover, I've made a zoom to this point and I can see anything
> wrong.
>
> Thank you for your help,
>
> Marc
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list