Hi All -
We're working on scripting the export (via python) of parcel fabric layers so we can push them through our data publishing workflow. We're not having any trouble doing this, but now we'd like to export the "Lots and Units" layer to a Feature Class, but with the Parcel Id # included in the output Feature Class (it's not in this layer by default).
Does anyone have experience python scripting custom exports of parcel fabric layers?
Thanks!
-Mike Knapp
Aloha Mike,
I am doing something similar to what Frank suggested (spatial join) but for updating the SEWERSERV attribute of the Parcel Publishing feature class, which is going to be similar to what you are looking to do with the Parcel ID#. The following function lives in the same script that builds the Tax Parcel FC that is in the Parcel Publishing FDs, hence, why only one argument to the function (sorry, about the lack of formatting, I tried to manually format it):
# Begin updateSewerserv function to calculate Sewerserv attribute of Parcel Publishing feature class
def updateSewerserv(tax_parcels):
arcpy.AddMessage("Starting updateSewerserv() function...")
# source feature
sourceFeature = r'<UPDATE THIS PATH TO YOUR PARCEL PUBLISHING TAX PARCEL LAYER>'
# source field
sourceField = r'Type'
# target feature
targetFeature = tax_parcels
# target field
targetField = r'<UPDATE THIS TO YOUR ATTRIBUTE>'
# overlap type
# overlap_type options ["WITHIN_A_DISTANCE_GEODESIC", "WITHIN_A_DISTANCE", "WITHIN_A_DISTANCE_3D", "INTERSECT", "INTERSECT_3D", "HAVE_THEIR_CENTER_IN", "CONTAINS", "WITHIN"]
overlap_type= r'HAVE_THEIR_CENTER_IN'
workSpace = targetFeature
arcpy.env.workspace = workSpace
oid = "OBJECTID"
tmpSrcLayer = "in_memory\\tmpSource"
targetLayer = "in_memory\\tmpTarget"
if arcpy.Exists(tmpSrcLayer):
arcpy.Delete_management(tmpSrcLayer)
if arcpy.Exists(targetLayer):
arcpy.Delete_management(targetLayer)
with arcpy.da.SearchCursor(sourceFeature, [oid,sourceField]) as cursorSearch:
for row in cursorSearch:
arcpy.MakeFeatureLayer_management(targetFeature, targetLayer)
arcpy.MakeFeatureLayer_management(sourceFeature, tmpSrcLayer, where_clause = oid + " = " + str(row[0]))
arcpy.SelectLayerByLocation_management (targetLayer, overlap_type=overlap_type, select_features = tmpSrcLayer, selection_type = "NEW_SELECTION")
updateCount = arcpy.GetCount_management(targetLayer)
with arcpy.da.UpdateCursor(targetLayer,targetField) as cursorUpdate:
for row2 in cursorUpdate:
if row[1] == None:
pass
else:
row2[0] = row[1]
cursorUpdate.updateRow(row2)
del row2
arcpy.AddMessage(str(updateCount)+ " features in "+ targetFeature+ "'s field '"+targetField+"' updated to: "+str(row[1]))
del cursorUpdate
del row
del cursorSearch
arcpy.Delete_management(tmpSrcLayer)
del tmpSrcLayer
arcpy.Delete_management(targetLayer)
del targetLayer
# End updateSewerserv function
I'd be happy to send you the full script is you'd like.
Mahalo!
Dan Sereno
GIS Manager
County of Maui
Hi Dan... just wanted to say thanks for sharing this!