Model builder, find minimum value, Iterate feature class

6293
12
Jump to solution
08-04-2014 06:36 AM
jamiefinney
New Contributor III

Hi i'm struggling to finalize a model i'm making. from my final results i want to extract the lowest (minimum) value and save it.

 

i'm using an "iterate feature classes" tool so i need to be able to add %name% into the expression so it will find the lowest value for each of the files that goes into the tool

 

The column Elev_Diff is the column i want the minimum value from

 

the name of the file will be a variable (from iterator) called %name%

 

any ideas?

0 Kudos
1 Solution

Accepted Solutions
ChristianWells
Esri Regular Contributor

I believe that the issues being faces are related to the geodatabase referenced in G (7_Match_DTM_Assessment.gdb) and used for the FC to FC in B. This is currently a File Geodatabase (.gdb) and needs to be a Personal Geodatabase with a .mdb extension.

View solution in original post

12 Replies
RiyasDeen
Occasional Contributor III

1. Use summary statistics tool, statistics field will be your Elev_Diff and statistics will be MIN, don't use any case field. This will create a table with one row, containing your minimum Elev_Diff.

2. Then Iterate field value of this table to get your name parameter.

0 Kudos
ChristianWells
Esri Regular Contributor

Finding the minimum value:

This may be difficult to do as shapefiles don't fully support subqueries (See link here). However, if the data were stored within a Personal Geodatabase (MDB) this could be done using the following query:

Elev_Diff in (select MIN(Elev_Diff) from <featureclass>)

Exporting a file with the name of its input:

I would suggest adding another tool to the end of the model, Copy Features, to copy the selected features to a new file.

jamiefinney
New Contributor III

Thanks for both your suggestions

Christian;

your method looks the more promising of the two. I've converted the data into a geodatabase but i can't seem to get the query to validate. i'm sure its something obvious i'm doing wrong.

[Elev_Diff] in (select MIN([Elev_Diff]) from %name%)

Riyas;

your method would work but would require more processing to create points and bring data back into the tables so i'd be keen to avoid this method if i can.

0 Kudos
ChristianWells
Esri Regular Contributor

Hi Jamie,

Here is how I set up my model. I put all of the shapefiles into a Personal Geodatabase, then used the iterate tool to loop through them and create a new feature class using the following expression:  [Area_SqFt] in (select MIN( [Area_SqFt]) from %Name%)

0 Kudos
jamiefinney
New Contributor III

Thanks for your continuing help on this query.

as best as i can see i've got exactly the same query as you but i'm getting an error see attached.

0 Kudos
ChristianWells
Esri Regular Contributor

No problem. Do you get the error when running the model or verifying the SQL expression? If it happens during the verify, this would be expected because the verification does not substitute the value of the inline variable when evaluating an expression. When the tool runs, the value of the inline variable is substituted in the expression and the results are created based on the substituted values. (See link here)

0 Kudos
jamiefinney
New Contributor III

Hi Christian,

Still having trouble getting this to work.

the data is now held in a geodatabase but i'm sill getting errors (see attached) when the model runs

i've used the query using the feature class to feature class tool and select tool in model builder with the same error outcome

0 Kudos
ChristianWells
Esri Regular Contributor

Can you send a picture of your model and the settings of the "Name” variable?

0 Kudos
jamiefinney
New Contributor III

Sure thanks again for your continuing help on this issue

running ArcView 10 (sp5) if that makes any difference

0 Kudos