turicas/rows

Support shapefiles (SHP and GeoJSON)

開放

#343 建立於 2020年3月24日

 (0 則留言) (0 個反應) (0 位負責人)Python (136 個分叉)github user discovery
enhancementhelp wantedplugin

倉庫指標

星標
 (886 顆星)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

It woud be awesome to read/write from/to SHP and GeoJSON formats, so we can convert between SHP to GeoJSON, SHP to CSV, CSV to GeoJSON, CSV do SHP etc.

It's not that difficult: libraries such as fiona and shapely make the work easier - example from this post:

import csv
from shapely.geometry import Point, mapping
from fiona import collection

schema = { 'geometry': 'Point', 'properties': { 'name': 'str' } }
with collection(
    "some.shp", "w", "ESRI Shapefile", schema) as output:
    with open('some.csv', 'rb') as f:
        reader = csv.DictReader(f)
        for row in reader:
            point = Point(float(row['lon']), float(row['lat']))
            output.write({
                'properties': {
                    'name': row['name']
                },
                'geometry': mapping(point)
            })

貢獻者指南