最新国产好看的视频,伊人天堂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)文章

最新評論

乃东县| 信阳市| 玉田县| 德钦县| 上高县| 沙田区| 宁化县| 汉川市| 宿松县| 鸡东县| 军事| 伊金霍洛旗| 准格尔旗| 黄梅县| 阜城县| 准格尔旗| 卓资县| 铜川市| 驻马店市| 集安市| 榆林市| 华安县| 仁化县| 都匀市| 定陶县| 兴山县| 陇南市| 淮阳县| 阿克苏市| 德阳市| 永年县| 巴林右旗| 绥滨县| 永定县| 天台县| 定远县| 河西区| 山西省| 札达县| 天全县| 靖安县|