I am trying to iterate through a set of polygons and for each polygon select the points in another feature class which fall within. Once those points are selected I want sum the values of one of the point attributes and add that sum to an attribute field in the polygon. Everything seems to work except if no point falls within the polygon instead of 0 the field in the polygon attribute is filling to 1. I have tried various preconditions and the field value Null is set to 0 but this keeps occurring. Attached is a copy of the current model.
you may accidentally have a selection on a layer?
Should be One to one not one to Many? that seems like the issue.
If doesn't work, just try with all the defaults, and don't add a new field or change anything except for changing the merge rule.
Ahhh, I think it was the one to many that was the issue. Thought to use that since there are multiple GS points within a cell but it looks like I don't need it. Thanks for your help!
Did that, as attached screen shot, added field GSTEST, which came out as NULL...
OK to save this getting muddled just do this:
add a new field using the + icon -> name the field whatever you want. on the right hand side Add Source and set that to ART_COUNT and click 'add selected' set the merge rule to SUM. keep all the other fields as original default.
then run
But I do want to Sum ART_COUNT from the GS table and put the Sum in the TOT_GS field. TOT_GS is just 0s right which needs the sum of ART_COUNT of all intersecting GS points. Does that make sense?
I see what you mean, so:
Target Features: Polygon
Join Features: Point
Output fields: Polygon attribute field selected
Source: Merge Rule=Sum, Point attribute field to sum selected
This configuration gives me all NULL values in the polygon field.
Yes, you can control how a field is mapped in the spatial join. As you say, the default would be to return a JOIN_COUNT, JOIN_FID etc. and the other fields you have specified in the field mapping.
Of those other fields, you would have the attribute of the first coincident point found, BUT you can control how this is done.
Look at the field map parameter in the tool, and the merge rule dropdown.
from the link I supplied:
Merge rules specified in the Field Map of Join Features parameter only apply to attributes from the join features and when more than one feature is matched to a target feature (when Join_Count > 1). For example, if three features with DEPTH attribute values of 15.5, 2.5, and 3.3 are joined, and a merge rule of Mean is applied, the output field will have a value of 6.1. Null values in join fields are ignored for statistic calculation. For example, 15.5, <null>, and 2.5 will result in 9.0 for Mean and 2 for Count.
I'm looking to total an attribute field in the selected point feature class which has a count number in it, so not just summing the number of points that fall within the polygon. For instance there may be two points within the polygon, one with a count of 1 and one with a count of 3. I want to fill in the polygon attribute with the value of 4. This model successfully does that but when there are no points within the polygon it is filling in the attribute field as 1 instead of 0.
Can you not achieve the same without a model and use a Spatial Join, with a field mapping merge rule set to 'SUM' of that particular field?
Spatial Join (Analysis)—ArcGIS Pro | Documentation
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.