2

I am in need of a few shapefiles with bad geometry for testing some Python code. How can I intentionally create bad geometry in a shapefile? Preferably I would be able to create three (point, line, polygon).

5
  • Geometry can be bad in many ways, can you narrow it down? Commented Mar 29, 2016 at 18:04
  • 1
    I write 'C' code to break geometry, or use dd to sew pieces of files together. You could certainly use Python for the same purpose, but non-conformant shapefiles often invoke undefined behavior rules, which make them exceedingly difficult to test (a valid undefined behavior could include production of a black hole that consumes your server).
    – Vince
    Commented Mar 29, 2016 at 18:32
  • 1
    @KirkKuykendall Things that would normally be fixed by ArcMAP's repair geometry tool, such as self intersections or unclosed rings.
    – Daniel W
    Commented Mar 29, 2016 at 19:04
  • See here for discussion postgis.net/docs/using_postgis_dbmanagement.html#OGC_Validity and look at the GDAL autotest suite for concrete examples with Python trac.osgeo.org/gdal/wiki/TestingNotes
    – mdsumner
    Commented Mar 30, 2016 at 5:21
  • I can upload a couple 3rd parties product, line and polygon. Let me know. Create bad point is easy, open table and click after last row
    – FelixIP
    Commented Mar 30, 2016 at 8:43

1 Answer 1

2

You could use QGIS to edit line and polygon shapefiles. Rightclick a shapelayer then "toggle editing". Use the "node tool" to drag lines across each other to cause intersecting(invalid) geometry. Intersecting line points are even highlighted with bright green 'X's.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.