# Import system modules
import arcpy
from arcpy import env
import os, glob
# Set environment settings
arcpy.env.workspace = ("G:/Animals")
# Set local variables
outWorkspace = ("G:/Animals/Reproject_Out.gdb")
# Use ListFeatureClasses to generate a list of shapefiles in the
# workspace shown above.
fcList = arcpy.ListFeatureClasses()
print fcList
# Set coordinate system only for those inputs which have a defined spatial reference
for infc in fcList:
# Determine if the input has a defined coordinate system
desc = arcpy.Describe(Animals)
sr = desc.spatialReference
if sr.Name == "Unknown":
# skip
continue
else:
# Determine the new output feature class path and name
outFeatureClass = os.path.join(outWorkspace, infc.strip(".shp")
# Set output coordinate system
resFc = outFeatureClass + "," + ("<install directory>/Coordinate Systems/Projected Coordinate Systems/WGS 1984.prj/Cylindrical Equal Area (world).prj")
arcpy.Project_management(infc, outFeatureClass, outCS)
arcpy.AddMessage("The shapefiiles have been reprojected")
print "Get Area Info...."
# Print message to say the two fields are being added
arcpy.AddMessage("Adding fields F_AREA and C_AREA, calculating field values...")
# Execute AddField twice for two new fields
arcpy.AddField_management(Animals, F_AREA, "LONG", "", fieldLength)
arcpy.AddField_management(Animals, C_AREA, "LONG", "", fieldLength)
try:
# Set the current workspace (to avoid having to specify the full path to the feature classes each time)
arcpy.env.workspace = outCS
# Process: Calculate Areas...
arcpy.CalculateAreas_stats(outCS, outCS_output_area)
except:
# If an error occurred when running the tool, print out the error message.
print arcpy.GetMessages()
import math