I have a point shapefile (points.shp) with fields [owner], [name], etc.. [owner] and [name] are both of type string. The owner contains a single string, the unique owner. Name contains a list of names, seperated by ";".
[owner] [name]
a ";wood;grass;"
a ";grass;house;"
a "house"
b ";wood;tree;"
b ";grass;house;"
c ";tree;"
Now, what I am currently doing is aggregating all points of each unique name-string in [name] by a distance and Spatial Joining those back to count the amount of points containing this string within the Aggregated Polygon. The following script is running in Model Builder.
- Select all [name] LIKE '%;wood;%'
- Aggregate Points by distance z = agg_wood.shp
- Spatial Join agg_wood.shp with points.shp (selection still alive) = adds a field "Join_Count" to agg_wood.shp
- Select [name] LIKE '%;house;%' etc.
The aggregated Polygon Shapes (about 7000) are merged into a final Shapefile. So, my final, merged shapefile will have all counts of [name] occurrences:
shape_wood.shp:
[FID] [Join_Count]
1 10
2 11
3 2
4 1
5 13
6 4
Finally, I merge all aggregated polygon shapefiles, which works. The point file has something about 800,000 points, about 5,000 unique name strings, and about 20,000 unique owners.
My problem is I would like to add a field to agg_wood.shp during the process that sums the number of unique occurrences for the field [owner] for each aggregated polygon. Lets say there are 5,000 points in an area and 500 of those contain "wood" in the list of strings from the field [name]. These are aggregated into one or more polygons. However, there may be 1 up to 500 different owners who generated "wood". I want to add a field [occ_own] with the number of unique owner-strings who added "wood" in the field [name]. So my intermediate output file (agg_wood.shp) would look like this:
shape_wood.shp:
[FID] [Join_Count] [Occ_Own]
1 10 1
2 11 1
3 2 2
4 1 1
5 13 13
6 4 1
shape_house.shp:
[FID] [Join_Count] [Occ_Own]
1 23 3
2 10 5
3 3 3
4 1 1
5 150 1
6 2 1
Then I would merge all of those to a single shapefile of all [name] polygons. But I can't imagine how to modify my process so it can calculate the number of unique owners for each polygon area and [name].
Does anyone have an idea?