[R-sig-Geo] "invalid" geometries in shape data

Michael Sumner mdsumner at gmail.com
Fri Feb 10 03:03:45 CET 2017


On Thu, Feb 9, 2017, 11:34 chris english <englishchristophera at gmail.com>
wrote:

> Michael,
>
> I'll forward to rgis/toposhop/issues some 'flat' triangles (i.e.
> co-linear) that come up in my neuro
> data. Even Roualt says that TRIANGLE will be in GDAL 2.2 release in May
> and has been
> wrestling with it since Nov/Dec last.
>
> PostGIS tests first three points of polygon for co-linearity but doesn't
> detail precision,
> presumably at level provided. stryk seems generally pragmatic in these
> things. Even was
> miffed in a Dec tweet about triangle having four points (.."and its called
> Simple Features),
> but coming where it does in the polygon hierarchy, it is going to be
> closed.
>

Thanks Chris, appreciate the pointers.

Simple features is a bit silly for sure, but it does have a strict logic
for path-based geometry and it fits the very fast special case
optimizations that are available to planar operations.

It's just a shame that GIS has no higher standard to at least aim for, but
there's a convergence on the horizon for many disparate projects that have
broken the mould. Most of them have to one way or another for real data,
note the dozens of track or GPS data packages on CRAN, they have no common
foundation but usually express much overlapping logic).

GIS logic with multiple levels of grouping are easy for database
techniques, and computer graphics array indexing and primitives can be
expressed as tables with no problems. I think R is better suited than many
platforms for designing a better standard but there's no consistent
discussion around this or even wide recognition that there is any problem.

If you know of discussions I'd appreciate any connections. I will follow up
what you've added here.

Fwiw, it seems rgeos::gBuffer(x, width = 0) will fix many problems (thanks
Barry). The machinery that decomposes a feature and rebuilds it again in
value form is something that should be a standalone tool. That's something
that I will pursue from this.

Cheers, Mike


> geophys::TriangleInfo tests for co-linearity using sign of determinant
> through the dt function,
> though determinant (proper) would likely be quicker for evaluating lots of
> them as it is direct call to
> .Internal.
>
> I am still trying to wrap my head around RTriangle. I think it must be
> sturdy for triangle(s), but in
> some sense its goal of mesh propagation upon/within a polygon system is
> seemingly time travel
> compared to my 'this thing is a triangle, aren't it?" None of the methods
> I've seen so far seem to test
> for 'no internal boundary', including CGAL. And none of this addresses
> 'automatic fixing tool' that
> you or Delft suggests.
>
> My data, from the wild, seems amenable to a jitter after a test by either
> atan2 or determinant to
> establish candidates for jittering. determinant seems like it would work
> best with sf approach to
> st_geometry(sfc) as they are lists and one can discern, following geophys'
> approach building out
> (adding 1s to a 3rd col of) a 2x4 triangle/polygon matrix to 3x4 and
> evaluating on first 3x3 square.
>
> I've said as much as I know to this point, triangles are coming.
>
> Chris
>
> On Wed, Feb 8, 2017 at 1:47 PM, Barry Rowlingson <
> b.rowlingson at lancaster.ac.uk> wrote:
>
> Searching GIS StackExchange for [r] and TopologyException might find you a
> few:
>
> http://gis.stackexchange.com/search?q=%5Br%5D+topologyexception
>
> [answered one of these just today:
>
> http://gis.stackexchange.com/questions/227569/r-error-fortifying-dataframe-from-shapefile
> ]
>
> Barry
>
> On Tue, Feb 7, 2017 at 9:46 PM, Michael Sumner <mdsumner at gmail.com> wrote:
> > Hi,
> >
> > I'm interested in exploring the details of kinds of errors and warnings
> > that are seen from the underlying geometry lib (GEOS) for spatial data in
> > R.
> >
> > I would like to also have a collection of  examples with actual data and
> > reproducible code.
> >
> > (The underlying theory and definitions and source code are all open and
> > available, I'm looking for examples).
> >
> > The kinds of errors I'm talking about come from the GEOS library under
> the
> > hood, and this is more or less the same in the sp/rgdal as well as the
> new
> > sf family.
> >
> > Here's one example, this data set is not valid because of at least one
> > "polygon self intersection", basically the ring winds back on itself:
> >
> > library(maptools)
> > data(wrld_simpl)
> > rgeos::gIsValid(wrld_simpl)
> > [1] FALSE
> > Warning message:
> > In RGEOSUnaryPredFunc(spgeom, byid, "rgeos_isvalid") :
> >   Ring Self-intersection at or near point -95.902496339999999
> > 66.946641920000005
> >
> > I'd appreciate if you could send me similar examples, preferably
> > reproducible with code but links to existing emails and online posts are
> > welcome too. Feel free to construct examples from scratch that reproduce
> a
> > particular warning/error.
> >
> > If you like, you can use the Github Issues mechanism here, or just email
> > them in reply.
> >
> > https://github.com/r-gris/toposhop/issues
> >
> > Cheers, Mike.
> >
> >
> > --
> > Dr. Michael Sumner
> > Software and Database Engineer
> > Australian Antarctic Division
> > 203 Channel Highway
> > Kingston Tasmania 7050 Australia
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> --
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list