# How can I keep only the maximal value of two overlapping polygon, keeping also the initial value where they don't?

I work with ArcGis 10.2. I want to Combine (Union?) two Polygons FC of waterdepths, both having the same classification but not the same elements. I want to keep all the elements and all the initial values where the elements don't overlap and only the highest value where they do. I want to use a model builder to do this.

The issue could be resolved in raster but I have too many datasets of different hydrological orders, meaning the main rivers run across a third of Germany whereas the secondary ones are sometimes just small auxiliaries.

Does anyone has already done something like that? How was it solved?

I hope that made sense. I will clarify as much as needed.

-

you can union your layer with itself (Union(analysis)) to build new geometries where you have overlaps. When there is only one polygon it will be retained. Note that you need an advanced licence to union more than two layers at once, otherwise you need to put several unions in a chain.

Then using calculateField(management) you can update all the fields with the maximum value. e.g. with Python, using max(!fielda!,!fieldb!, !fieldc!). Note that the field will be if there was no polygon for one of the layers, so you might need to use a code block like below

``````def nanmax(a,b,c):
if a is None:
a=-999999
if b is None:
b= -99999
if c is None:
c = -99999
return max(a,b,c)
``````

called as

``````nanmax(!fielda!, !fieldb!, !fieldc!)
``````

as suggested by @Chris W, you could add an additionnal "dissolve" step to reduce the number of polygon. Note that you may also need to use a snapping tolerance to avoid sliver polygons.

-
You've got the core of it, but a couple of things. First, OP has multiple layers (changes nothing, but just to clarify). Second, did you mean 'max' at the end there? To elaborate for OP, Union will give you a set of polygons that has an attribute for each layer's depth. Overlaps will have two values, while non-overlap will only have one. Should they be the same, max will return the same value anyway, otherwise the greater depth. I would also suggest adding a Dissolve step based on your new depth field value to eliminate excess polygons. – Chris W May 12 '14 at 18:17
@Chris W thanks for your comments, I've improved my post accordingly. – radouxju May 12 '14 at 18:51
I figured it out , thanks to both of you. I replace the -9999 with 0, found out the field should not be in string... that worked well. Many thanks! – PMessager May 13 '14 at 8:25