0

I have built a geoprocessing tool using arcpy modules in python. Screenshot shown below: enter image description here

In this tool I am creating Service Area Polygons and selecting census boundaries within those Service Area Polygons to extract the demographic data. The part where I am creating the service area polygon and copying them to output is shown below:

#PART 3: CREATING SERVICE AREA POLYGON USING DRIVING DISTANCE AS COST FACTOR AND INTERSECTING WITH CENSUS LAYER AND CREATING OUTPUT

Service_Area = "Service Area"

# Process: Make Service Area Layer
arcpy.na.MakeServiceAreaLayer(road_network, Service_Area, "Length", "", distance)

# Process: Add Facility to the Network
arcpy.na.AddLocations(Service_Area, "Facilities", "facility", "", "")

# Process: Solve the Network
arcpy.na.Solve(Service_Area)

# Copy Polygons to Service Area output
arcpy.CopyFeatures_management(Service_Area, service_area_output)

# Process: Create a new Feature layer - Census layer
arcpy.MakeFeatureLayer_management(cen_blk,"blocks_lyr")

# Process: Create a new Feature layer - Census layer
arcpy.MakeFeatureLayer_management(service_area_output,"service_area_output")

# Process: Select Layer By Location...
arcpy.SelectLayerByLocation_management("blocks_lyr", "HAVE_THEIR_CENTER_IN", "service_area_output")
if census_output=="#" or census_output=="":
    census_output==None

else:
    # Process: Copy the intersected census layer to output FC and add it into current workspace
    arcpy.CopyFeatures_management("blocks_lyr", census_output)

gp.AddMessage (" ")

I cannot seem copy the service area polygon to a feature class. I am getting a following error message.

Is CopyFeature not the right method to copy the service area polygons?

enter image description here

3

You don't want copy, you want Select. You'll select the layer you want from the Solve and carry on with that. The Solve output is a group of layers. After you select it out, I believe it's still a layer, as such you wont need to MakeFeatureLayer. You should just be able to do your SelectByLocation with it.

  • Can you actually export the selected layer to feature class for other analysis purposes? – Raj Dec 12 '13 at 21:22
  • Sure. Once its selected you can run copy features to persist it as it's own featureclass. Or just use the selected features directly into another tool. It's up to you. – KHibma Dec 13 '13 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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