How to Create an invalid point and polygon geometry

499
1
11-06-2017 07:21 AM
ApurvDanke
Occasional Contributor

Hi,

I am testing ArcGIS Data Reviewer 10.4.1 and I want to test the invalid geometry check against point and polygon features, which I also want to create newly in a geodatabase version. I am using Oracle 12g for the geodatabase. Also installed Data Reviewer 10.4.1 patch 6.

I was able to reproduce an invalid polyline geometry which self intersects, i.e. the same feature cuts itself. However for point and polygon I'm not able create a geometry which is invalid to test against. ArcMap doesn't allow me to create any points or polygons which have invalid geometry. I think this check would be most useful for data which has been migrated from different sources, but still to test it I need to create some data in the geodatabase which is invalid. 

I thought of modifying the X and Y coordinates in the SDO_Geometry field (SHAPE) for that particular feature in the A table (as I created the feature in a version); or even make the value for this field as null. However I think doing something like this from backend in SQL might corrupt the feature class. Is there any safe way to create test data for invalid geometry check for points and polygons?

Regards,

Apurv

0 Kudos
1 Reply
XanderBakker
Esri Esteemed Contributor

Maybe you can load the featureclasses (shapefiles) in the ZIP attached.

I used this code to create them:

def main():
    import arcpy

    fc_pnt = r'C:\GeoNet\InvalidGeom\invalid_points.shp'
    fc_pol = r'C:\GeoNet\InvalidGeom\invalid_polygon.shp'

    sr = arcpy.SpatialReference(4326) # WGS 1984

    # create invalid points
    features = []
    pntg = arcpy.PointGeometry(arcpy.Point(None, None), sr)
    features.append(pntg)
    pntg = arcpy.PointGeometry(arcpy.Point(500, 500), sr)
    features.append(pntg)
    arcpy.CopyFeatures_management(features, fc_pnt)

    # create invalid polygon
    features = []
    pnts = [(-1, -1), (1, 1), (-1, 1), (1, -1), (-1, -1)]
    polygon = arcpy.Polygon(arcpy.Array([arcpy.Point(*pnt) for pnt in pnts]), sr)
    arcpy.CopyFeatures_management([polygon], fc_pol)

if __name__ == '__main__':
    main()

I would suggest to not load these features into any exiting featureclass. It is possible that during the loading an error occurs due to the invalid geometry.