I have a two polygon feature classes stored in a geodatabase: Natural reserves and Forest cover.

Using ArcGIS Desktop 10.4, I would like to subset National reserves where the forest covers more then 5% of their area.

Therefore, I wanted to:

  • intersect the natural reserves and forest
  • dissolve the forest (multiple islets might present the forest in one reserve) polygons in Reserves
  • spatial join the Shape_Area of forest per reserve to attribute table of original natural reserves
  • calculate the % of forest coverage subset only reserves covered by forest by more than 5%

My problem is when I apply Spatial Join, some of my forest Area values (Area_SMK)are added as Null. I have tried to define fieldmappings, and also copied the Shape_Area of Forest FC to new columns, to avoid the same field name (Shape_Area) in my output data; neither one helped:

enter image description here

How can I avoid the Null values acquisition?

Is there maybe a safer way to subset my Natural reserves by the proportion of the forest?

My python code:

import arcpy

# SEt working directory
arcpy.env.workspace = "C:/Users/Projects/analyzed.gdb"

# Read input Forest and Reserves data
inSMK = "outSMKpoly"
inNR = "NR_inSMK"

# Set local variables
dissFields = ["NAM_lat", "PSB"]


    # Allow files to overwrite
    arcpy.env.overwriteOuput = True

    # Process: Intersect SMK and NR
    intersectOutput = "intSMK_NR"

    if arcpy.Exists(intersectOutput):

    arcpy.Intersect_analysis([inSMK, inNR], intersectOutput)

    # Process: dissolve SMK by fields NAM_lat and PSB
    outDiss = "outDiss"

    if arcpy.Exists(outDiss):


    # add new field to outDiss
    arcpy.AddField_management(outDiss, "Area_SMK", "DOUBLE")

    # copy values from Shape_area to new field
    arcpy.CalculateField_management(outDiss, "Area_SMK", "!Shape_Area!", "PYTHON_9.3")            

    # Process: define the field mapping for correct Spatial join
    fieldmappings = arcpy.FieldMappings()

    # Add all files from inputs

    # Name fields I want to keep
    keepers = ["NAM_lat", "PSB",  "Area_SMK", "Shape_Area", "Shape_length"]

    # Remove output fields I don't want
    for field in fieldmappings.fields:
        if field.name not in keepers:

    # Process: Spatial join the Shape_area of dissolved
    # SMK to the NR area
    outSpatJoin = "outJoin"

    if arcpy.Exists(outSpatJoin):

                               field_mapping = fieldmappings,
                               join_operation = "JOIN_ONE_TO_ONE",
                               match_option = "COMPLETELY_CONTAINS")

    print "intersected"

except Exception as err:

# clean up the data
  • Replace it by attribute join.
    – FelixIP
    Mar 7 '18 at 18:47
  • Please, be specific if using down vote. How to make question better?
    – maycca
    Mar 7 '18 at 22:21
  • When I down vote, I do it. Wrong address?
    – FelixIP
    Mar 8 '18 at 5:56
  • I wanted to try your approach, but then I figured that out by using "INTERSECT" instead of "COMPLETELY_CONTAINS" in 'match_option'
    – maycca
    Mar 8 '18 at 8:56

You are using "completely contains" and you have not defined a "keep all target features" parameter, the default is true. Not knowing your data my assumption would be that those nulls are polys that are not completely contained by your join features. Therefore they populate as null because spatial relationship you defined does not exist.

I had a similar problem with a script I was writing. I was unable to determine a way to force the output to maintain the input value when the spatial relationship was undefined (null). For my data I knew that I could modify the join feature to include all of my target features and avoid this problem. You are doing some pre-processing here so I doubt that would work for you. You could add another step to calculate nulls some other way. Maybe a For loop that rules out those features that are not "completely contains" but only a "Contains" or "intersect"

  • Seems, that it worked! As I have intersected my features earlier, the 'INTERSECT' was correct as 'match_option'. Thank you, I've spend so much time to solve it! :-D
    – maycca
    Mar 7 '18 at 22:22

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.