-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
6 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
|
||
# Created by https://www.toptal.com/developers/gitignore/api/python | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=python | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# poetry | ||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. | ||
# This is especially recommended for binary packages to ensure reproducibility, and is more | ||
# commonly ignored for libraries. | ||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control | ||
#poetry.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# PyCharm | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
## Python GeoJSON generator from telemetry GPS Coordinates | ||
|
||
*built in python 3* | ||
|
||
The multiline.geojson file contains the multiline for the entire path in the dataset, and can be uploaded as a layer for a custom style on mapbox. This was done to shorten the URL requests as there is an 8000 character limit. You can create your own mapbox style, the alter the geojsonrequest script and replace the "mitchelbourne/cl1......" with your own style. | ||
|
||
Packages used: geojson, json, os, requests, urllib, argparse | ||
|
||
1. Paste telemetry data into the data.json file | ||
2. Run the generategeojson python file to create the geojson files from the data set. | ||
3. Open the geojsonrequest and paste in your mapbox api key into the access_key variable | ||
4. Run the geojson request python file, this will generate the images into the images folder. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import json | ||
from geojson import Point | ||
import os | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
files_dir = 'geojson-files' | ||
|
||
parser.add_argument("-f", "--file", help="Telemetry Filename Including .json") | ||
args = parser.parse_args() | ||
|
||
# Find the samples value in dict | ||
def find_by_key(data, target): | ||
for key, value in data.items(): | ||
if isinstance(value, dict): | ||
yield from find_by_key(value, target) | ||
elif key == target: | ||
yield value | ||
|
||
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") | ||
exit() | ||
|
||
with open(f'./{args.file}') as json_file: | ||
data = json.load(json_file) | ||
linestring = [] | ||
|
||
for x in find_by_key(data, "samples"): | ||
data = x | ||
|
||
for x in data: | ||
linestring.append( | ||
[x['GPS (Lat.) [deg]'], x['GPS (Long.) [deg]']] | ||
) | ||
|
||
try: | ||
os.mkdir(f"./{files_dir}") | ||
except OSError as error: | ||
print(error) | ||
|
||
for index, x in enumerate(data): | ||
f = open(f"./{files_dir}/{index:06}.geojson", "x") | ||
|
||
filedata = f'{{"type": "Point","coordinates": {[x["GPS (Lat.) [deg]"], x["GPS (Long.) [deg]"]]}}}' | ||
f.write(filedata) | ||
f.close() | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import json | ||
import requests | ||
import urllib.parse | ||
import os | ||
|
||
files_dir = 'geojson-files' | ||
images_dir = 'mapbox-images' | ||
# Paste in an access token here | ||
access_token = "" | ||
|
||
def main(): | ||
index = 0 | ||
try: | ||
os.mkdir(f"./{images_dir}") | ||
except OSError as error: | ||
print(error) | ||
|
||
for filename in os.listdir(files_dir): | ||
with open(f'./{files_dir}/{index:06}.geojson') as json_file: | ||
data = json.load(json_file) | ||
xcoord = data["coordinates"][0] | ||
ycoord = data["coordinates"][1] | ||
|
||
encodeddata = urllib.parse.quote(json.dumps(data), safe='') | ||
|
||
r = requests.get(f"https://api.mapbox.com/styles/v1/mitchelbourne/cl1jw3qpv005014q4s04zfzea/static/geojson({encodeddata})/{xcoord}, {ycoord},17/500x300?access_token={access_token}") | ||
|
||
if r.status_code == 200: | ||
with open(f"./{images_dir}/{index:06}.png", 'wb') as f: | ||
f.write(r.content) | ||
f.close() | ||
print(f"Fetched image: {index}") | ||
else: | ||
print("Failed to fetch image with status code: ", r.status_code) | ||
index += 1 | ||
|
||
if __name__ == '__main__': | ||
main() |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.