1

Occasionally NRCS will update their soils layer for each county. When they do, we get an email from our clients because they have been notified of the change. The problem is, sometimes it's just a metadata change. And we don't know until we run the full analysis and compare the soil types (MUSYM).

I'm trying to write a script that will compare the soils layer on file with the supposed "new" soils layer. If the unique values in the MUSYM field are the same for both features, I would like it to print "no new soils". If not, print "new soils added". The data is stored in a File Geodatabase. I'm using version 10.5 of Arcmap. I've looked through some of the other posts but I'm too green yet to figure this out.

import arcpy, os
arcpy.env.workspace = "H:\\SoilsUpdate\\SoilsUpdate.gdb"

#INPUTS:
fc1 = "R:\\State Soils\\gSSURGO_KS.gdb\\MUPOLYGON"

fc2 = "C:\\County\\Assessor.gdb\\NRCS\\Soils"

#set up cursors
cursor1 = arcpy.da.SearchCursor(fc1, ["MUSYM"])

cursor2 = arcpy.da.SearchCursor(fc2, ["MUSYM"])

#make a dictionary and store values
soil_lst = {}

for row in cursor1:
  soil_lst[row[0]] = row[1]

#loop through other table
for row in cursor2:

  if row[1] = soil_lst[row[0]]:

   soil_lst.append(row[0])

    print "no new soils".format(row[0])
  • Cursor 2 doesn't have 2 fields.. it looks like you want to declare with ['OID@','MUSYM'] as fields. What is the common field between existing data and updated data, do not make the mistake of thinking the rows will be in the same order, they might but might not. Have a look at Feature Compare resources.arcgis.com/en/help/main/10.2/index.html#//… and see if that might work for you. Does the data come as a file geodatabase or shapefile? File geodatabase OIDs cannot be used as list indexes as they're not guaranteed to be 0 based and contiguous. – Michael Stimson Nov 16 '17 at 22:00
  • This is probably a duplicate of gis.stackexchange.com/questions/153608 If you had seen that before posting your question then it should be explicitly linked rather than saying "I've looked through some of the other posts". – PolyGeo Nov 17 '17 at 0:14
  • 1
    The question somewhat over-simplifies the SSURGO data. A soil mapunit may be comprised of multiple component soils, each of which has multiple layers. Properties and interpretations are assigned to the mapunits, components, & layers, and are continuously being added and refined. Even if a polygon hasn't changed, the underlying properties associated with it may have changed significantly. (Full disclosure: I work for NRCS) – Bjorn Nov 17 '17 at 1:30
  • I did oversimplify. But for the purposes of this script, all that matter are the MUSYM poly's. Because when we run a property assessment analysis we use parcels, agtype, and soils MUSYM. – Chris Swanson Nov 20 '17 at 19:21
4

The ordering of the polygons in the MUPOLYGON feature class may change from one update to the next. Instead of doing a feature-to-feature comparison with cursors (trying to run 2 cursors simultaneously is generally considered a bad idea), I would Union the two feature classes, then search the results for polygons where the MUSYM values from the source feature classes differ.

  • Excellent idea Bjorn.. that way you can check attributes (at least he important ones) and geometries (either INPUT_FID = -1 indicating a geometry change). +1 from me. – Michael Stimson Nov 16 '17 at 22:35
  • A better field to use when making the comparison is MUKEY, especially when comparing features from multiple soil survey areas. Two soil surveys may use the same MUSYM, but it doesn't mean they are identical. The MUKEY is a truly unique identifier for each soil mapping unit nationwide. – Bjorn Nov 17 '17 at 15:25

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.