2

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?

Basically I want the info in the second column, to be broken into each, individual code to have its own polygon.

Codes

2 Answers 2

3

As there is only one geometry per object (row) you can create two new fields with the seperated values and just copy the shapefile and use the merge geoprocessing tool afterwards. This way the polygons are doubled and on top of each other if you really need that (normally you can just use the two fields with the different values for symbology, labels, selections and so on).

To calculate your new fields you use the the left and right functions in the field calculator to seperate the values (as your data looks very regular).

first part: left(your_field,7) second part: right(your_field,7)

1
  • Thank you! I am going to give it a try. I appreciate the response. Jul 4, 2017 at 13:14
0

After you create the empty field that you want to populate, go to 'Field Calculator' and type:

SourceField.split()[n]

'SourceField' is the name of your field where you have the long string you want to create fields from. split() will brake the field in text chunks, using the ' ' space character as a separator. [n] is an integer that allows you to pick which block you want in your new field. Say -for your FID4- [0] will pick 'N9B', [1] will pick '2T8'... and so on.

Make sure you click on the 'Python' button (not Visual Basic) on the Field Calculator dialogue.

2
  • 1
    If you need to break up by the ; as delimiter use this expression: field.split(";")[0] for one field and field.split(";")[1] for the next one.
    – Delonix R.
    Jun 28, 2017 at 19:03
  • Thank you! I am going to give it a try. I appreciate the response. Jul 4, 2017 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.