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.CheckOutExtension("Spatial")
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)
outViewshed.save("C:/temp/output/viewsheds/"+fid)
Answer
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.
No comments:
Post a Comment