2021-03-27T09:56:38,586 Created temporary directory: /tmp/pip-ephem-wheel-cache-1z2ddyx9 2021-03-27T09:56:38,590 Created temporary directory: /tmp/pip-req-tracker-apuml9s1 2021-03-27T09:56:38,590 Initialized build tracking at /tmp/pip-req-tracker-apuml9s1 2021-03-27T09:56:38,590 Created build tracker: /tmp/pip-req-tracker-apuml9s1 2021-03-27T09:56:38,591 Entered build tracker: /tmp/pip-req-tracker-apuml9s1 2021-03-27T09:56:38,591 Created temporary directory: /tmp/pip-wheel-acl1jbkj 2021-03-27T09:56:38,632 1 location(s) to search for versions of py-staticmaps: 2021-03-27T09:56:38,632 * https://pypi.org/simple/py-staticmaps/ 2021-03-27T09:56:38,632 Fetching project page and analyzing links: https://pypi.org/simple/py-staticmaps/ 2021-03-27T09:56:38,633 Getting page https://pypi.org/simple/py-staticmaps/ 2021-03-27T09:56:38,635 Found index url https://pypi.org/simple 2021-03-27T09:56:38,734 Found link https://files.pythonhosted.org/packages/c1/37/92e15225fa11747d61ad303391a6f4a37f24ef272cfee63e712b0cf080e7/py-staticmaps-0.0.1.tar.gz#sha256=71d68975dd0443f6b925eb55f4203671bd84e565e4e8cba3ee1afb94efb46a98 (from https://pypi.org/simple/py-staticmaps/), version: 0.0.1 2021-03-27T09:56:38,735 Found link https://files.pythonhosted.org/packages/a1/98/00d2f6057cf2f541ccf796f5a3847713e9dc51251d7d4554f9caad338d47/py-staticmaps-0.0.2.tar.gz#sha256=cfed70f9b0a2c8130ad4ee73c709763dbae570f75ca038aec8d0242778c7be4f (from https://pypi.org/simple/py-staticmaps/), version: 0.0.2 2021-03-27T09:56:38,735 Found link https://files.pythonhosted.org/packages/e0/53/00551e1cfb8612c4dc0b6e76c7ed776513155245586799d789e4379c3f35/py-staticmaps-0.1.0.tar.gz#sha256=a500406520db2a2754d71824b1b14da5d5eac3731d6059108c686ca9fbf08568 (from https://pypi.org/simple/py-staticmaps/), version: 0.1.0 2021-03-27T09:56:38,735 Found link https://files.pythonhosted.org/packages/c8/cf/d25eb225616779dcec60a5f57f858e0437ac67e8dab8bb97635e02407167/py-staticmaps-0.1.1.tar.gz#sha256=0efe19b1f3bf35283d9aaa0f485bf5f56d9c97c71e5a8ae9190f3ef452bd7bc6 (from https://pypi.org/simple/py-staticmaps/), version: 0.1.1 2021-03-27T09:56:38,736 Found link https://files.pythonhosted.org/packages/92/12/9014b674db3a0a17fe7317d051644bd4a5243f222bc8fa9ab9f3bcc8d330/py-staticmaps-0.2.0.tar.gz#sha256=9043c59e27d419c75e6a8ccdd55d844a20071b796e9dab2ae904fe29c2b1c3bf (from https://pypi.org/simple/py-staticmaps/), version: 0.2.0 2021-03-27T09:56:38,736 Found link https://files.pythonhosted.org/packages/8f/e2/28896c344c786088c7d7ca18f4cf95e3491a37a010f44e398df38224b274/py-staticmaps-0.2.2.tar.gz#sha256=adabc734cbe0ccf904cab17c64b838b83f6264098f9fa39e84c567e4576ffabe (from https://pypi.org/simple/py-staticmaps/), version: 0.2.2 2021-03-27T09:56:38,736 Found link https://files.pythonhosted.org/packages/03/1e/a86e19c1efd133e21d8b541359a15592807d128582147f89539da6529cab/py-staticmaps-0.2.3.tar.gz#sha256=ea54d361350bae1ba7ec2f94389e4582e177fdf6d1d8d37594249d834edf6029 (from https://pypi.org/simple/py-staticmaps/), version: 0.2.3 2021-03-27T09:56:38,737 Found link https://files.pythonhosted.org/packages/42/e3/deeb3dece94a3b1b36206087677f5937a71a146c91b9616873bdda182822/py-staticmaps-0.3.0.tar.gz#sha256=df0474d4e7f8ee2134d08a4747808bad4b56fe7625b7e0bac35cf637b05d2ce1 (from https://pypi.org/simple/py-staticmaps/), version: 0.3.0 2021-03-27T09:56:38,737 Found link https://files.pythonhosted.org/packages/f9/22/efa565521b37c3cf8b64c6a2c7a3631efae15724231e23c9fd37623df7ef/py-staticmaps-0.4.0.tar.gz#sha256=5aba5ad59f30a63f860e76ed99407a6efb24eaad5c8997aa8617363989f17389 (from https://pypi.org/simple/py-staticmaps/), version: 0.4.0 2021-03-27T09:56:38,752 Given no hashes to check 1 links for project 'py-staticmaps': discarding no candidates 2021-03-27T09:56:38,767 Collecting py-staticmaps==0.4.0 2021-03-27T09:56:38,769 Created temporary directory: /tmp/pip-unpack-5n24pb05 2021-03-27T09:56:38,810 Downloading py-staticmaps-0.4.0.tar.gz (21 kB) 2021-03-27T09:56:38,925 Added py-staticmaps==0.4.0 from https://files.pythonhosted.org/packages/f9/22/efa565521b37c3cf8b64c6a2c7a3631efae15724231e23c9fd37623df7ef/py-staticmaps-0.4.0.tar.gz#sha256=5aba5ad59f30a63f860e76ed99407a6efb24eaad5c8997aa8617363989f17389 to build tracker '/tmp/pip-req-tracker-apuml9s1' 2021-03-27T09:56:38,927 Running setup.py (path:/tmp/pip-wheel-acl1jbkj/py-staticmaps_57c1eb342e774cfda46f2fe8515ae213/setup.py) egg_info for package py-staticmaps 2021-03-27T09:56:38,928 Created temporary directory: /tmp/pip-pip-egg-info-h2yx965i 2021-03-27T09:56:38,928 Running command python setup.py egg_info 2021-03-27T09:56:39,989 # py-staticmaps 2021-03-27T09:56:39,990 A python module to create static map images (PNG, SVG) with markers, geodesic lines, etc. 2021-03-27T09:56:39,990 ## Features 2021-03-27T09:56:39,991 - Map objects: pin-style markers, image (PNG) markers, polylines, polygons, (geodesic) circles 2021-03-27T09:56:39,991 - Automatic computation of best center + zoom from the added map objects 2021-03-27T09:56:39,991 - Several pre-configured map tile providers 2021-03-27T09:56:39,992 - Proper tile provider attributions display 2021-03-27T09:56:39,992 - On-disc caching of map tile images for faster drawing and reduced load on the tile servers 2021-03-27T09:56:39,992 - Non-anti-aliased drawing via `PILLOW` 2021-03-27T09:56:39,992 - Anti-aliased drawing via `pycairo` (optional; only if `pycairo` is installed properly) 2021-03-27T09:56:39,992 - SVG creation via `svgwrite` 2021-03-27T09:56:39,993 ## Installation 2021-03-27T09:56:39,994 ### SVG + non-anti-aliased PNG version 2021-03-27T09:56:39,994 ```shell 2021-03-27T09:56:39,995 pip install py-staticmaps 2021-03-27T09:56:39,995 ``` 2021-03-27T09:56:39,995 ### SVG + anti-aliased PNG version (via Cairo) 2021-03-27T09:56:39,996 ```shell 2021-03-27T09:56:39,996 pip install py-staticmaps[cairo] 2021-03-27T09:56:39,996 ``` 2021-03-27T09:56:39,997 `py-staticmaps` uses `pycairo` for creating anti-aliased raster-graphics, so make sure `libcairo2` is installed on your system (on Ubuntu just install the `libcairo2-dev` package, i.e. `sudo apt install libcairo2-dev`). 2021-03-27T09:56:39,997 ## Examples 2021-03-27T09:56:39,998 Note: PNG support (e.g. `context.render_cairo(...)`) is only available if the `pycairo` module is installed. 2021-03-27T09:56:39,998 ### Markers and Geodesic Lines 2021-03-27T09:56:39,999 ```python 2021-03-27T09:56:39,999 import staticmaps 2021-03-27T09:56:39,999 context = staticmaps.Context() 2021-03-27T09:56:40,000 context.set_tile_provider(staticmaps.tile_provider_StamenToner) 2021-03-27T09:56:40,000 frankfurt = staticmaps.create_latlng(50.110644, 8.682092) 2021-03-27T09:56:40,000 newyork = staticmaps.create_latlng(40.712728, -74.006015) 2021-03-27T09:56:40,001 context.add_object(staticmaps.Line([frankfurt, newyork], color=staticmaps.BLUE, width=4)) 2021-03-27T09:56:40,001 context.add_object(staticmaps.Marker(frankfurt, color=staticmaps.GREEN, size=12)) 2021-03-27T09:56:40,001 context.add_object(staticmaps.Marker(newyork, color=staticmaps.RED, size=12)) 2021-03-27T09:56:40,002 # render non-anti-aliased png 2021-03-27T09:56:40,002 image = context.render_pillow(800, 500) 2021-03-27T09:56:40,002 image.save("frankfurt_newyork.pillow.png") 2021-03-27T09:56:40,002 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:40,003 image = context.render_cairo(800, 500) 2021-03-27T09:56:40,003 image.write_to_png("frankfurt_newyork.cairo.png") 2021-03-27T09:56:40,003 # render svg 2021-03-27T09:56:40,003 svg_image = context.render_svg(800, 500) 2021-03-27T09:56:40,004 with open("frankfurt_newyork.svg", "w", encoding="utf-8") as f: 2021-03-27T09:56:40,004 svg_image.write(f, pretty=True) 2021-03-27T09:56:40,004 ``` 2021-03-27T09:56:40,005 ### Transparent Polygons 2021-03-27T09:56:40,005 ```python 2021-03-27T09:56:40,006 import staticmaps 2021-03-27T09:56:40,006 context = staticmaps.Context() 2021-03-27T09:56:40,006 context.set_tile_provider(staticmaps.tile_provider_OSM) 2021-03-27T09:56:40,007 freiburg_polygon = [ 2021-03-27T09:56:40,007 (47.96881, 7.79045), 2021-03-27T09:56:40,007 (47.96866, 7.78610), 2021-03-27T09:56:40,007 (47.97134, 7.77874), 2021-03-27T09:56:40,008 ... 2021-03-27T09:56:40,008 ] 2021-03-27T09:56:40,008 context.add_object( 2021-03-27T09:56:40,008 staticmaps.Area( 2021-03-27T09:56:40,009 [staticmaps.create_latlng(lat, lng) for lat, lng in freiburg_polygon], 2021-03-27T09:56:40,009 fill_color=staticmaps.parse_color("#00FF003F"), 2021-03-27T09:56:40,009 width=2, 2021-03-27T09:56:40,009 color=staticmaps.BLUE, 2021-03-27T09:56:40,009 ) 2021-03-27T09:56:40,010 ) 2021-03-27T09:56:40,010 # render non-anti-aliased png 2021-03-27T09:56:40,010 image = context.render_pillow(800, 500) 2021-03-27T09:56:40,010 image.save("freiburg_area.pillow.png") 2021-03-27T09:56:40,011 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:40,011 image = context.render_cairo(800, 500) 2021-03-27T09:56:40,011 image.write_to_png("freiburg_area.cairo.png") 2021-03-27T09:56:40,011 # render svg 2021-03-27T09:56:40,012 svg_image = context.render_svg(800, 500) 2021-03-27T09:56:40,012 with open("freiburg_area.svg", "w", encoding="utf-8") as f: 2021-03-27T09:56:40,012 svg_image.write(f, pretty=True) 2021-03-27T09:56:40,012 ``` 2021-03-27T09:56:40,013 ### Drawing a GPX Track + Image Marker (PNG) 2021-03-27T09:56:40,013 ```python 2021-03-27T09:56:40,014 import sys 2021-03-27T09:56:40,014 import gpxpy 2021-03-27T09:56:40,014 import staticmaps 2021-03-27T09:56:40,014 context = staticmaps.Context() 2021-03-27T09:56:40,015 context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery) 2021-03-27T09:56:40,015 with open(sys.argv[1], "r") as file: 2021-03-27T09:56:40,015 gpx = gpxpy.parse(file) 2021-03-27T09:56:40,016 for track in gpx.tracks: 2021-03-27T09:56:40,016 for segment in track.segments: 2021-03-27T09:56:40,016 line = [staticmaps.create_latlng(p.latitude, p.longitude) for p in segment.points] 2021-03-27T09:56:40,016 context.add_object(staticmaps.Line(line)) 2021-03-27T09:56:40,016 for p in gpx.walk(only_points=True): 2021-03-27T09:56:40,017 pos = staticmaps.create_latlng(p.latitude, p.longitude) 2021-03-27T09:56:40,017 marker = staticmaps.ImageMarker(pos, "start.png", origin_x=27, origin_y=35) 2021-03-27T09:56:40,017 context.add_object(marker) 2021-03-27T09:56:40,017 break 2021-03-27T09:56:40,017 # render non-anti-aliased png 2021-03-27T09:56:40,018 image = context.render_pillow(800, 500) 2021-03-27T09:56:40,018 image.save("draw_gpx.pillow.png") 2021-03-27T09:56:40,018 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:40,018 image = context.render_cairo(800, 500) 2021-03-27T09:56:40,019 image.write_to_png("draw_gpx.cairo.png") 2021-03-27T09:56:40,019 ``` 2021-03-27T09:56:40,019 ### US State Capitals 2021-03-27T09:56:40,020 ```python 2021-03-27T09:56:40,020 import json 2021-03-27T09:56:40,020 import requests 2021-03-27T09:56:40,020 import staticmaps 2021-03-27T09:56:40,021 context = staticmaps.Context() 2021-03-27T09:56:40,021 context.set_tile_provider(staticmaps.tile_provider_OSM) 2021-03-27T09:56:40,021 URL = ( 2021-03-27T09:56:40,021 "https://gist.githubusercontent.com/jpriebe/d62a45e29f24e843c974/" 2021-03-27T09:56:40,022 "raw/b1d3066d245e742018bce56e41788ac7afa60e29/us_state_capitals.json" 2021-03-27T09:56:40,022 ) 2021-03-27T09:56:40,022 response = requests.get(URL) 2021-03-27T09:56:40,022 for _, data in json.loads(response.text).items(): 2021-03-27T09:56:40,022 capital = staticmaps.create_latlng(float(data["lat"]), float(data["long"])) 2021-03-27T09:56:40,023 context.add_object(staticmaps.Marker(capital, size=5)) 2021-03-27T09:56:40,023 # render non-anti-aliased png 2021-03-27T09:56:40,023 image = context.render_pillow(800, 500) 2021-03-27T09:56:40,023 image.save("us_capitals.pillow.png") 2021-03-27T09:56:40,024 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:40,024 image = context.render_cairo(800, 500) 2021-03-27T09:56:40,024 image.write_to_png("us_capitals.cairo.png") 2021-03-27T09:56:40,024 ``` 2021-03-27T09:56:40,025 ### Geodesic Circles 2021-03-27T09:56:40,025 ```python 2021-03-27T09:56:40,025 import staticmaps 2021-03-27T09:56:40,026 context = staticmaps.Context() 2021-03-27T09:56:40,026 context.set_tile_provider(staticmaps.tile_provider_StamenToner) 2021-03-27T09:56:40,026 center1 = staticmaps.create_latlng(66, 0) 2021-03-27T09:56:40,026 center2 = staticmaps.create_latlng(0, 0) 2021-03-27T09:56:40,027 context.add_object(staticmaps.Circle(center1, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.RED, width=2)) 2021-03-27T09:56:40,027 context.add_object(staticmaps.Circle(center2, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.GREEN, width=2)) 2021-03-27T09:56:40,027 context.add_object(staticmaps.Marker(center1, color=staticmaps.RED)) 2021-03-27T09:56:40,027 context.add_object(staticmaps.Marker(center2, color=staticmaps.GREEN)) 2021-03-27T09:56:40,028 # render non-anti-aliased png 2021-03-27T09:56:40,028 image = context.render_pillow(800, 500) 2021-03-27T09:56:40,028 image.save("geodesic_circles.pillow.png") 2021-03-27T09:56:40,028 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:40,028 image = context.render_cairo(800, 600) 2021-03-27T09:56:40,029 image.write_to_png("geodesic_circles.cairo.png") 2021-03-27T09:56:40,029 ``` 2021-03-27T09:56:40,030 ### Other Examples 2021-03-27T09:56:40,030 Please take a look at the command line program which uses the `staticmaps` package: `staticmaps/cli.py` 2021-03-27T09:56:40,030 ### Dependencies 2021-03-27T09:56:40,031 `py-staticmaps` uses 2021-03-27T09:56:40,031 - `PILLOW` for rendering raster-graphics 2021-03-27T09:56:40,031 - `pycairo` for rendering antialiased raster-graphics (optional!) 2021-03-27T09:56:40,031 - `svgwrite` for writing SVG files 2021-03-27T09:56:40,032 - `s2sphere` for geo coordinates handling 2021-03-27T09:56:40,032 - `geographiclib` for geodesic computations 2021-03-27T09:56:40,032 - `appdirs` for finding the user's default cache directory 2021-03-27T09:56:40,032 - `requests` for downloading tile files 2021-03-27T09:56:40,033 ## License 2021-03-27T09:56:40,033 [MIT](LICENSE) © 2020-2021 Florian Pigorsch 2021-03-27T09:56:40,033 running egg_info 2021-03-27T09:56:40,034 creating /tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info 2021-03-27T09:56:40,034 writing /tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info/PKG-INFO 2021-03-27T09:56:40,034 writing dependency_links to /tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info/dependency_links.txt 2021-03-27T09:56:40,034 writing entry points to /tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info/entry_points.txt 2021-03-27T09:56:40,034 writing requirements to /tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info/requires.txt 2021-03-27T09:56:40,034 writing top-level names to /tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info/top_level.txt 2021-03-27T09:56:40,034 writing manifest file '/tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info/SOURCES.txt' 2021-03-27T09:56:40,148 reading manifest file '/tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info/SOURCES.txt' 2021-03-27T09:56:40,150 reading manifest template 'MANIFEST.in' 2021-03-27T09:56:40,152 warning: no previously-included files matching '__pycache__' found under directory '*' 2021-03-27T09:56:40,153 warning: no previously-included files matching '*.py[co]' found under directory '*' 2021-03-27T09:56:40,155 writing manifest file '/tmp/pip-pip-egg-info-h2yx965i/py_staticmaps.egg-info/SOURCES.txt' 2021-03-27T09:56:40,443 Source in /tmp/pip-wheel-acl1jbkj/py-staticmaps_57c1eb342e774cfda46f2fe8515ae213 has version 0.4.0, which satisfies requirement py-staticmaps==0.4.0 from https://files.pythonhosted.org/packages/f9/22/efa565521b37c3cf8b64c6a2c7a3631efae15724231e23c9fd37623df7ef/py-staticmaps-0.4.0.tar.gz#sha256=5aba5ad59f30a63f860e76ed99407a6efb24eaad5c8997aa8617363989f17389 2021-03-27T09:56:40,445 Removed py-staticmaps==0.4.0 from https://files.pythonhosted.org/packages/f9/22/efa565521b37c3cf8b64c6a2c7a3631efae15724231e23c9fd37623df7ef/py-staticmaps-0.4.0.tar.gz#sha256=5aba5ad59f30a63f860e76ed99407a6efb24eaad5c8997aa8617363989f17389 from build tracker '/tmp/pip-req-tracker-apuml9s1' 2021-03-27T09:56:40,457 Created temporary directory: /tmp/pip-unpack-zlj55n2i 2021-03-27T09:56:40,458 Building wheels for collected packages: py-staticmaps 2021-03-27T09:56:40,464 Created temporary directory: /tmp/pip-wheel-az43w1lm 2021-03-27T09:56:40,465 Building wheel for py-staticmaps (setup.py): started 2021-03-27T09:56:40,465 Destination directory: /tmp/pip-wheel-az43w1lm 2021-03-27T09:56:40,465 Running command /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-acl1jbkj/py-staticmaps_57c1eb342e774cfda46f2fe8515ae213/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-acl1jbkj/py-staticmaps_57c1eb342e774cfda46f2fe8515ae213/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-az43w1lm 2021-03-27T09:56:41,283 # py-staticmaps 2021-03-27T09:56:41,283 A python module to create static map images (PNG, SVG) with markers, geodesic lines, etc. 2021-03-27T09:56:41,284 ## Features 2021-03-27T09:56:41,284 - Map objects: pin-style markers, image (PNG) markers, polylines, polygons, (geodesic) circles 2021-03-27T09:56:41,285 - Automatic computation of best center + zoom from the added map objects 2021-03-27T09:56:41,285 - Several pre-configured map tile providers 2021-03-27T09:56:41,285 - Proper tile provider attributions display 2021-03-27T09:56:41,285 - On-disc caching of map tile images for faster drawing and reduced load on the tile servers 2021-03-27T09:56:41,286 - Non-anti-aliased drawing via `PILLOW` 2021-03-27T09:56:41,286 - Anti-aliased drawing via `pycairo` (optional; only if `pycairo` is installed properly) 2021-03-27T09:56:41,286 - SVG creation via `svgwrite` 2021-03-27T09:56:41,287 ## Installation 2021-03-27T09:56:41,287 ### SVG + non-anti-aliased PNG version 2021-03-27T09:56:41,287 ```shell 2021-03-27T09:56:41,288 pip install py-staticmaps 2021-03-27T09:56:41,288 ``` 2021-03-27T09:56:41,288 ### SVG + anti-aliased PNG version (via Cairo) 2021-03-27T09:56:41,288 ```shell 2021-03-27T09:56:41,289 pip install py-staticmaps[cairo] 2021-03-27T09:56:41,289 ``` 2021-03-27T09:56:41,289 `py-staticmaps` uses `pycairo` for creating anti-aliased raster-graphics, so make sure `libcairo2` is installed on your system (on Ubuntu just install the `libcairo2-dev` package, i.e. `sudo apt install libcairo2-dev`). 2021-03-27T09:56:41,290 ## Examples 2021-03-27T09:56:41,290 Note: PNG support (e.g. `context.render_cairo(...)`) is only available if the `pycairo` module is installed. 2021-03-27T09:56:41,290 ### Markers and Geodesic Lines 2021-03-27T09:56:41,291 ```python 2021-03-27T09:56:41,291 import staticmaps 2021-03-27T09:56:41,291 context = staticmaps.Context() 2021-03-27T09:56:41,291 context.set_tile_provider(staticmaps.tile_provider_StamenToner) 2021-03-27T09:56:41,292 frankfurt = staticmaps.create_latlng(50.110644, 8.682092) 2021-03-27T09:56:41,292 newyork = staticmaps.create_latlng(40.712728, -74.006015) 2021-03-27T09:56:41,292 context.add_object(staticmaps.Line([frankfurt, newyork], color=staticmaps.BLUE, width=4)) 2021-03-27T09:56:41,293 context.add_object(staticmaps.Marker(frankfurt, color=staticmaps.GREEN, size=12)) 2021-03-27T09:56:41,293 context.add_object(staticmaps.Marker(newyork, color=staticmaps.RED, size=12)) 2021-03-27T09:56:41,293 # render non-anti-aliased png 2021-03-27T09:56:41,293 image = context.render_pillow(800, 500) 2021-03-27T09:56:41,294 image.save("frankfurt_newyork.pillow.png") 2021-03-27T09:56:41,294 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:41,294 image = context.render_cairo(800, 500) 2021-03-27T09:56:41,294 image.write_to_png("frankfurt_newyork.cairo.png") 2021-03-27T09:56:41,295 # render svg 2021-03-27T09:56:41,295 svg_image = context.render_svg(800, 500) 2021-03-27T09:56:41,295 with open("frankfurt_newyork.svg", "w", encoding="utf-8") as f: 2021-03-27T09:56:41,295 svg_image.write(f, pretty=True) 2021-03-27T09:56:41,296 ``` 2021-03-27T09:56:41,296 ### Transparent Polygons 2021-03-27T09:56:41,297 ```python 2021-03-27T09:56:41,297 import staticmaps 2021-03-27T09:56:41,297 context = staticmaps.Context() 2021-03-27T09:56:41,297 context.set_tile_provider(staticmaps.tile_provider_OSM) 2021-03-27T09:56:41,298 freiburg_polygon = [ 2021-03-27T09:56:41,298 (47.96881, 7.79045), 2021-03-27T09:56:41,298 (47.96866, 7.78610), 2021-03-27T09:56:41,298 (47.97134, 7.77874), 2021-03-27T09:56:41,299 ... 2021-03-27T09:56:41,299 ] 2021-03-27T09:56:41,299 context.add_object( 2021-03-27T09:56:41,299 staticmaps.Area( 2021-03-27T09:56:41,300 [staticmaps.create_latlng(lat, lng) for lat, lng in freiburg_polygon], 2021-03-27T09:56:41,300 fill_color=staticmaps.parse_color("#00FF003F"), 2021-03-27T09:56:41,300 width=2, 2021-03-27T09:56:41,300 color=staticmaps.BLUE, 2021-03-27T09:56:41,300 ) 2021-03-27T09:56:41,301 ) 2021-03-27T09:56:41,301 # render non-anti-aliased png 2021-03-27T09:56:41,301 image = context.render_pillow(800, 500) 2021-03-27T09:56:41,301 image.save("freiburg_area.pillow.png") 2021-03-27T09:56:41,302 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:41,302 image = context.render_cairo(800, 500) 2021-03-27T09:56:41,302 image.write_to_png("freiburg_area.cairo.png") 2021-03-27T09:56:41,302 # render svg 2021-03-27T09:56:41,303 svg_image = context.render_svg(800, 500) 2021-03-27T09:56:41,303 with open("freiburg_area.svg", "w", encoding="utf-8") as f: 2021-03-27T09:56:41,303 svg_image.write(f, pretty=True) 2021-03-27T09:56:41,303 ``` 2021-03-27T09:56:41,304 ### Drawing a GPX Track + Image Marker (PNG) 2021-03-27T09:56:41,304 ```python 2021-03-27T09:56:41,304 import sys 2021-03-27T09:56:41,305 import gpxpy 2021-03-27T09:56:41,305 import staticmaps 2021-03-27T09:56:41,305 context = staticmaps.Context() 2021-03-27T09:56:41,306 context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery) 2021-03-27T09:56:41,306 with open(sys.argv[1], "r") as file: 2021-03-27T09:56:41,306 gpx = gpxpy.parse(file) 2021-03-27T09:56:41,306 for track in gpx.tracks: 2021-03-27T09:56:41,307 for segment in track.segments: 2021-03-27T09:56:41,307 line = [staticmaps.create_latlng(p.latitude, p.longitude) for p in segment.points] 2021-03-27T09:56:41,307 context.add_object(staticmaps.Line(line)) 2021-03-27T09:56:41,307 for p in gpx.walk(only_points=True): 2021-03-27T09:56:41,308 pos = staticmaps.create_latlng(p.latitude, p.longitude) 2021-03-27T09:56:41,308 marker = staticmaps.ImageMarker(pos, "start.png", origin_x=27, origin_y=35) 2021-03-27T09:56:41,308 context.add_object(marker) 2021-03-27T09:56:41,308 break 2021-03-27T09:56:41,309 # render non-anti-aliased png 2021-03-27T09:56:41,309 image = context.render_pillow(800, 500) 2021-03-27T09:56:41,309 image.save("draw_gpx.pillow.png") 2021-03-27T09:56:41,309 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:41,309 image = context.render_cairo(800, 500) 2021-03-27T09:56:41,310 image.write_to_png("draw_gpx.cairo.png") 2021-03-27T09:56:41,310 ``` 2021-03-27T09:56:41,310 ### US State Capitals 2021-03-27T09:56:41,311 ```python 2021-03-27T09:56:41,311 import json 2021-03-27T09:56:41,311 import requests 2021-03-27T09:56:41,311 import staticmaps 2021-03-27T09:56:41,312 context = staticmaps.Context() 2021-03-27T09:56:41,312 context.set_tile_provider(staticmaps.tile_provider_OSM) 2021-03-27T09:56:41,312 URL = ( 2021-03-27T09:56:41,312 "https://gist.githubusercontent.com/jpriebe/d62a45e29f24e843c974/" 2021-03-27T09:56:41,313 "raw/b1d3066d245e742018bce56e41788ac7afa60e29/us_state_capitals.json" 2021-03-27T09:56:41,313 ) 2021-03-27T09:56:41,313 response = requests.get(URL) 2021-03-27T09:56:41,313 for _, data in json.loads(response.text).items(): 2021-03-27T09:56:41,313 capital = staticmaps.create_latlng(float(data["lat"]), float(data["long"])) 2021-03-27T09:56:41,313 context.add_object(staticmaps.Marker(capital, size=5)) 2021-03-27T09:56:41,314 # render non-anti-aliased png 2021-03-27T09:56:41,314 image = context.render_pillow(800, 500) 2021-03-27T09:56:41,314 image.save("us_capitals.pillow.png") 2021-03-27T09:56:41,314 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:41,315 image = context.render_cairo(800, 500) 2021-03-27T09:56:41,315 image.write_to_png("us_capitals.cairo.png") 2021-03-27T09:56:41,315 ``` 2021-03-27T09:56:41,316 ### Geodesic Circles 2021-03-27T09:56:41,316 ```python 2021-03-27T09:56:41,316 import staticmaps 2021-03-27T09:56:41,317 context = staticmaps.Context() 2021-03-27T09:56:41,317 context.set_tile_provider(staticmaps.tile_provider_StamenToner) 2021-03-27T09:56:41,317 center1 = staticmaps.create_latlng(66, 0) 2021-03-27T09:56:41,317 center2 = staticmaps.create_latlng(0, 0) 2021-03-27T09:56:41,318 context.add_object(staticmaps.Circle(center1, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.RED, width=2)) 2021-03-27T09:56:41,318 context.add_object(staticmaps.Circle(center2, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.GREEN, width=2)) 2021-03-27T09:56:41,318 context.add_object(staticmaps.Marker(center1, color=staticmaps.RED)) 2021-03-27T09:56:41,318 context.add_object(staticmaps.Marker(center2, color=staticmaps.GREEN)) 2021-03-27T09:56:41,318 # render non-anti-aliased png 2021-03-27T09:56:41,319 image = context.render_pillow(800, 500) 2021-03-27T09:56:41,319 image.save("geodesic_circles.pillow.png") 2021-03-27T09:56:41,319 # render anti-aliased png (this only works if pycairo is installed) 2021-03-27T09:56:41,319 image = context.render_cairo(800, 600) 2021-03-27T09:56:41,319 image.write_to_png("geodesic_circles.cairo.png") 2021-03-27T09:56:41,320 ``` 2021-03-27T09:56:41,320 ### Other Examples 2021-03-27T09:56:41,321 Please take a look at the command line program which uses the `staticmaps` package: `staticmaps/cli.py` 2021-03-27T09:56:41,321 ### Dependencies 2021-03-27T09:56:41,322 `py-staticmaps` uses 2021-03-27T09:56:41,322 - `PILLOW` for rendering raster-graphics 2021-03-27T09:56:41,322 - `pycairo` for rendering antialiased raster-graphics (optional!) 2021-03-27T09:56:41,322 - `svgwrite` for writing SVG files 2021-03-27T09:56:41,322 - `s2sphere` for geo coordinates handling 2021-03-27T09:56:41,323 - `geographiclib` for geodesic computations 2021-03-27T09:56:41,323 - `appdirs` for finding the user's default cache directory 2021-03-27T09:56:41,323 - `requests` for downloading tile files 2021-03-27T09:56:41,324 ## License 2021-03-27T09:56:41,324 [MIT](LICENSE) © 2020-2021 Florian Pigorsch 2021-03-27T09:56:41,479 running bdist_wheel 2021-03-27T09:56:41,486 running build 2021-03-27T09:56:41,486 running build_py 2021-03-27T09:56:41,619 creating build 2021-03-27T09:56:41,620 creating build/lib 2021-03-27T09:56:41,620 creating build/lib/staticmaps 2021-03-27T09:56:41,622 copying staticmaps/renderer.py -> build/lib/staticmaps 2021-03-27T09:56:41,624 copying staticmaps/svg_renderer.py -> build/lib/staticmaps 2021-03-27T09:56:41,627 copying staticmaps/__init__.py -> build/lib/staticmaps 2021-03-27T09:56:41,629 copying staticmaps/object.py -> build/lib/staticmaps 2021-03-27T09:56:41,631 copying staticmaps/cairo_renderer.py -> build/lib/staticmaps 2021-03-27T09:56:41,634 copying staticmaps/cli.py -> build/lib/staticmaps 2021-03-27T09:56:41,636 copying staticmaps/coordinates.py -> build/lib/staticmaps 2021-03-27T09:56:41,638 copying staticmaps/marker.py -> build/lib/staticmaps 2021-03-27T09:56:41,641 copying staticmaps/line.py -> build/lib/staticmaps 2021-03-27T09:56:41,644 copying staticmaps/area.py -> build/lib/staticmaps 2021-03-27T09:56:41,646 copying staticmaps/meta.py -> build/lib/staticmaps 2021-03-27T09:56:41,648 copying staticmaps/tile_provider.py -> build/lib/staticmaps 2021-03-27T09:56:41,651 copying staticmaps/color.py -> build/lib/staticmaps 2021-03-27T09:56:41,653 copying staticmaps/circle.py -> build/lib/staticmaps 2021-03-27T09:56:41,656 copying staticmaps/context.py -> build/lib/staticmaps 2021-03-27T09:56:41,659 copying staticmaps/transformer.py -> build/lib/staticmaps 2021-03-27T09:56:41,662 copying staticmaps/tile_downloader.py -> build/lib/staticmaps 2021-03-27T09:56:41,665 copying staticmaps/image_marker.py -> build/lib/staticmaps 2021-03-27T09:56:41,668 copying staticmaps/pillow_renderer.py -> build/lib/staticmaps 2021-03-27T09:56:41,676 installing to build/bdist.linux-armv7l/wheel 2021-03-27T09:56:41,676 running install 2021-03-27T09:56:41,678 running install_lib 2021-03-27T09:56:41,682 creating build/bdist.linux-armv7l 2021-03-27T09:56:41,683 creating build/bdist.linux-armv7l/wheel 2021-03-27T09:56:41,686 creating build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,687 copying build/lib/staticmaps/renderer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,690 copying build/lib/staticmaps/svg_renderer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,693 copying build/lib/staticmaps/__init__.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,695 copying build/lib/staticmaps/object.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,697 copying build/lib/staticmaps/cairo_renderer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,700 copying build/lib/staticmaps/cli.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,702 copying build/lib/staticmaps/coordinates.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,704 copying build/lib/staticmaps/marker.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,707 copying build/lib/staticmaps/line.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,710 copying build/lib/staticmaps/area.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,712 copying build/lib/staticmaps/meta.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,715 copying build/lib/staticmaps/tile_provider.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,718 copying build/lib/staticmaps/color.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,720 copying build/lib/staticmaps/circle.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,722 copying build/lib/staticmaps/context.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,726 copying build/lib/staticmaps/transformer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,729 copying build/lib/staticmaps/tile_downloader.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,731 copying build/lib/staticmaps/image_marker.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,734 copying build/lib/staticmaps/pillow_renderer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-27T09:56:41,737 running install_egg_info 2021-03-27T09:56:41,763 running egg_info 2021-03-27T09:56:41,764 writing py_staticmaps.egg-info/PKG-INFO 2021-03-27T09:56:41,766 writing dependency_links to py_staticmaps.egg-info/dependency_links.txt 2021-03-27T09:56:41,769 writing entry points to py_staticmaps.egg-info/entry_points.txt 2021-03-27T09:56:41,770 writing requirements to py_staticmaps.egg-info/requires.txt 2021-03-27T09:56:41,772 writing top-level names to py_staticmaps.egg-info/top_level.txt 2021-03-27T09:56:41,778 reading manifest file 'py_staticmaps.egg-info/SOURCES.txt' 2021-03-27T09:56:41,780 reading manifest template 'MANIFEST.in' 2021-03-27T09:56:41,783 warning: no previously-included files matching '__pycache__' found under directory '*' 2021-03-27T09:56:41,784 warning: no previously-included files matching '*.py[co]' found under directory '*' 2021-03-27T09:56:41,787 writing manifest file 'py_staticmaps.egg-info/SOURCES.txt' 2021-03-27T09:56:41,789 Copying py_staticmaps.egg-info to build/bdist.linux-armv7l/wheel/py_staticmaps-0.4.0-py3.7.egg-info 2021-03-27T09:56:41,805 running install_scripts 2021-03-27T09:56:41,901 adding license file "LICENSE" (matched pattern "LICEN[CS]E*") 2021-03-27T09:56:41,908 creating build/bdist.linux-armv7l/wheel/py_staticmaps-0.4.0.dist-info/WHEEL 2021-03-27T09:56:41,910 creating '/tmp/pip-wheel-az43w1lm/py_staticmaps-0.4.0-py3-none-any.whl' and adding 'build/bdist.linux-armv7l/wheel' to it 2021-03-27T09:56:41,915 adding 'staticmaps/__init__.py' 2021-03-27T09:56:41,916 adding 'staticmaps/area.py' 2021-03-27T09:56:41,918 adding 'staticmaps/cairo_renderer.py' 2021-03-27T09:56:41,919 adding 'staticmaps/circle.py' 2021-03-27T09:56:41,921 adding 'staticmaps/cli.py' 2021-03-27T09:56:41,922 adding 'staticmaps/color.py' 2021-03-27T09:56:41,925 adding 'staticmaps/context.py' 2021-03-27T09:56:41,926 adding 'staticmaps/coordinates.py' 2021-03-27T09:56:41,928 adding 'staticmaps/image_marker.py' 2021-03-27T09:56:41,930 adding 'staticmaps/line.py' 2021-03-27T09:56:41,931 adding 'staticmaps/marker.py' 2021-03-27T09:56:41,933 adding 'staticmaps/meta.py' 2021-03-27T09:56:41,934 adding 'staticmaps/object.py' 2021-03-27T09:56:41,936 adding 'staticmaps/pillow_renderer.py' 2021-03-27T09:56:41,937 adding 'staticmaps/renderer.py' 2021-03-27T09:56:41,939 adding 'staticmaps/svg_renderer.py' 2021-03-27T09:56:41,941 adding 'staticmaps/tile_downloader.py' 2021-03-27T09:56:41,942 adding 'staticmaps/tile_provider.py' 2021-03-27T09:56:41,944 adding 'staticmaps/transformer.py' 2021-03-27T09:56:41,945 adding 'py_staticmaps-0.4.0.dist-info/LICENSE' 2021-03-27T09:56:41,947 adding 'py_staticmaps-0.4.0.dist-info/METADATA' 2021-03-27T09:56:41,948 adding 'py_staticmaps-0.4.0.dist-info/WHEEL' 2021-03-27T09:56:41,949 adding 'py_staticmaps-0.4.0.dist-info/entry_points.txt' 2021-03-27T09:56:41,950 adding 'py_staticmaps-0.4.0.dist-info/top_level.txt' 2021-03-27T09:56:41,950 adding 'py_staticmaps-0.4.0.dist-info/RECORD' 2021-03-27T09:56:41,952 removing build/bdist.linux-armv7l/wheel 2021-03-27T09:56:42,028 Building wheel for py-staticmaps (setup.py): finished with status 'done' 2021-03-27T09:56:42,030 Created wheel for py-staticmaps: filename=py_staticmaps-0.4.0-py3-none-any.whl size=29618 sha256=b609f066f924972d7e75e3fb882788812ce1a873c8014fea1b3c7fa05f87036f 2021-03-27T09:56:42,030 Stored in directory: /tmp/pip-ephem-wheel-cache-1z2ddyx9/wheels/d6/38/ab/d3b2fb411022246af6af683306fd589598197eb1a9ddda7e9c 2021-03-27T09:56:42,040 Successfully built py-staticmaps 2021-03-27T09:56:42,044 Removed build tracker: '/tmp/pip-req-tracker-apuml9s1'