Skip to content

Commit

Permalink
Multiline geojson generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchelbourne committed Apr 7, 2022
1 parent 788fe95 commit 967a832
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions generategeojson.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ def find_by_key(data, target):
elif key == target:
yield value

def generate_multiline_geojson(data):
mutiline = []
filedata = ''

for index, x in enumerate(data[1::2]):
mutiline.append([[data[index]["GPS (Lat.) [deg]"], data[index]["GPS (Long.) [deg]"]],[data[index + 1]["GPS (Lat.) [deg]"], data[index + 1]["GPS (Long.) [deg]"]]])

filedata = f'{{"type": "FeatureCollection","features": [{{"type": "Feature","geometry": {{"type": "MultiLineString","coordinates": {mutiline}}},"properties": {{"prop0": "value0"}}}}]}}'

f = open(f"./multiline.geojson", "w")
f.write(filedata)
f.close()

def main():
if not args.file:
print("Please provide the telemetry filename (in base directory) using the -f flag, e.g. python3 generategeojson.py -f mytelemetry.json")
Expand All @@ -39,6 +52,8 @@ def main():
except OSError as error:
print(error)

generate_multiline_geojson(data)

for index, x in enumerate(data):
f = open(f"./{files_dir}/{index:06}.geojson", "x")

Expand Down
Empty file added multiline.geojson
Empty file.

0 comments on commit 967a832

Please sign in to comment.