Is it possible to get the attribute values from selected features and export them to an excel file using python? If so, how do i go about it.
Thank You
You bet. Please let me know if you have any questions and I'll do my best to help.
Thank you
If I understand you correctly, you're wanting to create a selection, and then export the results to .xls.
Here's how I would do it:
# Import libaryimport arcpyfrom arcpy import env
# Set variablesyourworkspace = "path to your workspace"yourfeatureclass = "path to your feature class"outputlocation = "path to your output folder"
arcpy.env.workspace = yourworkspace
# Make Layerarcpy.MakeFeatureLayer_management (yourfeatureclass, "featureclasslayer")
# Create selectionarcpy.SelectLayerByAttribute_management ("featureclasslayer", "NEW_SELECTION" ["build your selection criteria here"])
# Copy the results of your selection to a new feature classarcpy.CopyFeatures_management ("featureclasslayer", "yourselectedfeatures")
# Export to ExcelTableToExcel_conversion ("yourselectedfeatures", "yourexcefilename.xls")
# Finish
raise SystemExit(0)
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.