Skip to content

Instantly share code, notes, and snippets.

Created February 21, 2023 21:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
LUCAS 2018 dataset as a GeoJSON file for simple and easy visualization -
#!/usr/bin/env python3
import sys
import csv
import json
import argparse
from pathlib import Path
def main(args):
print("reading csv from {}".format(args.input), file=sys.stderr)
geo = { "type": "FeatureCollection", "features": [] }
with as src:
reader = csv.DictReader(src)
for row in reader:
lat, lng = row["TH_LAT"], row["TH_LONG"]
geo["features"] += [{
"type": "Feature",
"properties": row,
"geometry": {
"coordinates": [ lng, lat ],
"type": "Point",
print("writing geojson to {}".format(args.out), file=sys.stderr)
with"w") as dst:
json.dump(geo, dst, indent=2)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("input", type=Path, help="path to lucas2018 .csv file")
parser.add_argument("-o", "--out", type=Path, required=True, help="path to .geojson output file")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment