Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I've created a polygon from a raster dataset:

arcpy.RasterToPolygon_conversion(RasterInt, "C:/arc/poly_int.shp", "NO_SIMPLIFY", "Value")

The 'value' field has numbers 1-37, which map to the ID field in the output polygon shapefile feature class.

Now I would like to select points that lay within certain polygons (e.g. delineated by ID). Using the SelectLayerByLocation_management tool only selects points inside all the polygons. How to a define a criteria?

Alternative approach: How do I create multiple polygons from the main polygon, using the ID field?

I'm looking for solutions in Python -- not necessarily using arcpy but I do have it.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You should be able to do a SelectLayerByAttribute on your polygons (from raster) prior to using SelectLayerByLocation.

The Select_analysis tool could be useful to your alternative approach.

share|improve this answer
    
I'm new with arcpy, are you saying I could do something along the lines of: arcpy.SelectLayerByLocation_management("MaalestDnmiSF", "WITHIN", arcpy.SelectLayerByAttribute(..."test")) –  John Jan 18 '13 at 13:19
    
It works! arcpy.SelectLayerByLocation_management("stations", "WITHIN", arcpy.SelectLayerByAttribute_management("test", "NEW_SELECTION", '"ID" = 21')) –  John Jan 18 '13 at 13:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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