creating a shapefile from a multipart text file

579
2
08-22-2018 10:27 PM
brantleyallen
New Contributor

Hi.  I'm in a college class and I have a project to read several multi-part coordinate files and create shapefiles from them.
The file format I am given is below. 

I'm hung up on a few parts.

1: I can't bring the part name into a shapefile.  

2. I am unable to use the existing spatial reference.

If I take a set single set of coordinates and save them into a file I can make a shapefile with the following code, but under no circumstance can I work on the file as it has been provided. 

Can someone help me?

Brantley

Single part conversion.  working

    cursor = arcpy.da.InsertCursor(fc, ["SHAPE@"])
    array = arcpy.Array()
    point = arcpy.Point()
    for line in fileinput.input(infile1):
        point.ID, point.X, point.Y = line.split()
        array.add(point)
    polygon = arcpy.Polygon(array)
    cursor.insertRow([polygon])
    fileinput.close()
 

provided multipart text file.  unable to convert/import to a shapefile.

Work Completed on: 7_8_2014
Spatial Reference: 43006
Name: W_1
488597.653655, 4134910.76248
488813.848952, 4134609.01192
488904.303214, 4134480.54842
488938.462756, 4134422.3471
Name: E_1
496198.193041, 4134565.19994
496312.413827, 4134568.14182
496433.652036, 4134568.08923
496559.933558, 4134547.91561
496782.196397, 4134527.70636
496923.636101, 4134512.56252
Name: S_1
494434.480367, 4134742.03574
494610.098577, 4134679.72895
494726.29001, 4134689.71507
494872.793327, 4134704.71426
494963.626594, 4134548.72468
Name: N_1
494995.829828, 4135127.64541
494978.929114, 4135325.68215
494974.480425, 4135410.81948
495046.57052, 4135567.60122
495127.628495, 4135675.08887
495222.19606, 4135804.97093
495307.786759, 4135979.66167

Tags (1)
0 Kudos
2 Replies
LR
by
Occasional Contributor III

Why don't you just merge the txt files beforehand or merge the resulting point layers?

0 Kudos
brantleyallen
New Contributor

Merging the files doesn't give me an answer to my question, "How do I import a multipart coordinate file into a shapefile."  It only makes a bigger multipart file. 

0 Kudos