最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python中shapefile轉(zhuǎn)換geojson的示例

 更新時間:2019年01月03日 11:46:16   作者:staHuri  
今天小編就為大家分享一篇關(guān)于Python中shapefile轉(zhuǎn)換geojson的示例,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧

shapefile轉(zhuǎn)換geojson

import shapefile
import codecs
from json import dumps
# read the shapefile
def shp2geo(file="line出產(chǎn).shp"):
  reader = shapefile.Reader(file)
  fields = reader.fields[1:]
  field_names = [field[0] for field in fields]
  buffer = []
  for sr in reader.shapeRecords():
    record = sr.record
    record = [r.decode('gb2312', 'ignore') if isinstance(r, bytes)
         else r for r in record]
    atr = dict(zip(field_names, record))
    geom = sr.shape.__geo_interface__
    buffer.append(dict(type="Feature", geometry=geom, properties=atr))
    # write the GeoJSON file
  geojson = codecs.open(file.split('.')[0] + "-geo.json", "w", encoding="gb2312")
  geojson.write(dumps({"type": "FeatureCollection", "features": buffer}, indent=2) + "\n")
  geojson.close()
if __name__ == '__main__':
  # import os
  # for z,x,c in os.walk('.'):
  #   for zz in c:
  #     if zz.endswith(".shp"):
  #       shp2geo(zz)
  # shp2geo(file='D.shp')
  shp2geo(file='ttttttttttt.shp')

總結(jié)

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,謝謝大家對腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請查看下面相關(guān)鏈接

相關(guān)文章

最新評論

大兴区| 法库县| 麦盖提县| 桓台县| 天台县| 台江县| 胶州市| 远安县| 准格尔旗| 马公市| 潜江市| 邳州市| 通渭县| 漳平市| 沐川县| 虎林市| 壤塘县| 屯门区| 宝清县| 通许县| 巴塘县| 永兴县| 略阳县| 汉沽区| 昆明市| 西贡区| 富锦市| 嵊泗县| 西盟| 南京市| 石狮市| 红河县| 清流县| 昌平区| 剑川县| 滕州市| 东丽区| 安龙县| 乐亭县| 海伦市| 青海省|