Modelbuilder If Falue Field Is

460
7
03-01-2022 06:27 AM
SarahHartholt
Occasional Contributor III

I'm attempting to use the If Field Value Is logical tool to append an AddressPoint to an ApprovedLicense feature class only if the IssueLicense field is 'yes'. 

My current workflow includes reading in the AddressPoint feature class and iterating over the ID field. I perform some calculations on the feature including populating the IssueLicense with 'yes' if a series of conditions are met. I run my model and stop it after  a few iterations to see if it is performing as expected. The field calculations return correct values but I can see that the first 6 address points are appended to my ApprovedLicense feature class even though only 3 have 'yes' values in the IssueLicense field. Can someone tell me why this is happening?

SarahHartholt_0-1646145386636.png

 

SarahHartholt_1-1646144768030.png

 

 

0 Kudos
7 Replies
KimGarbade
Occasional Contributor III

Can you provide a better image of your model (sorry I can't read it)?  Also can you provide an image of your Append dialog?

0 Kudos
SarahHartholt
Occasional Contributor III

Hi Kim,

Thanks for bringing this to my attention. My append tool was missing the Query to only append Where IssueLicense is equal to 'yes', which is now honored when I run the model. I am wondering if it is possible to only append features if they don't fall within a distance of an existing point? i.e. if I run my model multiple times, address points are appended even though they already exist in the dataset. I've tried to use the If Spatial Relationship Is tool as a precondition to append but it hasn't worked with my current set up. Or is there another way to achieve this? 

SarahHartholt_1-1646232464621.png

 

 

0 Kudos
KimGarbade
Occasional Contributor III

Does the point you want to exclude from being added to the append file have an identifier that will already exist in the append file? I.E. if the point you don't want to append to the Append file has an ID of "UID_0001" (made up ID) will that ID already exist in the append file, or will there just be a point in the append file at the exact same location, but having a different ID?

0 Kudos
SarahHartholt
Occasional Contributor III

There may be a point within a distance of the iterated feature. For example, if 5 Main St. has been issued a license and is already in the ApprovedLicense feature class, when 5 Main St. is iterated over in the AddressPoint feature class I don't want it to be appended. Typically we place the address point near the centre of the house but it's not necessarily going to have the exact same geometry as that of the ApprovedLicense point, which is why I set my search radius to 10m in the If Spatial Relationship Is tool above.

0 Kudos
KimGarbade
Occasional Contributor III

I would probably create all the new points first and then run a near command on them to assign them a distance away from the nearest existing point. Then select for distance greater than your tolerance then append the resulting set all at once. It will require you to use a submodel that takes the result of your iterator as input. 

Problem is that if 7 main st is very close to the point that would be created for 5 main it will not get appended..

If the address is common you could use that as the match criteria. But that only works if the addresses are spelled and formatted the same.  Maybe you could use a combo of distance difference and address number.  

0 Kudos
SarahHartholt
Occasional Contributor III

Thanks for the suggestion. I'm trying to incorporate the near tool but I don't believe it is behaving. I assume that the NEAR_DIST field populates to -1 if another point isn't within my 5m search distance. The first time I ran my model I did see one field populate with the id of a point that was within 5m, but since then I only see -1 in all of the processed features so I don't think the tool is working properly.

And so the testing continues.

0 Kudos
KimGarbade
Occasional Contributor III

I put together this example.  Maybe it will help.  Sorry, this might get long:

Let me say first I'm using test data and couldn't do all the processing that you did, but I think it's a decent representation of the steps I'm thinking about.

I had a small Feature Class containing 5 test points (TestPoints - red dots) and created another feature class of 5 points called CloseTest (Green Dots) tables for both are below (before running the model)

KimGarbade_1-1646824782336.png

 

You can see they both contain an address field.  I'm going to append the records from "CloseTest" that have a "Criteria" equal to "Yes" and that are farther than 10 feet away from a point in TestPoints back into TestPoints.  In this case I want to add 25 Pebbles Wy and 40 Not Close St (33 Kim Crt meets the distance requirement but its criteria is "n/a", so it fails the criteria test).

note: I just manually set the criteria, but I think this part is working for you so no big deal.

To do this I had to use three models (and just for the record let me say here that model builder is great for small things, but I don't like it when it starts getting complicated like this. It just seemed harder than writing python would have been)

Model 1

KimGarbade_2-1646825414875.png

Model 1 creates a blank feature class into which I put just the points from CloseTest that meet my criteria test.  I just used Create Feature Class to copy the schema of CloseTest.  I call the empty feature class PotentialAppendRecords.  Model 1 then calls Model2.  This is a submodel containing an iterator that iterates over all of my CloseTest records and appends them into PotentialAppendRecords if they meet my criteria of "Criteria = 'Yes'".

KimGarbade_3-1646826213534.png

The result of Model 2 is a feature class containing 4 records that meet my criteria, it is set as a parameter in Model 2 so it will be returned in model 1 as the output of Model 2 (I hope that makes sense - it shows up as "PotentialAppendRecord(#)" in model 1).  PotentialAppendRecords then gets passed to a Near tool in Model 1.  This adds attributes to PotentialAppendRecords that indicate how close it is to a feature in TestPoints.  I use 10 feet search radius, so anything outside of that gets a -1 value in NEAR_DIST:

KimGarbade_5-1646826805081.png

 

KimGarbade_4-1646826688833.png

We can see that two records in PotentialAppendRecords are farther than 10 feet from a record in TestPoints.  All model 3 does is append those 2 records in TestPoints.

KimGarbade_6-1646827214788.pngKimGarbade_7-1646827254627.png

I hope this helps.

Since I've been this long winded I'll say that to me it didn't seem like Model 3 should be needed, but if I didn't include it the iterator in model 2 would run the Near in Model 1 5 times and the append would not work, but when I isolated the append in its own model and passed PotentialAppendRecords to it as a parameter it worked.  I think I know model builder pretty well and it still confuses me sometimes.

0 Kudos