outFeatureClass = os.path.join(outWorkspace, infc.strip(".shp")
outFeatureClass = os.path.join(outWorkspace, infc.strip(".shp"))
if sr.name == "Unknown": # Determine the new output feature class path and name outFeatureClass = os.path.join(outWorkspace, infc.strip(".shp")) # Set output coordinate system outCS = "Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj" outCS2 = "Coordinate Systems\Projected Coordinate Systems\World\Cylindrical Equal Area (world).prj" arcpy.DefineProjection_management(infc, outCS) arcpy.Project_management(infc, outFeatureClass, outCS2) arcpy.AddMessage("The shapefiiles have been reprojected") print "Get Area Info...."
desc = arcpy.Describe("Animals.shp")
desc = arcpy.Describe(infc)
# 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.shp") sr = desc.spatialReference if sr.name == "Unknown": # Determine the new output feature class path and name outFeatureClass = os.path.join(outWorkspace, infc.strip(".shp")) # Set output coordinate system outCS = "Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj" outCS2 = "Coordinate Systems\Projected Coordinate Systems\World\Cylindrical Equal Area (world).prj" arcpy.DefineProjection_management(infc, outCS) arcpy.Project_management(infc, outFeatureClass, outCS2) arcpy.AddMessage("The shapefiiles have been reprojected")
arcpy.Project_management(infc, outFeatureClass, outCS)
# 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
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.