In Arcpy, I would like to start with a point and then using its geometry method to find out if it is inside my polygon feature (Urban Areas) deeper than the buffer distance.

This is a follow up to this post: Zonal Analysis using geometries

for i in range(4):
    if buf.within(UrbanAreaFC):  # Error here

The error is: type 'exceptions.ValueError' and the path to the geodatabase where Urban Areas is found is given.

What is that error and how do I fix it?

  • 1
    I'm assuming you've got point from a cursor before this. What is UrbanAreaFC? It looks like a feature class, only geometries can be used in this way. Either you load all the geometries from the feature class or persist the buffer and use Select by Location with a feature count to determine overlap. If you want to find out how far they are inside get the boundary and do a near, that will tell you how far it is to the closest boundary. May 12, 2015 at 21:32
  • 1
    It'd help if you included the full code since the error you're getting is not part of the code you provided.
    – ianbroad
    May 12, 2015 at 21:32

1 Answer 1


The Geometry.within() method only accepts other Geometry objects -- in your case, it has to be a Polygon. It doesn't know what to do with a feature class, so I would suggest dissolving that feature class into one containing a single polygon, and then access the Geometry object with this:

urban_area_geom = [r[0] for r in arcpy.da.SearchCursor(DissolvedUrbanAreasFc, ['SHAPE@'])][0]

This returns the first (only) specified attribute -- the geometry -- for the first (only) row in the dissolved feature class.

  • You were right and it totally makes sense! Thanks!
    – user918967
    May 13, 2015 at 1:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.