3

I have a feature class that contains one polygon feature, and I need to check if said feature lies completely within another polygon feature.

Used selectLayerByLocation and then retrieved the count (arcpy.GetCount_management) for some other intersection based checks that need to be done; in this case however there is only ever one feature in the feature class and retrieving the count will only return one (regardless of if the polygon is fully contained or not).

Any ideas?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jul 8, 2014 at 8:51

2 Answers 2

4

The Select Layer By Location (Data Management) tool has various overlap_type values that you can use so I think you should try:

COMPLETELY_CONTAINS —The features in the input layer will be selected if they completely contain a selecting feature. The input features must be polygons.

answered Jul 8, 2014 at 9:55
0
2

An "amusing" way to solve the issue of there being only one feature in your input feature class would be to make a feature layer to select every feature (in this case, 1) and then run select layer by location with the parameter selection_type="REMOVE_FROM_SELECTION". Then, GetCount() will return a 0 if the feature is indeed within the polygon (selected and therefore removed) and a 1 if it is not.

A bit backwards, so just cast to int and not the result if you want your 0 to be a 1.

answered Jul 8, 2014 at 12:59
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.