We are working with parcel data that includes a single polygon for each individual tax parcel. We need to develop a list that includes an attribute for each residential address. Some tax parcels could have multiple residential addresses, e.g. condos, apartments, etc. Although this could be done in a spreadsheet, it would likely be time consuming. The though is to copy each polygon x number of times dependent on the number of units in order to begin this list, this would allow for all the attribute data to be copied as well. In researching a way to do this is we came across Exploding features based on numerical field in QGIS?. I provides a Python script and minimal directions to run the script.The script is as follows:
layer.startEditing()
for f in layer.getFeatures():
# Create X-1 new features since we already have the original
for i in range(f['X']-1):
layer.addFeature(f)
layer.commitChanges()
I am actually trying to replicate this in ArcGIS. I have translated this to the following:
import arcpy
mxd = arcpy.mapping.MapDocument(r"G:\LUCA_2020\WorkingMap_4.19.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "newburgh_city_parcels_master_april2012_joinRPS", df)[0]
lyrfile = arcpy.mapping.layer(r"G:\GIS_Chad\Scratch\Delete\test.lyr")
arcpy.mapping.UpdateLayer(df, lyr, lyrfile, True)
layer.startEditing('newburgh_city_parcels_master_april2012_joinRPS')
for f in layer.getFeatures('total_units'):
# Create X-1 new features since we already have the original
for i in range(f['X']-1):
layer.addFeature(f)
layer.commitChanges('newburgh_city_parcels_master_april2012_joinRPS')
When I run the script in the Python window, i get the following error:
Runtime error
Traceback (most recent call last):
File "<string>", line 5, in <module>
AttributeError: 'module' object has no attribute 'layer'
I assume there may be other, put I am not sure. I am looking for guidance on correcting and running the script in ArcGIS 10.3.


lyr = arcpy.mapping.Layer(r'C:\Project\Data\Time\TemperatureWithTime.lyr')– SMiller Apr 20 '18 at 15:05