I currently have a search cursor iterating through a shapefile in ArcGIS 10.1 that selects a feature and runs a viewshed analysis on that feature (and only that feature). What's the easiest way to also export that same feature to a shapefile with the same name in Python?

fieldFID = 'FID'

arcpy.MakeFeatureLayer_management (inPoints, "pts")

with arcpy.da.SearchCursor('pts',[fieldFID]) as cursor:
    for row in cursor:
        fid = str(row[0])
        print fid
        arcpy.SelectLayerByAttribute_management ("pts", "NEW_SELECTION", '"FID" = {}'.format(fid))
        outViewshed = Viewshed(inDEM,"pts",1,"CURVED_EARTH",0.15)
  • 1
    Generally speaking, all ArcGIS GP operations behave on 1) the selected features , and 2) the whole data set if none is selected. Therefore, as long as you have features selected, only those features will be exported. Commented May 2, 2013 at 14:39

1 Answer 1


You may use the Feature Class To Feature Class python snippet. Here is the general syntax.

FeatureClassToFeatureClass_conversion (in_features, out_path, out_name, {where_clause}, {field_mapping}, {config_keyword})

To output to a shapefile, make sure that your out_path is a folder (and not pointing within a file geodatabase), and that out_name has a *.shp extension.

  • Will this output to a shapefile? Commented May 2, 2013 at 13:43
  • 2
    If out_path is a folder, it will be a shapefile.
    – nmpeterson
    Commented May 2, 2013 at 13:51
  • 1
    Yes, just make sure your out_path is not pointing within a geodatabase and out_name has a .shp extension.
    – artwork21
    Commented May 2, 2013 at 13:51

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.