Skip to main content
deleted 24 characters in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. Hopefully that makes sense. 

Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. Hopefully that makes sense. Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. 

Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()
deleted 128 characters in body
Source Link
DEB
  • 305
  • 1
  • 10

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

Like this:

enter image description here

I need the result to be:

enter image description here

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. Hopefully that makes sense. Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

Like this:

enter image description here

I need the result to be:

enter image description here

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. Hopefully that makes sense. Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. Hopefully that makes sense. Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()
edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

Like this:

enter image description here

I need the result to be:

enter image description here

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. Hopefully that makes sense. Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()

Any Help would be great!

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

Like this:

enter image description here

I need the result to be:

enter image description here

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. Hopefully that makes sense. Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()

Any Help would be great!

I currently have code that re-projects all my shapefiles in a folder based off an input shapefile that I select. I will attach the code below. The code runs fine, but I would like the message on the geoprocessor window to say "Projected feature1, feature2, feature3, etc"

I currently can only get the script to list: "Projected feature1" "Projected feature2" "Projected feature3"

Like this:

enter image description here

I need the result to be:

enter image description here

It's basically printing the message for each iteration of the loop but I need it to print each feature class selected. Hopefully that makes sense. Attached is my example script below.

import arcpy
folderLocation = arcpy.GetParameterAsText(0)
targetShapefile = arcpy.GetParameterAsText(1)

try:
    
    targetDescribe = arcpy.Describe(targetShapefile)
    targetSpatialRef= targetDescribe.spatialReference
    targetSpatialName = targetSpatialRef.Name
    arcpy.env.workspace = folderLocation
    featureList = arcpy.ListFeatureClasses()
    for fc in featureList:
        desc = arcpy.Describe(fc)
        spatialRef = desc.spatialReference
        fcName = spatialRef.Name
        
        
        if fcName != targetSpatialName:
            rootName = fc.replace(".shp", "")
            outfc = folderLocation + '\\' + rootName + "_Projected"
            outCS = targetSpatialRef
            arcpy.Project_management(fc, outfc, outCS)
            arcpy.AddMessage("Projected "+ fc)


except:
    print arcpy.GetMessages()
added 222 characters in body
Source Link
DEB
  • 305
  • 1
  • 10
Loading
Source Link
DEB
  • 305
  • 1
  • 10
Loading