Hi, I am very new to Model Builder and need to make a model that will create a new field which basically says "yes, this point is within this boundary," or "no, this point is not within this boundary." I have used the select layer by location tool to select the points that are within my other shapefile (a polygon), and believe I need to use the "Add Field" and "Calculate Field" tools, but am stuck as to where to go from here and how to get the Yes/No text into the new field. From my understanding, the spatial join tool could also be used, however, I end up with zero results which is incorrect (possibly user error?). Any help would be appreciated. Thank you!
do a spatial join manually... if it returns none, then the files are not in the same coordinate system, even if it appears they are onscreen. If that is the case then you need to fix this by using the Project tool on one of them, projecting to the coordinate system of the other. Do not use the Define Projection tool, unless one of the files does not have a defined coordinate system.
In addition to advice on projection, I would create a new field and
populate it using "no" in field calculator before applying the spatial
join, then afterwards change selected records to "yes" .
Thank you for the suggestions. After fixing my coordinate system, it was very easy to create my model. While the spatial join works well, I am wanting to test out the select layer by location tool so that it automatically highlights/flags those points that are within the boundary. The part I am stuck on is creating the script in the calculate field tool so that the selected points (those within the boundary) have "Yes" in the new field, while those not in the boundary have a "No" in the new field. I imagine it's very similar to what I used for the spatial join, but don't know how to write it since I am wanting the selected features to return a "Yes" in the field. For the spatial join I used:
if InBoundary == 0:
Glad the coordinate issue is fixed. I figured it was that, although there seems to be one in disagreement.
Now with select by location, you know that it makes a selection in the table, If you have added the field already, then you can use the Calculate field to put "yes" in your desired field. The problem then, is you have to switch the selection, which will highlight all the records that weren't within, then calculate again with "No" in the field.
Your workflow is better suited to scripting than a model. However, by using the Results window output, you can export any successful process and see the syntax required.
In any event, there is an option to invert a selection inside the tool process itself