由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
GeoSpace版 - ArcGIS问题求助
相关主题
ArcMap9.2: how to make county map from USA map?gis/rs能创业吗?
这里就没有讨论ArcGIS的么?求助:如何用ArcGIS进行河流侵蚀风险的分析
AO 开发之 如何创建定制的工具条(Tool Bar) zz求助如何取得elevation信息
AO 开发之 如何创建定制的MultiItem zzhow to overlay two different maps? Thanks a lot.
现在常用的GIS软件都有哪些??HELP: do any of you know how to use ArcGIS (转载)
[合集] 现在常用的GIS软件都有哪些??请问GIS软件好学吗
还有人用IDRISI么?问一个GIS问题 (转载)
问一个ArcGIS的问题开发基于ArcGIS的程序
相关话题的讨论汇总
话题: twops话题: mypoints话题: costdic1话题: lyrname
进入GeoSpace版参与讨论
1 (共1页)
f*****c
发帖数: 3257
1
我有美国road shape file和全美500个城市的longtitude and latitude。
现在需要计算每对城市之间的road distance.
我从网上找的办法是用python写code,可是总是出错。
各位大神帮忙看一下 。由于没有时间变量,所以里面关于时间的我都给省去了
import arcpy, os, sys
arcpy.env.overwriteOutput = True
try:
# costDic1 = {}
f = open(r"C:UsersUserDocumentsArcGISindia.txt", 'r+')
layer1 = "Route" #an open in-memory layer

for line in f:
twoPs = line.split(",")

# if the line contains number
if twoPs[0].isdigit():
OPoint = arcpy.Point()
DPoint = arcpy.Point()
pointGeometryList = []

OPoint.X = twoPs[1]
OPoint.Y = twoPs[2]
DPoint.X = twoPs[3]
DPoint.Y = twoPs[4]
pointGeometry = arcpy.PointGeometry(OPoint)
pointGeometryList.append(pointGeometry)
pointGeometry = arcpy.PointGeometry(DPoint)
pointGeometryList.append(pointGeometry)
myPoints = "Mypoints"
arcpy.CopyFeatures_management(pointGeometryList, myPoints)
arcpy.na.AddLocations(layer1,"Stops",myPoints)
arcpy.Solve_na(layer1)

# get the cost info from the layer
# rows = arcpy.SearchCursor(lyrName + "\Routes")
# for row in rows:
# costDic1[twoPs[0]] = row.Total_TravelTime

# delete stops and route from the layer
arcpy.DeleteRows_management(lyrName + "\Stops")
arcpy.DeleteRows_management(lyrName + "\Routes")
f.close

# Output the result to a txt file
fOut = open(r"C:UsersUserDocumentsArcGISOut.txt", 'w')
# for costKey in costDic1.keys():
# line = str(costKey) + "," + str(costDic1[costKey])
# fOut.writelines(line)
fOut.close
except:
print "NO RESULTS"
1 (共1页)
进入GeoSpace版参与讨论
相关主题
开发基于ArcGIS的程序现在常用的GIS软件都有哪些??
有人做ArcGIS Server吗[合集] 现在常用的GIS软件都有哪些??
ESRI UC 08还有人用IDRISI么?
初级GIS求助,如何计算点到polygon的最短距离?问一个ArcGIS的问题
ArcMap9.2: how to make county map from USA map?gis/rs能创业吗?
这里就没有讨论ArcGIS的么?求助:如何用ArcGIS进行河流侵蚀风险的分析
AO 开发之 如何创建定制的工具条(Tool Bar) zz求助如何取得elevation信息
AO 开发之 如何创建定制的MultiItem zzhow to overlay two different maps? Thanks a lot.
相关话题的讨论汇总
话题: twops话题: mypoints话题: costdic1话题: lyrname