2016-08-09 6 views
-2

에 파일 "C : \ Users \ Brett \ Desktop \ Jefferson_final.py"파일 추적 (최근 호출 마지막) point = arcpy.Point (좌표 [0], [1]) IndexError 좌표 : 나는 x, y 좌표의 ashapefile을 txt에서 만들려고한다. 파일,하지만 다음과 같은 오류가 발생했습니다

범위

에서리스트 인덱스 것은 여기 내 스크립트 당신은 파일 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로 변환해야합니다.