3

I am working with ArcMap 10.8 and extensions.

I have a grid (polygons) and another shapefile of points. I need to generate a field in the grid that shows me how many points are inside each cell, but grouped by a criterion.

For example suppose that the grid are "football stadiums" and players are points. The points shape has a field called "team". If in a specific stadium there are 34 players from 3 different teams, in the count field of polygons shape we will have 3.

With spatial join tool I can only count the total points within the polygons, but I cannot count by attributes.

4
  • 1
    Spatial join is hardly the only tool for this (I prefer overlay tools), but there doesn't seem to be any reason it couldn't be used. You just need to compile the correct statistics (which, again, have multiple tools to accomplish the goal). Please Edit your Question to contain more information on how you are attempting this. – Vince Feb 7 at 18:54
  • Dissolve by grid Id and team name to multiparts. Compute frequency per grid id. – FelixIP Feb 7 at 19:05
  • FelixIP, thanks very much. Could you explain the method in more detail please? – Jota Q Feb 8 at 8:48
  • Not sure what else to explain. You need 2 tools a)Dissolve. Use 2 fields in spatially joined points, id of rectangular polygon and team name. Tick 'create multiparts'. b) Frequency tool to run on output of a., using polygon identifier. You can add output table to polygons by Join Field tool – FelixIP Feb 8 at 18:40
5

Here is one such solution, using this test data, players are labelled with their "team name":

Test data

Run the spatial Join Tool but set the field map up as shown below:

Field Map Note the merge rule is set to JOIN and the delimiter is a comma

The Output would be this:

Output

Now add a numeric field and run the following python in a field calculate tool:

len(set(!team!.split(",")))

Final result

3
  • 1
    Nice one, +1. Never used rules in join before. – FelixIP Feb 8 at 3:39
  • 1
    Hornbydd thanks very much. I'll try your proposal, I find it incredibly ingenious. – Jota Q Feb 8 at 8:50
  • @FelixIP, it's a trick I learnt a few years ago reading someone else's blog page, I rarely use it in anger but it does solve these sorts of problems, a card to keep up ones sleeve to be revealed at the right time! :) – Hornbydd Feb 8 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.