Extracting attribute values of underlaying polygons to single cell

885
3
Jump to solution
07-23-2021 07:00 AM
TadeášDěd
New Contributor III

Hi, 

imagine I have one target polygon (A) and several underlying polygons (B1, B2, ...). Is there a way to concatenate attribute values of underlaying B polygons to target polygon A?

I was trying to create a script with Spatial join and rule (field maps), however, I was strugglling with two things:

1. it did not work :), but I believe that I could solve that one 

2. there is no suitable match option for my case, please check this site.  

I would like to match B polygons where A polygon is overlapping them. The default option INTERSECT however matches also in the case where two polygons touch by edges or when they have only one point in common. Well, I understand the coding part behind it, but from a practical point of view, this is bad. For example, you have a polygon of vegetation growing on multiple parcels. For every vegetation area, you want the string/list of parcel numbers. When I define my vegetation area exactly around several parcels (respecting their edges) I would get neighbor parcel numbers in my list too. 😕

Is there any workaround? The only thing that came to my mind is creating new vegetation areas with a very small negative buffer to avoid matching of edges.

Thank you very much for any tips on how to solve this.

Thank you!

TD

p.s. Here is my code (not functional)

KN_Feature = "PARCELY_KN_JOIN"
areaVysledek = "area_Vysledek"
zapojporostFeature = "zapojporost"

fms1 = arcpy.FieldMappings()

fms1.addTable(KN_Feature)
fms1.addTable(zapojporostFeature)
keepers = ["cislo","KATUZE_KOD","TEXT_KM","DRUH_POZEMKU"] # etc.
# Remove all output fields you don't want.
for field in fms1.fields:
if field.name not in keepers:
fms1.removeFieldMap(fms1.findFieldMapIndex(field.name))

parcela_index = fms1.findFieldMapIndex("TEXT_KM")
fieldmap = fms1.getFieldMap(parcela_index)
field = fieldmap.outputField
field.name = "parcelaCislo"
field.aliasName = "parcela č."
fieldmap.outputField = field
fieldmap.mergeRule = "Join"
fieldmap.joinDelimiter = ", "
fms1.replaceFieldMap(parcela_index, fieldmap)

drupoz_index = fms1.findFieldMapIndex("DRUH_POZEMKU")
fieldmap1 = fms1.getFieldMap(drupoz_index)
field1 = fieldmap1.outputField
field1.name = "druhPozemku1"
field1.aliasName = "druh pozemku"
fieldmap1.outputField = field1
fieldmap1.mergeRule = "Join"
fieldmap1.joinDelimiter = ", "
fms1.replaceFieldMap(drupoz_index, fieldmap1)


# SpatailJoin pro plochy
arcpy.analysis.SpatialJoin(zapojporostFeature, "PARCELY_KN_JOIN", areaVysledek, 'JOIN_ONE_TO_ONE',"KEEP_ALL",fms1)

0 Kudos
1 Solution

Accepted Solutions
JayantaPoddar
MVP Esteemed Contributor

Could you test Intersect (Analysis) tool, if it gives you a desirable result?



Think Location

View solution in original post

3 Replies
JayantaPoddar
MVP Esteemed Contributor

Could you test Intersect (Analysis) tool, if it gives you a desirable result?



Think Location
NobbirAhmed
Esri Regular Contributor

Your case is very interesting. Spatial Join tool's Join Features parameter takes only one feature class or layer as input. But you have multiple join feature classes. 

You can give Jayanta Poddar's suggestion a try - it's a good suggestion.

You wrote you couldn't find any suitable match option - which relationship (except for the given ones) you are looking for? 

Send an email to me at nahmed@esri.com

TadeášDěd
New Contributor III

Hi, 

 

thank you for your answer. Jayanta's suggestion works as expected. 

 

Spatial Join however is still having this INTERSECT option (default) which is different from Intersect (Analysis). I would expect it to be the same thing (i.e. return the same results).

 

Thank you!

Best from 

Tadeas

0 Kudos