Last active
December 12, 2015 01:28
-
-
Save alexprengere/4691086 to your computer and use it in GitHub Desktop.
GeoBases visualize method used to display custom markers and lines on a map, *development version*.
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/python | |
# -*- coding: utf-8 -*- | |
""" | |
Drawing some lines between airports on a map. | |
""" | |
from GeoBases import GeoBase | |
def main(): | |
"""Main function. | |
""" | |
g = GeoBase('ori_por', verbose=False) | |
# 1) List of icons displayed | |
# 2) Icons for which data is not in the base | |
icons = ['ORY', 'NCE', 'MUC', 'MAD', 'BES'] | |
a_icons = [(48.7, 2.35)] | |
# 1) List of lines displayed | |
# 2) Lines for which data is not in the base | |
lines = [ | |
['ORY', 'NCE'], | |
['ORY', 'MAD'], | |
['ORY', 'MUC'], | |
['ORY', 'TLS'] # note that TLS has no marker | |
] | |
a_lines = [ | |
[(48.7, 2.35), (48.7, 2.25), (49.7, 2.35)] | |
] | |
g.visualize(output='the_gist', # name of the html output | |
icon_label='name', # field name is used for titles | |
icon_weight='page_rank', # circle size is based on page_rank | |
icon_color='country_code', # marker color is based on country_code | |
icon_type='auto', # icon size will be based on their number | |
from_keys=icons, # icons are specified from iterable of keys | |
add_lines=lines, # lines are specified from iterable of (key1, key2) | |
add_anonymous_icons=a_icons, # additional icons from geocodes | |
add_anonymous_lines=a_lines, # additional lines from geocodes | |
catalog=None, # keep the original catalog of colors for overriding | |
line_colors=('black', # override default line colors to settle argument | |
'white', # over color prettiness :) | |
'purple', | |
'green'), | |
link_duplicates=True) # draw lines from duplicates analysis | |
if __name__ == '__main__': | |
# Once this script has run, | |
# display your map with: | |
# $ firefox the_gist_map.html | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment