-1

I have two feature classes - artificial polygon grid and a point geosites feature class. I have to count number of types of geosites in each polygon of the grid.

For example from an image - the left upper polygon of the grid have number of geosites types: 3.

Some ideas?

enter image description here

enter image description here

enter image description here

  • Construct defaultdict(set), with key being polygon id, values are point types. – FelixIP Oct 5 at 18:23
1

Rename you points layer in mxd table of content to "points", it doesn't matter if it is stored in database or shapefile. I assume that field "ranga" stores type of geosite (why on Earth are you showing irrelevant fields?).

Lookin at polygon table I assume it is stored as shapefile, this is why run below expression on TYPE_COUNT integer field in polygons table:

aDict ={}
with arcpy.da.SearchCursor("points",("NEAR_FID","ranga")) as cursor:
 for pgonID, pointType in cursor:
  ad = aDict.get(pgonID,set())
  ad.add(pointType)
  aDict[pgonID]=ad
def CountTypes(OID):
 return len(aDict[OID])
#--------
CountTypes( !FID!)

If polygons stored in database change

CountTypes( !FID!)

to:

CountTypes( !OBJECTID!)

Output:

enter image description here

Longer alternative without coding:

  1. Dissolve points using 2 fields: NEAR_FID and ranga, with checked multiparts option;
  2. Run frequency on output from above, using NEAR_FID as case field;
  3. Join output of Frequency to polygons using FID<=>NEAR_FID.

As a precaution explode you multipoint input into single parts and work with them, starting with NEAR to polygons.

| improve this answer | |
  • Thank you for your answer. I can't understand the script. Could you explain me - "points" it is the name of the point feature class and POINT_TYPE is the name of the attribute from the geosites attribute table which define of the geosite type? Are there something else to change in the script? There is no definition of the TYPE_COUNT variable... Sorry for my python ignorance... – Tomek Bartuś Oct 6 at 17:54
  • When I tried to run of the script it appears an error: "There was a failure during processing..." – Tomek Bartuś Oct 6 at 18:02
  • "Points" is name of player in mxd. Pointtype is field name. I run script on pointcount field. Polygons stored as ahapefile! – FelixIP Oct 6 at 18:51
  • I do something wrong. Could you write me clearly what names (layers and attributes names) I have to change? Both layers should be in .shp format? What does it mean "player"? – Tomek Bartuś Oct 7 at 8:26
  • This is going anywhere. Update your post with pictures of both layers, I'll rewrite my answer accordingly. – FelixIP Oct 7 at 8:54
0

Apologies I haven't worked with Arc for a while, but one way of tackling this problem is by using overlays. Intersect your grid and point feature classes so each point gets the ID information of the grid it's in.

Then you can use Summary Statistics on the points feature class by the intersected ID field. Select the geosite type field from the grid feature class as your statistics field, and you want the UNIQUE statistic type. Finally, use the grid identifier as a case type.

Edit:

I did misunderstand the question. This only works in ArcGIS Pro. Each point would know which polygon it sits in:

enter image description here

Here are the parameters on the summary statistics tool for the intersected table. Unfortunately, the Unique Statistics Type is what's only available on Pro. So my apologies again.

enter image description here

Along with the results:

enter image description here

| improve this answer | |
  • Output will say that each point sits in one polygon, not even close to the answer he wants. – FelixIP Oct 5 at 21:50

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.