I have a model where I want to check the projection. If it is GCS_WGS_1984, I want it to go one path, and if it isn't, I want it to go another path.

I created a "Check Coordinates of Input" script to output two Boolean values of True or False. The script is:

import arcpy, os
from arcpy import env
env.overwriteOutput = True

Footprints = arcpy.GetParameterAsText(0)

desc = arcpy.Describe(Footprints)
type = desc.spatialReference

    if type.name == "GCS_WGS_1984":
        arcpy.SetParameterAsText(1, "True")
        arcpy.SetParameterAsText(2, "False")

        arcpy.SetParameterAsText(1, "False")
        arcpy.SetParameterAsText(2, "True")
except Exception as e:
    AddPrintMessage(e[0], 2)

enter image description here

When the input isn't in GCS_WGS_1984, the model is able to run okay. I get the True.kmz file but in the messages I also get "The process did not execute because the precondition is false" and "All the inputs are not current". When the input file is in GCS_WGS_1984 however, I get and error message from the Project function of "invalid geographic transformation" and it stops there.

How do I get it so that if the coordinates are true, the goes along the upper path, and if it's false, to go along the lower path?

I was reading something on ArcGIS's online resource about a Run Model Parameter http://resources.arcgis.com/en/help/main/10.2/index.html#//002w0000007r000000 being checked and was wondering if that would make a different? Still though, I don't know how to access that.

And this is for later if it all works out: If I'm running this in a tool dialog box, the options for the true and false kmz will be required, even if only one is going to be created?


You have two options in model builder:

  1. Use Calculate Value to test a condition and output a boolean
  2. Write a custom script tool to test the condition. There is a good sample script on the help page which checks for a certain projection and outputs a boolean.

More information here:

Using if-then-else logic in ModelBuilder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.