Geometry methods

952
6
05-30-2012 03:42 AM
NeilAyres
MVP Alum
When I first saw this in 10 I though that would be very cool to do some spatial processing...
Never had a chance to try it until a few days ago. As usual I'm stuggling.

I have done a whole load of searches here and found plenty of discussion re the accuracy of the integer version of the geometry so that properties are incorrectly reported (like Poly1Geom.area)
But no real info on how to do the geometry comparisons. The help files are a little thin here as well.

My idea was to load the geometry objects into a python list / dictionary or whatever, to facilitate looping and comparison with other geometry objects.
The lists load fine and the geometry objects in the list have the usual properties. But when I get to the methods they are always "False". ie Poly1.inside(Poly2) always = False, even when its not.

I am using Arc10 SP4 and all this is running python code in IDLE.

Anyone got any tips or pointers to some script examples to do this?

Thanks in advance,
Neil
Tags (2)
0 Kudos
6 Replies
NeilAyres
MVP Alum
Bump....

So has no one out there used geometry methods?
0 Kudos
MarcinGasior
Occasional Contributor III
According to Geometry class web help, there's no inside() method for this class.
Make note that some geometry methods can be applied for specific geometry types only (eg. when you test if point contains polygon, you'll always get False).

If you want more specific answer, provide your code with description of inputs.
0 Kudos
NeilAyres
MVP Alum
Probably meant to say ".within()", but no matter. Just wanted to know if there were any scripts or pointers out there using these methods with objects in a python list or dictionary.
All the help seems to build a geometry object from scratch, then do some anlaysis on it. Rather than reading the geometry object from an existing fc.
Will have another go at this when i have a little more time....

Thanks anyway.
Neil
0 Kudos
MarcinGasior
Occasional Contributor III
You access geometry using cursors and then reading SHAPE field.
Here's an example where if a polygon contains a point, some attribute from polygon layer is copied to point layer:
...
updCursor = arcpy.UpdateCursor(pointLayer)
for updRow in updCursor:
    pnt = updRow.Shape

    #copy field values from polygon to point layer
    searchCursor = arcpy.SearchCursor(polygonLayer)
    for row in searchCursor:
        poly = row.Shape
        if poly.contains(pnt):
            updRow.setValue(copyField, row.getValue(copyField))
            updCursor.updateRow(updRow)
...
0 Kudos
NeilAyres
MVP Alum
No worries,
and yes I do read the help files before posting here....

My approach was exactly that, use cursors to cycle through the relavent geometries.
However, I was reading the geometry objects into a python list first before testing with the various methods.

N
0 Kudos