Created
May 11, 2015 08:25
-
-
Save cindygis/828c4925d668bc7b7f9c to your computer and use it in GitHub Desktop.
Writes certain properties of a feature layer within a group layer to csv.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# @date 11/05/2015 | |
# @author Cindy Williams | |
# | |
# Writes certain properties of a layer within a group | |
# layer in a mxd to csv. | |
# | |
# For use in the Python window in ArcMap. | |
# | |
import arcpy | |
import csv | |
mxd = arcpy.mapping.MapDocument("CURRENT") | |
lyrs = [lyr for lyr in arcpy.mapping.ListLayers(mxd) if lyr.isFeatureLayer] | |
outcsv = r"C:\Some\Arb\Folder\comp.csv" | |
with open(outcsv, 'wb') as csvfile: | |
csvwriter = csv.writer(csvfile) | |
csvwriter.writerow(["Group Layer Name", "Dataset Name", "Projection", "Number of features"]) | |
for lyr in lyrs: | |
desc = arcpy.Describe(lyr) | |
csvwriter.writerow(lyr.longName.split("\\")[0], | |
lyr.datasetName, | |
desc.spatialReference.name, | |
str(len([row[0] for row in arcpy.da.SearchCursor(lyr, desc.OIDFieldName)]))) | |
print("Wrote properties for " + lyr.name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment