import arcpy,json
roadFC = r"C:\Users\Administrator\Desktop\s\data100\da.gdb\buslines"
stopFC = r"C:\Users\Administrator\Desktop\s\data100\da.gdb\busstops"
jsonFile = r"C:\Users\Administrator\Desktop\s\line.txt"
#spatial reference checking
if cmp(arcpy.Describe(roadFC).spatialReference.name,"GCS_WGS_1984") != 0:
raise Exception("buslines spatialreference error. not equal to 'GCS_WGS_1984'")
if cmp(arcpy.Describe(stopFC).spatialReference.name,"GCS_WGS_1984") != 0:
raise Exception("busstops spatialreference error. not equal to 'GCS_WGS_1984'")
#fileds checking
if len(arcpy.ListFields(roadFC))!=9:
raise Exception("buslines fields checking error")
if len(arcpy.ListFields(stopFC))!=4:
raise Exception("busstops fields checking error")
buslines = json.loads(open(jsonFile,'r').read())
curLine = arcpy.InsertCursor(roadFC)
curStop = arcpy.InsertCursor(stopFC)
count = 0
for busline in buslines:
lineArray = arcpy.Array()
for point in busline["points"]:
pnt = arcpy.Point()
pnt.X = point["lng"]
pnt.Y = point["lat"]
lineArray.add(pnt)
#buslines featureclass
feat = curLine.newRow()
feat.shape = lineArray
feat.name = busline["name"]
print busline["name"]
feat.startTime = busline["startTime"]
feat.endTime = busline["endTime"]
feat.company = busline["company"]
feat.stopsCount = busline["stopsCount"]
curLine.insertRow(feat)
lineArray.removeAll()
#busstops featureclass
for stop in busline["stops"]:
pnt = arcpy.Point()
pnt.X = stop["position"]["lng"]
pnt.Y = stop["position"]["lat"]
feat = curStop.newRow()
feat.shape = pnt
feat.name = stop["name"]
feat.lineName = busline["name"]
curStop.insertRow(feat)
arcpy.AddMessage("processing:"+busline["name"])
count+=1
del curStop,curLine
arcpy.AddMessage(str(count)+" lines processed.")
json 轉(zhuǎn)shp
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門翩剪,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人彩郊,你說我怎么就攤上這事前弯∥杷粒” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵博杖,是天一觀的道長椿胯。 經(jīng)常有香客問我,道長剃根,這世上最難降的妖魔是什么哩盲? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮狈醉,結(jié)果婚禮上廉油,老公的妹妹穿的比我還像新娘。我一直安慰自己苗傅,他們只是感情好抒线,可當(dāng)我...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著渣慕,像睡著了一般嘶炭。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上逊桦,一...
- 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼炬称!你這毒婦竟也來了汁果?” 一聲冷哼從身側(cè)響起,我...
- 正文 年R本政府宣布只洒,位于F島的核電站,受9級特大地震影響劳坑,放射性物質(zhì)發(fā)生泄漏毕谴。R本人自食惡果不足惜,卻給世界環(huán)境...
- 文/蒙蒙 一距芬、第九天 我趴在偏房一處隱蔽的房頂上張望涝开。 院中可真熱鬧,春花似錦框仔、人聲如沸舀武。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽银舱。三九已至,卻和暖如春跛梗,著一層夾襖步出監(jiān)牢的瞬間纵朋,已是汗流浹背。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 1藏澳、JSONString轉(zhuǎn)換為字典 2、字典轉(zhuǎn)換為JSONString
- 首先給大家?guī)砭W(wǎng)上常見的Json字符串轉(zhuǎn)字典狞悲,字典轉(zhuǎn)Json字符串代碼 Json字符串轉(zhuǎn)字典 字典轉(zhuǎn)Json字符串...
- 起因 后臺返回的JSON數(shù)據(jù)中摇锋,部分ID使用了一長串?dāng)?shù)字作為ID使用丹拯,但由于JS的number會伴隨精度丟失的問題...
- 假若一個功能模塊需要動態(tài)處理數(shù)據(jù)站超,就把這個功能模塊包在一個函數(shù)內(nèi)傳遞不同的參數(shù)進(jìn)去就行了