turicas/rows

Support shapefiles (SHP and GeoJSON)

Offen

#343 geöffnet am 24.03.2020

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Python (136 Forks)github user discovery
enhancementhelp wantedplugin

Repository-Metriken

Stars
 (886 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

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)
            })

Contributor Guide