2021-03-07T23:19:21,091 Created temporary directory: /tmp/pip-ephem-wheel-cache-ncwp5g90 2021-03-07T23:19:21,094 Created temporary directory: /tmp/pip-req-tracker-m64w0pin 2021-03-07T23:19:21,094 Initialized build tracking at /tmp/pip-req-tracker-m64w0pin 2021-03-07T23:19:21,095 Created build tracker: /tmp/pip-req-tracker-m64w0pin 2021-03-07T23:19:21,095 Entered build tracker: /tmp/pip-req-tracker-m64w0pin 2021-03-07T23:19:21,096 Created temporary directory: /tmp/pip-wheel-s6s_0v98 2021-03-07T23:19:21,128 1 location(s) to search for versions of py-staticmaps: 2021-03-07T23:19:21,128 * https://pypi.org/simple/py-staticmaps/ 2021-03-07T23:19:21,128 Fetching project page and analyzing links: https://pypi.org/simple/py-staticmaps/ 2021-03-07T23:19:21,129 Getting page https://pypi.org/simple/py-staticmaps/ 2021-03-07T23:19:21,131 Found index url https://pypi.org/simple 2021-03-07T23:19:21,236 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-07T23:19:21,237 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-07T23:19:21,237 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-07T23:19:21,237 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-07T23:19:21,238 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-07T23:19:21,238 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-07T23:19:21,238 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-07T23:19:21,239 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-07T23:19:21,253 Given no hashes to check 1 links for project 'py-staticmaps': discarding no candidates 2021-03-07T23:19:21,268 Collecting py-staticmaps==0.3.0 2021-03-07T23:19:21,270 Created temporary directory: /tmp/pip-unpack-v_zlnue3 2021-03-07T23:19:21,310 Downloading py-staticmaps-0.3.0.tar.gz (17 kB) 2021-03-07T23:19:21,404 Added py-staticmaps==0.3.0 from https://files.pythonhosted.org/packages/42/e3/deeb3dece94a3b1b36206087677f5937a71a146c91b9616873bdda182822/py-staticmaps-0.3.0.tar.gz#sha256=df0474d4e7f8ee2134d08a4747808bad4b56fe7625b7e0bac35cf637b05d2ce1 to build tracker '/tmp/pip-req-tracker-m64w0pin' 2021-03-07T23:19:21,405 Running setup.py (path:/tmp/pip-wheel-s6s_0v98/py-staticmaps_e1876dd3d2f4480bb4c39551c4f6b4e8/setup.py) egg_info for package py-staticmaps 2021-03-07T23:19:21,406 Created temporary directory: /tmp/pip-pip-egg-info-s7ezszdg 2021-03-07T23:19:21,406 Running command python setup.py egg_info 2021-03-07T23:19:22,405 # py-staticmaps 2021-03-07T23:19:22,406 A python module to create static map images (PNG, SVG) with markers, geodesic lines, etc. 2021-03-07T23:19:22,406 ## Features 2021-03-07T23:19:22,407 - Map objects: pin-style markers, image (PNG) markers, polylines, polygons, (geodesic) circles 2021-03-07T23:19:22,407 - Automatic computation of best center + zoom from the added map objects 2021-03-07T23:19:22,407 - Several pre-configured map tile providers 2021-03-07T23:19:22,407 - Proper tile provider attributions display 2021-03-07T23:19:22,408 - On-disc caching of map tile images for faster drawing and reduced load on the tile servers 2021-03-07T23:19:22,408 - Anti-aliased drawing via `pycairo` 2021-03-07T23:19:22,408 - SVG creation via `svgwrite` 2021-03-07T23:19:22,409 ## Installation 2021-03-07T23:19:22,409 ### SVG only version 2021-03-07T23:19:22,409 ```shell 2021-03-07T23:19:22,410 pip install py-staticmaps 2021-03-07T23:19:22,410 ``` 2021-03-07T23:19:22,410 ### SVG + PNG version (via Cairo) 2021-03-07T23:19:22,411 ```shell 2021-03-07T23:19:22,411 pip install py-staticmaps[cairo] 2021-03-07T23:19:22,411 ``` 2021-03-07T23:19:22,412 `py-staticmaps` uses `pycairo` for creating antialiased 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-07T23:19:22,413 ## Examples 2021-03-07T23:19:22,413 Note: PNG support (e.g. `context.render_cairo(...)`) is only available if the `pycairo` module is installed. 2021-03-07T23:19:22,413 ### Markers and Geodesic Lines 2021-03-07T23:19:22,414 ```python 2021-03-07T23:19:22,414 import staticmaps 2021-03-07T23:19:22,414 context = staticmaps.Context() 2021-03-07T23:19:22,415 context.set_tile_provider(staticmaps.tile_provider_StamenToner) 2021-03-07T23:19:22,415 frankfurt = staticmaps.create_latlng(50.110644, 8.682092) 2021-03-07T23:19:22,415 newyork = staticmaps.create_latlng(40.712728, -74.006015) 2021-03-07T23:19:22,416 context.add_object(staticmaps.Line([frankfurt, newyork], color=staticmaps.BLUE, width=4)) 2021-03-07T23:19:22,416 context.add_object(staticmaps.Marker(frankfurt, color=staticmaps.GREEN, size=12)) 2021-03-07T23:19:22,416 context.add_object(staticmaps.Marker(newyork, color=staticmaps.RED, size=12)) 2021-03-07T23:19:22,417 # render png 2021-03-07T23:19:22,417 image = context.render_cairo(800, 500) 2021-03-07T23:19:22,417 image.write_to_png("frankfurt_newyork.png") 2021-03-07T23:19:22,418 # render svg 2021-03-07T23:19:22,418 svg_image = context.render_svg(800, 500) 2021-03-07T23:19:22,418 with open("frankfurt_newyork.svg", "w", encoding="utf-8") as f: 2021-03-07T23:19:22,418 svg_image.write(f, pretty=True) 2021-03-07T23:19:22,418 ``` 2021-03-07T23:19:22,419 ### Transparent Polygons 2021-03-07T23:19:22,420 ```python 2021-03-07T23:19:22,420 import staticmaps 2021-03-07T23:19:22,420 context = staticmaps.Context() 2021-03-07T23:19:22,420 context.set_tile_provider(staticmaps.tile_provider_OSM) 2021-03-07T23:19:22,421 freiburg_polygon = [ 2021-03-07T23:19:22,421 (47.96881, 7.79045), 2021-03-07T23:19:22,421 (47.96866, 7.78610), 2021-03-07T23:19:22,421 (47.97134, 7.77874), 2021-03-07T23:19:22,421 ... 2021-03-07T23:19:22,422 ] 2021-03-07T23:19:22,422 context.add_object( 2021-03-07T23:19:22,422 staticmaps.Area( 2021-03-07T23:19:22,422 [staticmaps.create_latlng(lat, lng) for lat, lng in freiburg_polygon], 2021-03-07T23:19:22,422 fill_color=staticmaps.parse_color("#00FF003F"), 2021-03-07T23:19:22,423 width=2, 2021-03-07T23:19:22,423 color=staticmaps.BLUE, 2021-03-07T23:19:22,423 ) 2021-03-07T23:19:22,423 ) 2021-03-07T23:19:22,424 # render png 2021-03-07T23:19:22,424 image = context.render_cairo(800, 500) 2021-03-07T23:19:22,424 image.write_to_png("freiburg_area.png") 2021-03-07T23:19:22,424 # render svg 2021-03-07T23:19:22,425 svg_image = context.render_svg(800, 500) 2021-03-07T23:19:22,425 with open("freiburg_area.svg", "w", encoding="utf-8") as f: 2021-03-07T23:19:22,425 svg_image.write(f, pretty=True) 2021-03-07T23:19:22,425 ``` 2021-03-07T23:19:22,426 ### Drawing a GPX Track + Image Marker (PNG) 2021-03-07T23:19:22,426 ```python 2021-03-07T23:19:22,426 import sys 2021-03-07T23:19:22,427 import gpxpy 2021-03-07T23:19:22,427 import staticmaps 2021-03-07T23:19:22,427 context = staticmaps.Context() 2021-03-07T23:19:22,428 context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery) 2021-03-07T23:19:22,428 with open(sys.argv[1], "r") as file: 2021-03-07T23:19:22,428 gpx = gpxpy.parse(file) 2021-03-07T23:19:22,428 for track in gpx.tracks: 2021-03-07T23:19:22,429 for segment in track.segments: 2021-03-07T23:19:22,429 line = [staticmaps.create_latlng(p.latitude, p.longitude) for p in segment.points] 2021-03-07T23:19:22,429 context.add_object(staticmaps.Line(line)) 2021-03-07T23:19:22,429 for p in gpx.walk(only_points=True): 2021-03-07T23:19:22,429 pos = staticmaps.create_latlng(p.latitude, p.longitude) 2021-03-07T23:19:22,430 marker = staticmaps.ImageMarker(pos, "start.png", origin_x=27, origin_y=35) 2021-03-07T23:19:22,430 context.add_object(marker) 2021-03-07T23:19:22,430 break 2021-03-07T23:19:22,430 image = context.render_cairo(800, 500) 2021-03-07T23:19:22,430 image.write_to_png("draw_gpx.png") 2021-03-07T23:19:22,431 ``` 2021-03-07T23:19:22,431 ### US State Capitals 2021-03-07T23:19:22,432 ```python 2021-03-07T23:19:22,432 import json 2021-03-07T23:19:22,432 import requests 2021-03-07T23:19:22,432 import staticmaps 2021-03-07T23:19:22,433 context = staticmaps.Context() 2021-03-07T23:19:22,433 context.set_tile_provider(staticmaps.tile_provider_OSM) 2021-03-07T23:19:22,433 URL = ( 2021-03-07T23:19:22,433 "https://gist.githubusercontent.com/jpriebe/d62a45e29f24e843c974/" 2021-03-07T23:19:22,433 "raw/b1d3066d245e742018bce56e41788ac7afa60e29/us_state_capitals.json" 2021-03-07T23:19:22,434 ) 2021-03-07T23:19:22,434 response = requests.get(URL) 2021-03-07T23:19:22,434 for _, data in json.loads(response.text).items(): 2021-03-07T23:19:22,434 capital = staticmaps.create_latlng(float(data["lat"]), float(data["long"])) 2021-03-07T23:19:22,434 context.add_object(staticmaps.Marker(capital, size=5)) 2021-03-07T23:19:22,435 image = context.render_cairo(800, 500) 2021-03-07T23:19:22,435 image.write_to_png("us_capitals.png") 2021-03-07T23:19:22,435 ``` 2021-03-07T23:19:22,436 ### Geodesic Circles 2021-03-07T23:19:22,436 ```python 2021-03-07T23:19:22,436 import staticmaps 2021-03-07T23:19:22,437 context = staticmaps.Context() 2021-03-07T23:19:22,437 context.set_tile_provider(staticmaps.tile_provider_StamenToner) 2021-03-07T23:19:22,437 center1 = staticmaps.create_latlng(66, 0) 2021-03-07T23:19:22,437 center2 = staticmaps.create_latlng(0, 0) 2021-03-07T23:19:22,438 context.add_object(staticmaps.Circle(center1, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.RED, width=2)) 2021-03-07T23:19:22,438 context.add_object(staticmaps.Circle(center2, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.GREEN, width=2)) 2021-03-07T23:19:22,438 context.add_object(staticmaps.Marker(center1, color=staticmaps.RED)) 2021-03-07T23:19:22,438 context.add_object(staticmaps.Marker(center2, color=staticmaps.GREEN)) 2021-03-07T23:19:22,439 image = context.render_cairo(800, 600) 2021-03-07T23:19:22,439 image.write_to_png("geodesic_circles.png") 2021-03-07T23:19:22,439 ``` 2021-03-07T23:19:22,440 ### Other Examples 2021-03-07T23:19:22,440 Please take a look at the command line program which uses the `staticmaps` package: `staticmaps/cli.py` 2021-03-07T23:19:22,440 ### Dependencies 2021-03-07T23:19:22,441 `py-staticmaps` uses 2021-03-07T23:19:22,441 - `pycairo` for rendering antialiased raster-graphics 2021-03-07T23:19:22,441 - `svgwrite` for writing SVG files 2021-03-07T23:19:22,442 - `s2sphere` for geo coordinates handling 2021-03-07T23:19:22,442 - `geographiclib` for geodesic computations 2021-03-07T23:19:22,442 - `appdirs` for finding the user's default cache directory 2021-03-07T23:19:22,442 - `requests` for downloading tile files 2021-03-07T23:19:22,442 ## License 2021-03-07T23:19:22,443 [MIT](LICENSE) © 2020-2012 Florian Pigorsch 2021-03-07T23:19:22,443 running egg_info 2021-03-07T23:19:22,443 creating /tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info 2021-03-07T23:19:22,443 writing /tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info/PKG-INFO 2021-03-07T23:19:22,444 writing dependency_links to /tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info/dependency_links.txt 2021-03-07T23:19:22,444 writing entry points to /tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info/entry_points.txt 2021-03-07T23:19:22,444 writing requirements to /tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info/requires.txt 2021-03-07T23:19:22,444 writing top-level names to /tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info/top_level.txt 2021-03-07T23:19:22,444 writing manifest file '/tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info/SOURCES.txt' 2021-03-07T23:19:22,563 reading manifest file '/tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info/SOURCES.txt' 2021-03-07T23:19:22,564 reading manifest template 'MANIFEST.in' 2021-03-07T23:19:22,567 warning: no previously-included files matching '__pycache__' found under directory '*' 2021-03-07T23:19:22,568 warning: no previously-included files matching '*.py[co]' found under directory '*' 2021-03-07T23:19:22,571 writing manifest file '/tmp/pip-pip-egg-info-s7ezszdg/py_staticmaps.egg-info/SOURCES.txt' 2021-03-07T23:19:22,636 Source in /tmp/pip-wheel-s6s_0v98/py-staticmaps_e1876dd3d2f4480bb4c39551c4f6b4e8 has version 0.3.0, which satisfies requirement py-staticmaps==0.3.0 from https://files.pythonhosted.org/packages/42/e3/deeb3dece94a3b1b36206087677f5937a71a146c91b9616873bdda182822/py-staticmaps-0.3.0.tar.gz#sha256=df0474d4e7f8ee2134d08a4747808bad4b56fe7625b7e0bac35cf637b05d2ce1 2021-03-07T23:19:22,637 Removed py-staticmaps==0.3.0 from https://files.pythonhosted.org/packages/42/e3/deeb3dece94a3b1b36206087677f5937a71a146c91b9616873bdda182822/py-staticmaps-0.3.0.tar.gz#sha256=df0474d4e7f8ee2134d08a4747808bad4b56fe7625b7e0bac35cf637b05d2ce1 from build tracker '/tmp/pip-req-tracker-m64w0pin' 2021-03-07T23:19:22,642 Created temporary directory: /tmp/pip-unpack-4xw2hlm8 2021-03-07T23:19:22,643 Building wheels for collected packages: py-staticmaps 2021-03-07T23:19:22,647 Created temporary directory: /tmp/pip-wheel-ey73vj8e 2021-03-07T23:19:22,648 Building wheel for py-staticmaps (setup.py): started 2021-03-07T23:19:22,648 Destination directory: /tmp/pip-wheel-ey73vj8e 2021-03-07T23:19:22,648 Running command /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-wheel-s6s_0v98/py-staticmaps_e1876dd3d2f4480bb4c39551c4f6b4e8/setup.py'"'"'; __file__='"'"'/tmp/pip-wheel-s6s_0v98/py-staticmaps_e1876dd3d2f4480bb4c39551c4f6b4e8/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-ey73vj8e 2021-03-07T23:19:23,455 # py-staticmaps 2021-03-07T23:19:23,455 A python module to create static map images (PNG, SVG) with markers, geodesic lines, etc. 2021-03-07T23:19:23,456 ## Features 2021-03-07T23:19:23,456 - Map objects: pin-style markers, image (PNG) markers, polylines, polygons, (geodesic) circles 2021-03-07T23:19:23,457 - Automatic computation of best center + zoom from the added map objects 2021-03-07T23:19:23,457 - Several pre-configured map tile providers 2021-03-07T23:19:23,457 - Proper tile provider attributions display 2021-03-07T23:19:23,457 - On-disc caching of map tile images for faster drawing and reduced load on the tile servers 2021-03-07T23:19:23,458 - Anti-aliased drawing via `pycairo` 2021-03-07T23:19:23,458 - SVG creation via `svgwrite` 2021-03-07T23:19:23,458 ## Installation 2021-03-07T23:19:23,459 ### SVG only version 2021-03-07T23:19:23,459 ```shell 2021-03-07T23:19:23,459 pip install py-staticmaps 2021-03-07T23:19:23,460 ``` 2021-03-07T23:19:23,460 ### SVG + PNG version (via Cairo) 2021-03-07T23:19:23,460 ```shell 2021-03-07T23:19:23,460 pip install py-staticmaps[cairo] 2021-03-07T23:19:23,461 ``` 2021-03-07T23:19:23,461 `py-staticmaps` uses `pycairo` for creating antialiased 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-07T23:19:23,462 ## Examples 2021-03-07T23:19:23,462 Note: PNG support (e.g. `context.render_cairo(...)`) is only available if the `pycairo` module is installed. 2021-03-07T23:19:23,462 ### Markers and Geodesic Lines 2021-03-07T23:19:23,463 ```python 2021-03-07T23:19:23,463 import staticmaps 2021-03-07T23:19:23,463 context = staticmaps.Context() 2021-03-07T23:19:23,463 context.set_tile_provider(staticmaps.tile_provider_StamenToner) 2021-03-07T23:19:23,464 frankfurt = staticmaps.create_latlng(50.110644, 8.682092) 2021-03-07T23:19:23,464 newyork = staticmaps.create_latlng(40.712728, -74.006015) 2021-03-07T23:19:23,464 context.add_object(staticmaps.Line([frankfurt, newyork], color=staticmaps.BLUE, width=4)) 2021-03-07T23:19:23,464 context.add_object(staticmaps.Marker(frankfurt, color=staticmaps.GREEN, size=12)) 2021-03-07T23:19:23,464 context.add_object(staticmaps.Marker(newyork, color=staticmaps.RED, size=12)) 2021-03-07T23:19:23,465 # render png 2021-03-07T23:19:23,465 image = context.render_cairo(800, 500) 2021-03-07T23:19:23,465 image.write_to_png("frankfurt_newyork.png") 2021-03-07T23:19:23,466 # render svg 2021-03-07T23:19:23,466 svg_image = context.render_svg(800, 500) 2021-03-07T23:19:23,466 with open("frankfurt_newyork.svg", "w", encoding="utf-8") as f: 2021-03-07T23:19:23,466 svg_image.write(f, pretty=True) 2021-03-07T23:19:23,466 ``` 2021-03-07T23:19:23,467 ### Transparent Polygons 2021-03-07T23:19:23,468 ```python 2021-03-07T23:19:23,468 import staticmaps 2021-03-07T23:19:23,468 context = staticmaps.Context() 2021-03-07T23:19:23,468 context.set_tile_provider(staticmaps.tile_provider_OSM) 2021-03-07T23:19:23,469 freiburg_polygon = [ 2021-03-07T23:19:23,469 (47.96881, 7.79045), 2021-03-07T23:19:23,469 (47.96866, 7.78610), 2021-03-07T23:19:23,469 (47.97134, 7.77874), 2021-03-07T23:19:23,469 ... 2021-03-07T23:19:23,470 ] 2021-03-07T23:19:23,470 context.add_object( 2021-03-07T23:19:23,470 staticmaps.Area( 2021-03-07T23:19:23,470 [staticmaps.create_latlng(lat, lng) for lat, lng in freiburg_polygon], 2021-03-07T23:19:23,470 fill_color=staticmaps.parse_color("#00FF003F"), 2021-03-07T23:19:23,471 width=2, 2021-03-07T23:19:23,471 color=staticmaps.BLUE, 2021-03-07T23:19:23,471 ) 2021-03-07T23:19:23,471 ) 2021-03-07T23:19:23,471 # render png 2021-03-07T23:19:23,472 image = context.render_cairo(800, 500) 2021-03-07T23:19:23,472 image.write_to_png("freiburg_area.png") 2021-03-07T23:19:23,472 # render svg 2021-03-07T23:19:23,472 svg_image = context.render_svg(800, 500) 2021-03-07T23:19:23,472 with open("freiburg_area.svg", "w", encoding="utf-8") as f: 2021-03-07T23:19:23,473 svg_image.write(f, pretty=True) 2021-03-07T23:19:23,473 ``` 2021-03-07T23:19:23,474 ### Drawing a GPX Track + Image Marker (PNG) 2021-03-07T23:19:23,474 ```python 2021-03-07T23:19:23,474 import sys 2021-03-07T23:19:23,474 import gpxpy 2021-03-07T23:19:23,475 import staticmaps 2021-03-07T23:19:23,475 context = staticmaps.Context() 2021-03-07T23:19:23,475 context.set_tile_provider(staticmaps.tile_provider_ArcGISWorldImagery) 2021-03-07T23:19:23,475 with open(sys.argv[1], "r") as file: 2021-03-07T23:19:23,476 gpx = gpxpy.parse(file) 2021-03-07T23:19:23,476 for track in gpx.tracks: 2021-03-07T23:19:23,476 for segment in track.segments: 2021-03-07T23:19:23,476 line = [staticmaps.create_latlng(p.latitude, p.longitude) for p in segment.points] 2021-03-07T23:19:23,477 context.add_object(staticmaps.Line(line)) 2021-03-07T23:19:23,477 for p in gpx.walk(only_points=True): 2021-03-07T23:19:23,477 pos = staticmaps.create_latlng(p.latitude, p.longitude) 2021-03-07T23:19:23,477 marker = staticmaps.ImageMarker(pos, "start.png", origin_x=27, origin_y=35) 2021-03-07T23:19:23,477 context.add_object(marker) 2021-03-07T23:19:23,478 break 2021-03-07T23:19:23,478 image = context.render_cairo(800, 500) 2021-03-07T23:19:23,478 image.write_to_png("draw_gpx.png") 2021-03-07T23:19:23,478 ``` 2021-03-07T23:19:23,479 ### US State Capitals 2021-03-07T23:19:23,479 ```python 2021-03-07T23:19:23,479 import json 2021-03-07T23:19:23,480 import requests 2021-03-07T23:19:23,480 import staticmaps 2021-03-07T23:19:23,480 context = staticmaps.Context() 2021-03-07T23:19:23,480 context.set_tile_provider(staticmaps.tile_provider_OSM) 2021-03-07T23:19:23,481 URL = ( 2021-03-07T23:19:23,481 "https://gist.githubusercontent.com/jpriebe/d62a45e29f24e843c974/" 2021-03-07T23:19:23,481 "raw/b1d3066d245e742018bce56e41788ac7afa60e29/us_state_capitals.json" 2021-03-07T23:19:23,481 ) 2021-03-07T23:19:23,481 response = requests.get(URL) 2021-03-07T23:19:23,481 for _, data in json.loads(response.text).items(): 2021-03-07T23:19:23,482 capital = staticmaps.create_latlng(float(data["lat"]), float(data["long"])) 2021-03-07T23:19:23,482 context.add_object(staticmaps.Marker(capital, size=5)) 2021-03-07T23:19:23,482 image = context.render_cairo(800, 500) 2021-03-07T23:19:23,482 image.write_to_png("us_capitals.png") 2021-03-07T23:19:23,482 ``` 2021-03-07T23:19:23,483 ### Geodesic Circles 2021-03-07T23:19:23,483 ```python 2021-03-07T23:19:23,484 import staticmaps 2021-03-07T23:19:23,484 context = staticmaps.Context() 2021-03-07T23:19:23,484 context.set_tile_provider(staticmaps.tile_provider_StamenToner) 2021-03-07T23:19:23,484 center1 = staticmaps.create_latlng(66, 0) 2021-03-07T23:19:23,485 center2 = staticmaps.create_latlng(0, 0) 2021-03-07T23:19:23,485 context.add_object(staticmaps.Circle(center1, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.RED, width=2)) 2021-03-07T23:19:23,485 context.add_object(staticmaps.Circle(center2, 2000, fill_color=staticmaps.TRANSPARENT, color=staticmaps.GREEN, width=2)) 2021-03-07T23:19:23,485 context.add_object(staticmaps.Marker(center1, color=staticmaps.RED)) 2021-03-07T23:19:23,485 context.add_object(staticmaps.Marker(center2, color=staticmaps.GREEN)) 2021-03-07T23:19:23,486 image = context.render_cairo(800, 600) 2021-03-07T23:19:23,486 image.write_to_png("geodesic_circles.png") 2021-03-07T23:19:23,486 ``` 2021-03-07T23:19:23,487 ### Other Examples 2021-03-07T23:19:23,487 Please take a look at the command line program which uses the `staticmaps` package: `staticmaps/cli.py` 2021-03-07T23:19:23,488 ### Dependencies 2021-03-07T23:19:23,488 `py-staticmaps` uses 2021-03-07T23:19:23,489 - `pycairo` for rendering antialiased raster-graphics 2021-03-07T23:19:23,489 - `svgwrite` for writing SVG files 2021-03-07T23:19:23,489 - `s2sphere` for geo coordinates handling 2021-03-07T23:19:23,489 - `geographiclib` for geodesic computations 2021-03-07T23:19:23,489 - `appdirs` for finding the user's default cache directory 2021-03-07T23:19:23,489 - `requests` for downloading tile files 2021-03-07T23:19:23,490 ## License 2021-03-07T23:19:23,490 [MIT](LICENSE) © 2020-2012 Florian Pigorsch 2021-03-07T23:19:23,649 running bdist_wheel 2021-03-07T23:19:23,655 running build 2021-03-07T23:19:23,656 running build_py 2021-03-07T23:19:23,791 creating build 2021-03-07T23:19:23,791 creating build/lib 2021-03-07T23:19:23,792 creating build/lib/staticmaps 2021-03-07T23:19:23,793 copying staticmaps/tile_downloader.py -> build/lib/staticmaps 2021-03-07T23:19:23,796 copying staticmaps/color.py -> build/lib/staticmaps 2021-03-07T23:19:23,798 copying staticmaps/coordinates.py -> build/lib/staticmaps 2021-03-07T23:19:23,800 copying staticmaps/cairo_renderer.py -> build/lib/staticmaps 2021-03-07T23:19:23,802 copying staticmaps/area.py -> build/lib/staticmaps 2021-03-07T23:19:23,805 copying staticmaps/marker.py -> build/lib/staticmaps 2021-03-07T23:19:23,807 copying staticmaps/image_marker.py -> build/lib/staticmaps 2021-03-07T23:19:23,809 copying staticmaps/circle.py -> build/lib/staticmaps 2021-03-07T23:19:23,812 copying staticmaps/context.py -> build/lib/staticmaps 2021-03-07T23:19:23,815 copying staticmaps/renderer.py -> build/lib/staticmaps 2021-03-07T23:19:23,817 copying staticmaps/meta.py -> build/lib/staticmaps 2021-03-07T23:19:23,819 copying staticmaps/line.py -> build/lib/staticmaps 2021-03-07T23:19:23,822 copying staticmaps/svg_renderer.py -> build/lib/staticmaps 2021-03-07T23:19:23,825 copying staticmaps/__init__.py -> build/lib/staticmaps 2021-03-07T23:19:23,828 copying staticmaps/cli.py -> build/lib/staticmaps 2021-03-07T23:19:23,831 copying staticmaps/object.py -> build/lib/staticmaps 2021-03-07T23:19:23,833 copying staticmaps/tile_provider.py -> build/lib/staticmaps 2021-03-07T23:19:23,836 copying staticmaps/transformer.py -> build/lib/staticmaps 2021-03-07T23:19:23,844 installing to build/bdist.linux-armv7l/wheel 2021-03-07T23:19:23,844 running install 2021-03-07T23:19:23,846 running install_lib 2021-03-07T23:19:23,851 creating build/bdist.linux-armv7l 2021-03-07T23:19:23,852 creating build/bdist.linux-armv7l/wheel 2021-03-07T23:19:23,854 creating build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,856 copying build/lib/staticmaps/tile_downloader.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,859 copying build/lib/staticmaps/color.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,862 copying build/lib/staticmaps/coordinates.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,864 copying build/lib/staticmaps/cairo_renderer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,868 copying build/lib/staticmaps/area.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,871 copying build/lib/staticmaps/marker.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,875 copying build/lib/staticmaps/image_marker.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,877 copying build/lib/staticmaps/circle.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,881 copying build/lib/staticmaps/context.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,888 copying build/lib/staticmaps/renderer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,891 copying build/lib/staticmaps/meta.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,894 copying build/lib/staticmaps/line.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,897 copying build/lib/staticmaps/svg_renderer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,900 copying build/lib/staticmaps/__init__.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,903 copying build/lib/staticmaps/cli.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,906 copying build/lib/staticmaps/object.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,909 copying build/lib/staticmaps/tile_provider.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,911 copying build/lib/staticmaps/transformer.py -> build/bdist.linux-armv7l/wheel/staticmaps 2021-03-07T23:19:23,914 running install_egg_info 2021-03-07T23:19:23,940 running egg_info 2021-03-07T23:19:23,941 writing py_staticmaps.egg-info/PKG-INFO 2021-03-07T23:19:23,944 writing dependency_links to py_staticmaps.egg-info/dependency_links.txt 2021-03-07T23:19:23,945 writing entry points to py_staticmaps.egg-info/entry_points.txt 2021-03-07T23:19:23,947 writing requirements to py_staticmaps.egg-info/requires.txt 2021-03-07T23:19:23,948 writing top-level names to py_staticmaps.egg-info/top_level.txt 2021-03-07T23:19:23,953 reading manifest file 'py_staticmaps.egg-info/SOURCES.txt' 2021-03-07T23:19:23,956 reading manifest template 'MANIFEST.in' 2021-03-07T23:19:23,958 warning: no previously-included files matching '__pycache__' found under directory '*' 2021-03-07T23:19:23,959 warning: no previously-included files matching '*.py[co]' found under directory '*' 2021-03-07T23:19:23,962 writing manifest file 'py_staticmaps.egg-info/SOURCES.txt' 2021-03-07T23:19:23,964 Copying py_staticmaps.egg-info to build/bdist.linux-armv7l/wheel/py_staticmaps-0.3.0-py3.7.egg-info 2021-03-07T23:19:23,979 running install_scripts 2021-03-07T23:19:24,079 adding license file "LICENSE" (matched pattern "LICEN[CS]E*") 2021-03-07T23:19:24,086 creating build/bdist.linux-armv7l/wheel/py_staticmaps-0.3.0.dist-info/WHEEL 2021-03-07T23:19:24,089 creating '/tmp/pip-wheel-ey73vj8e/py_staticmaps-0.3.0-py3-none-any.whl' and adding 'build/bdist.linux-armv7l/wheel' to it 2021-03-07T23:19:24,094 adding 'staticmaps/__init__.py' 2021-03-07T23:19:24,095 adding 'staticmaps/area.py' 2021-03-07T23:19:24,097 adding 'staticmaps/cairo_renderer.py' 2021-03-07T23:19:24,098 adding 'staticmaps/circle.py' 2021-03-07T23:19:24,100 adding 'staticmaps/cli.py' 2021-03-07T23:19:24,101 adding 'staticmaps/color.py' 2021-03-07T23:19:24,103 adding 'staticmaps/context.py' 2021-03-07T23:19:24,104 adding 'staticmaps/coordinates.py' 2021-03-07T23:19:24,106 adding 'staticmaps/image_marker.py' 2021-03-07T23:19:24,107 adding 'staticmaps/line.py' 2021-03-07T23:19:24,109 adding 'staticmaps/marker.py' 2021-03-07T23:19:24,110 adding 'staticmaps/meta.py' 2021-03-07T23:19:24,111 adding 'staticmaps/object.py' 2021-03-07T23:19:24,113 adding 'staticmaps/renderer.py' 2021-03-07T23:19:24,114 adding 'staticmaps/svg_renderer.py' 2021-03-07T23:19:24,116 adding 'staticmaps/tile_downloader.py' 2021-03-07T23:19:24,117 adding 'staticmaps/tile_provider.py' 2021-03-07T23:19:24,119 adding 'staticmaps/transformer.py' 2021-03-07T23:19:24,120 adding 'py_staticmaps-0.3.0.dist-info/LICENSE' 2021-03-07T23:19:24,122 adding 'py_staticmaps-0.3.0.dist-info/METADATA' 2021-03-07T23:19:24,123 adding 'py_staticmaps-0.3.0.dist-info/WHEEL' 2021-03-07T23:19:24,124 adding 'py_staticmaps-0.3.0.dist-info/entry_points.txt' 2021-03-07T23:19:24,125 adding 'py_staticmaps-0.3.0.dist-info/top_level.txt' 2021-03-07T23:19:24,126 adding 'py_staticmaps-0.3.0.dist-info/RECORD' 2021-03-07T23:19:24,127 removing build/bdist.linux-armv7l/wheel 2021-03-07T23:19:24,207 Building wheel for py-staticmaps (setup.py): finished with status 'done' 2021-03-07T23:19:24,209 Created wheel for py-staticmaps: filename=py_staticmaps-0.3.0-py3-none-any.whl size=23416 sha256=04bdf576bbe49b09308a0a54fe2025e7e56170cb93884fdb102c4e77be8b5b58 2021-03-07T23:19:24,210 Stored in directory: /tmp/pip-ephem-wheel-cache-ncwp5g90/wheels/80/a1/4e/cb85b9e9823279fb83275b1e7f4aa584855711a486a6eb70ce 2021-03-07T23:19:24,219 Successfully built py-staticmaps 2021-03-07T23:19:24,224 Removed build tracker: '/tmp/pip-req-tracker-m64w0pin'