Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle features with missing geometry #24

Closed
eyeseast opened this issue Jan 21, 2022 · 0 comments · Fixed by #27
Closed

Handle features with missing geometry #24

eyeseast opened this issue Jan 21, 2022 · 0 comments · Fixed by #27

Comments

@eyeseast
Copy link
Contributor

GeoJSON can be valid even if it's missing a geometry, but yield_records will throw a key error in that case:

def yield_records(features, pk, spatialite):
    for feature in features:
        record = {}
        if "id" in feature:
            record["id"] = feature["id"]
        record.update(feature.get("properties") or {})
        if spatialite:
            record["geometry"] = shape(feature["geometry"]).wkt
        else:
            record["geometry"] = feature["geometry"]
        yield record
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment