AnsweredAssumed Answered

Method "contain" from the Geometry object fails when using different coordinate systems

Question asked by groote_lfu on Apr 13, 2018

Hello,

 

I would like to check whether point geometries are within a certain extent or not. Therefore, I convert the "to test" polygon into a Polygon Geometry Object and the points into Point Geometry Objects using the Shape@ token from the da.SearchCursor. Within the Cursor I apply the contains method. This works perfectly fine when working with the same coordinate system but fails if I user different ones. To simplify things I used a single point coordinate to show the problem. Both, the in_geom as well as the pg object have a coordinate system assigned.

>>> arcpy.env.geographicTransformations = "DHDN_To_ETRS_1989_8_NTv2;ETRS_1989_To_WGS_1984"
>>> in_path = r"c:\dummy_path\polygon.shp"
>>> in_geom = arcpy.CopyFeatures_management(in_path ,arcpy.Geometry())[0]
>>> point_coordinates = [4310708,5534995]
>>> p = arcpy.Point()
>>> p.X = point_coordinates [0]
>>> p.Y = point_coordinates [1]
>>> pg = arcpy.PointGeometry(p,31468)
>>> in_geom .contains(pg)
False
>>> in_geom .contains(p)
True

Why is does the contains method return True with the Point Object but returns False with the PointGeometry Object?

Thanks a lot for your help,

Carolin

Outcomes