2

I made a model with which I would like to process various shapefiles that have different fields. I built it using a test shapefile that had its own fields.

When I try running another shapefile through it, I get wrong field mappings. Is there a way to set my field mappings as a variable so that the output fields in the final table are dependent on the input shapefile?

I have heard of inline variable substitution but I do not know how to/am having a hard time to use it. Any specific example would be most welcome.

My issue more specifically is to make sure that when performing a spatial join, the fields of the actual input feature class are the ones being used, and not the ones that were in the test feature class. I have tried substituting the name of the target feature layer in my Spatial Join with a variable (%Sites_Location%) but that crashes Arcmap I do not know why. Do Spatial Joins not accept variables as target? What am I missing? enter image description here

1 Answer 1

3

You are correct in terms of using inline variables substitutions. Esri has documentation Inline variable substitution

In ModelBuilder, the value or dataset path of a variable can be substituted for another variable by enclosing the substituting variable name in percent signs (%VariableName%). Substituting variables in this manner is called inline variable substitution.

User input to a model tool

Model variable substitution can help you pass values entered by a user directly into a tool inside your model. For example, in the model illustrated below, Parcel ID is a model parameter that is specified when the model tool is run from the Geoprocessing pane. This variable is used in the Expression parameter of the Select Layer By Attribute tool as "Parcel" = '%Parcel ID%'. When the tool runs, %Parcel ID% in the expression is replaced with the parcel ID (9 in the case below), and only those parcels with an ID of 9 are selected.

enter image description here

2
  • My issue more specifically is to make sure that when performing a spatial join, the fields of the actual input feature class are the ones being used, and not the ones that were in the test feature class. I tried substituting the name of the target feature layer in my Spatial Join with a variable (%Sites_Location%) but that crashes Arcmap I do not know why. Do Spatial Joins not accept variables as target? What am I missing?
    – Question
    Sep 26, 2017 at 15:02
  • Can you update your question with the additional details you provide in this comment for others to view as well, just in case they don't view the comment section. Also, can you provide a screen shot of your setup and inputs? So we can review.
    – whyzar
    Sep 26, 2017 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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