3

I have data in PostgreSQL with PostGIS that seems fine. I am trying to 'copy' that in to ESRI ArcGIS. I have 4 test rows, 3 import fine. I've also modified a jsfiddle that I found and now has the problem polygon at http://jsfiddle.net/bryanm/nev4hgvo/

fieldnames= ['SHAPE@']
sql = """select st_asbinary(geom),st_astext(geom)
        from asset_utm.dareport_misc
        """
cur.execute(sql)
val = cur.fetchone()
spatRef = arcpy.SpatialReference(4326)
while val != None:
    geom = arcpy.FromWKB(bytearray(val[0]),spatRef)
    geom = arcpy.FromWKT(val[1],spatRef)
    logger.info("Type {0} points {1} parts {2} length{3} area {4}"
                .format(geom.type, geom.pointCount, geom.partCount, geom.length, geom.area ))
    with arcpy.da.InsertCursor( 'VEGDBO.TRAIL_PY',fieldnames) as iCur:
        iCur.insertRow([geom])
    val = cur.fetchone()

The results from the logging are:

2017-07-05 12:24:40,173 - INFO - Type polygon points 20 parts 1 length0.00480354599632 area 1.30829909172e-06
2017-07-05 12:24:40,173 - INFO - Type polygon points 12 parts 1 length0.00575032905258 area 2.10941832519e-06
2017-07-05 12:24:40,188 - INFO - Type polygon points 114 parts 1 length0.00965835903742 area 5.79334045003e-06
2017-07-05 12:24:40,188 - INFO - Type polygon points 58 parts 0 length0.0137069668581 area -9.77088097695e-06

The last row with the -9x10^-6 area is null in the oracle sde based feature. I copied the table into a file geodatabase then ran check geometry, which said it was null.

Other tips I tried was buffering the values by 1 and 0 but that seemed to make things worse - the other geometries became null. I also tried st_simplify with a really small number (0.0000001) but that didn't resolve the issue either - with a larger number I just ended up with 4 points.

First of all, I don't currently know that it is converted to null when I insert it. I've googled for a way to find in arcpy that it is not going to happy.

Is there a better way to check for this than checking for negative area?

Secondly, any idea why this is happening, and how can I resolve it?

closed as unclear what you're asking by PolyGeo Jul 18 '17 at 3:49

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Negative area is an indication that your polygon is wound incorrectly. Please experiment with ST_IsValid() and ST_MakeValid() in the database before trying to get ArcGIS to accept the polygons. – Vince Jul 6 '17 at 2:30
  • Thanks @Vince, I already tried st_isvalid() and all the rows came back as valid. I have now tried st_makevalid and it doesn't change anything. I also wrote directly into a file geodatabase; not surprisingly, it didn't make any differences either. – Bryan Jul 6 '17 at 14:44
  • With further testing, I can create a geometry from this problem set of points. I can insert into a new fgdb. Check Geometry shows no errors. I can then append to the sde feature. This now shows up, albeit with adjusted points, here's a picture, the green is the original from the fgdb, the orange is from the Oracle sde. The strange thing is that I cannot insert it into another fgdb that has essentially the same definition for that feature (both wgs84 / srid 4326), but also other tables that have no geometries. – Bryan Jul 13 '17 at 18:03
  • Please use the edit button beneath your question to revise it with any additional information that may help to make it more answerable. – PolyGeo Jul 18 '17 at 3:49