Friday 20 April 2018

arcgis desktop - Using Join in model gives ERROR 000840?


I'm trying to build a model using Model Builder in ArcGIS 10.1 that starts off by joining two shapefiles together based on a common field. I would like to make this open ended (not hardcoded) so I can use it repeatedly.


enter image description here


Problem is when I go to select my shapefiles when I run it, I can add one, but not both (I only get an option to select "data elements").


Likewise, when I try to edit the model and insert or hardcode the shapefiles into it, I get an error message at Add Join that says


ERROR 000840
The value is not a Raster Layer. ERROR 000840: The value is not a Raster Catalog Layer. ERROR 000840: The value is not a Mosaic Layer.

When I go through this same workflow in ArcMap I get the results I am looking for.



Any idea what is causing these errors, how to correct them or a work around?


So we are clear, the following workflow is what I'm trying to automate:


1.  Join [CURRENTMONTH] shapefile to [PREVIOUSMONTH] shapefile.
2. Perform a select by attributes:
a. Select From “[PREVIOUSMONTH]_[CURRENTMONTH]“ WHERE “[CURRENTMONTH].SEGMENT_ID” IS NULL
3. Remove Join.
4. Export Selected Features to new shapefile (deletes.shp)

The second half of the model reverses the process and attempts to accomplish the following:


1.  Join [PREVIOUSMONTH] shapefile to [CURRENTMONTH] shapefile.

2. Perform a select by attributes:
a. Select From “[CURRENTMONTH]_[PREVIOUSMONTH]” WHERE “[PREVIOUSMONTH].SEGMENT_ID” IS NULL
3. Remove Join.
4. Export Selected Features to new shapefile (added.shp)

UPDATED TO SHOW MODEL DIALOG


enter image description here


Updated to show new model enter image description here



Answer



To do a join in a model, you first need to convert the shapefiles to feature layers within the model. Use the Make Feature Layer tool in the Data Management Tools>Layers and Table Views toolbox on your input shapefiles, then add the outputs of the Make feature layer tools as the inputs to the Join tool. The select by attributes tool also requires that the inputs be feature layers.enter image description here



EDIT


Here is an update in reference to comments below. Craig, since you want to run this as a tool, you need to set the model parameters on the tools without adding any data in the model itself. So starting with a empty model, add your make feature layer and join tools. Right click on the Make Feature Layer tool, then go to Make Variable>From Parameter>Input Features. Repeat for your second Make Feature Layer tool. Add the output layers to the join tool, then right-click on the join tool and go to Make Variable>From Parameter>Input Join, then repeat an do output join. Since you are going to run this a tool you will need to specify the join fields. Here are some screenshots.


enter image description here


When you run this model as a tool the select input layer shows shapefiles.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...