Hello,
I have a file that contains a field with multiple pieces of attribute data for one entry. The data in the field is separated by a semi-colon.
I need to create a separate polygon for each attribute in that field. Is this even a possibility, or am I going to have to copy each polygon multiple times and delete the attributes I don't want from each entry?
I hope this makes sense. See the attached image...
Basically I want the info in the second column, to be broken into each, individual code to have its own polygon.
Thanks
Larisa
For ArcGIS 10.5, Split By Attributes—Help | ArcGIS Desktop
For earlier versions, Split Layer by Attributes - Dan Patterson
Thank you, but I did try this tool and it unfortunately does not give me the results I need. There is multiple pieces of data in one field and I need each piece of data made into it's own polygon. The data in the record is separated by a semi-colon.
thanks
No, it is just one polygon, (not a multipart polygon), with multiple pieces of data, seperated by semi colon. I am just not sure I am ready to manually create new polygons and attached data to them. I have an image I attached of what my attribute table looks like. So if we look at the first record (FID 0), you can see a column with N8T 3B5;N8T 3B6.... in this case I would need two polygons on top of each other, one with an attribute of N8T 3B5 and another with an attribute of N8T 3B6.
I am sure there is a model or script of something I can use to create such a beast...just can't wrap my head around how! lol!
you need to split the data in the field first, into two separate text columns. Then use those values from each field to create your polygons... twice, once using the first field and the second time using the second field. You can emulate this in the field calculator
a = 'N8T 3B5;N8T 3B6'
a.split(';')[0] # 'a' is your field name... split and take the first
Out[43]: 'N8T 3B5'
a.split(';')[-1] # ditto, but take the last
Out[44]: 'N8T 3B6'
Here are steps you can try:
1. Make a copy of the shapefile
2. Open the original shapefile and run the following Field Calculation (replace Name_Test with the correct field name):
This will return the first value in the field.
3. Run the Append tool and append the copied shapefile to the original shapefile
4. Run the following Field Calculation:
This will return the second value in the field.
Thank you Dan and Jake!
I figured it was a multistep process, I just could not get my head around how to start.
Thanks for the info. I am going to give it a try and get back to you!
I believe the following ArcPy code will work (I got it working on a polygon layer in a file geodatabase😞
fc = # Path to feature class
split_fld = # Field to split
split_delim = # Delimeter for splitting field
sys_flds = [
'OIDFieldName', 'globalIDFieldName',
'ShapeFieldName', 'areaFieldName', 'lengthFieldName'
]
desc = arcpy.Describe(fc)
sys_fld_names = [
name for name in (getattr(desc, fld, '') for fld in sys_flds) if name
]
usr_fld_names = [
fld.name for fld in desc.fields if fld.name not in [split_fld] + sys_fld_names
]
cur_flds = ["SHAPE@", split_fld] + usr_fld_names
with arcpy.da.Editor(desc.path) as edit:
with arcpy.da.UpdateCursor(fc, cur_flds) as ucur:
with arcpy.da.InsertCursor(fc, cur_flds) as icur:
for row in ucur:
shape = row.pop(0)
split = row.pop(0).split(split_delim)
for i in split[1:]:
icur.insertRow([shape, i] + row)
ucur.updateRow([shape, split[0]] + row)
del icur, ucur, edit