-
-
Save manuelep/a81d56f5e69ec60085b19abc4b107eec to your computer and use it in GitHub Desktop.
test_map.py
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import argparse | |
from swissknife.script import common_setup | |
import plotly.graph_objs as go | |
import plotly.io as pio | |
parser = argparse.ArgumentParser( | |
description = """ | |
""", | |
formatter_class = argparse.RawTextHelpFormatter, | |
conflict_handler = 'resolve', | |
prefix_chars = '-+' | |
) | |
parser.add_argument("-p", "--port", | |
help = """Orca port""", | |
type = int | |
) | |
parser.add_argument("-t", "--token", | |
help = """Mapbox Token""", | |
default = 'pk.eyJ1IjoiY29sb3VyZWUiLCJhIjoiY2phbWp4cnkwNDI0dDMzcjFwY2hybGN4MiJ9.Zke-1vfMlfaCvGTICQwxDw' | |
) | |
parser.add_argument("--print-json", | |
help = """Print json""", | |
action = 'store_true', | |
default = False, | |
dest = 'print_json' | |
) | |
args, logger = common_setup(parser) | |
if not args.port is None: | |
pio.orca.config.port = 8005 | |
pio.orca.config.mapbox_access_token = args.token | |
#orca serve | |
def get_input_data(): | |
data = [ | |
go.Scattermapbox( | |
lat=['45.5017'], | |
lon=['-73.5673'], | |
mode='markers', | |
marker=dict( | |
size=14 | |
), | |
text=['Montreal'], | |
) | |
] | |
layout = go.Layout( | |
autosize=True, | |
hovermode='closest', | |
mapbox=dict( | |
accesstoken=args.token, | |
bearing=0, | |
center=dict( | |
lat=45, | |
lon=-73 | |
), | |
pitch=0, | |
zoom=5 | |
), | |
) | |
return vars() | |
if __name__ == '__main__': | |
fig = get_input_data() | |
#write json with plotly.io | |
if args.print_json: | |
pio.write_json(fig, 'figure.json', pretty=True) | |
pio.write_image(fig, 'figure.png') | |
#TERMINAL | |
# orca graph figure.json --mapbox-access-token pk.eyJ1IjoiY29sb3VyZWUiLCJhIjoiY2phbWp4cnkwNDI0dDMzcjFwY2hybGN4MiJ9.Zke-1vfMlfaCvGTICQwxDw -o figure.png --verbose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment