AnsweredAssumed Answered

How to generate a Point or PointGeometry from a da.SearchCurser that can be used as an input Point in queryPointAndDistance()

Question asked by alexander.c.audet@maine.edu on Nov 17, 2017
Latest reply on Nov 17, 2017 by alexander.c.audet@maine.edu

My question involves handling data types, particularly of strings, points and tuples. I start with a single object (I think I can say feature object as it has geometry on top of other attributes) selected by location in a feature layer. I then try to access a point geometry from that object using the SHAPE@TRUECENTROID token within a arcpy.da.SearchCurser() method and set that Point Geometry equal to a variable. I then call that variable within the queryPointAndDistance() function as my input Point or PointGeometry, but Arcpy gives me the following at the end of the error message error. 

 

File "<expression>", line 1, in <module>   File "<string>", line 22, in Strike ValueError: (612744.9906049052, 3417217.9973794315)

 

It appear that it does not recognize my function as either a Point or PointGeometry. Where does the output from the curser function become something different (a different type perhaps)? 

 

This post python - ArcPy QueryPointAndDistance: Incorrect Lengths? - Stack Overflow  suggested to me that by setting a variable equal to a SearchCurser, that variable would equal the geometry object specified. Is there any difference between the logic used there when the he gets the line geometry and what I am doing that I did not catch? 

 

The problematic part of the code is as follows:

 

If it helps answer the question, this script is within a def in the codeblock of a CalculateField_management() method so 'shape' = the geometry of the record being calculated, and PairedCheck6 is my feature layer with one selected record. 

codeblock = """def Strike(shape, seed, fid):

        # PairedCheck6 = feature layer with single selection

        cursorResult = arcpy.da.SearchCursor('PairedCheck6','SHAPE@TRUECENTROID').next()[0]
        centroid = None

        if len(cursorResult) > 0:
            centroid = cursorResult
        else:
            return '5000'
        (pointGeometry, distance, minDistance, isCentroidRight) = shape.queryPointAndDistance( centroid, False)"""

 I can show more of the code if requested, but I did not want to ask anyone to look through more than is required. 

Outcomes