2016-08-09 2 views
-2

ファイル: "C:\ Users \ Brett \ Desktop \ Jefferson_final.py"、行31、 の中のトレースバック(最近の呼び出し最後)point = arcpy.Point(coordinate [0]、座標[1]) はIndexError:範囲私はtxtからx、y座標のashapefileを作成しようとしています。ファイルが、次のエラーが発生しています

のうちリストインデックスは、ここでは、ファイルINPUT_DATAを開くと、それは、データを分割からの入力データを読んでいない私のスクリプト

import arcpy 
import fileinput 
import os 
import string 
arcpy.env.workspace = "C:\Users\Brett\Desktop\San Clemente" 
arcpy.env.overwriteOutput = True 

outFolder = "C:\Users\Brett\Desktop\San Clemente" 
output = open("result.txt", "w") 
fc = "metersSC1.shp" 
inputFile = "C:\Users\Brett\Desktop\San Clemente\San Clemente Lat Long.txt" 
name = "" 

for line in inputFile: 
    lineSegment = line.split(": ") 
    if lineSegment[0]== "spatialReference": 
     spatRef = spatRef = arcpy.SpatialReference(26946) 
     arcpy.CreateFeatureclass_management(outFolder, fc, "POINT", "", "", "", spatRef) 
    arcpy.AddField_management(fc, "NAME", "TEXT") 
    cursor = arcpy.da.InsertCursor(fc, ["","[email protected]"]) 
    array = arcpy.Array() 
elif lineSegment[0] =="NAME": 
    if len(array) > 0: 
     polygon = arcpy.Polygon(pointList) 
     cursor.insertRow((name,polygon)) 

     name = lineSegment[0] 

else: 
    coordinate = line.split(",") 
    point = arcpy.Point(coordinate[0],coordinate[1]) 
    pointList.add(point) 



polygon = arcpy.Polygon(array) 
cursor.insertRow((name, polygon)) 

print "COORDINATES ADDED" 

答えて

2

です。

inputname = r"C:\Users\Brett\Desktop\San Clemente\San Clemente Lat Long.txt" 
inputdata = [l.spilt(',') for l in open(inputname).readlines()] 

はさらにあなたを取得する必要があります - あなたはまた、彼らが開始するための文字列になります数値にX & yの変換する必要があります。

関連する問題