--Get images of OpenStreetMap and Geographical Survey Map using staticmap of Python library
Install the staticmap package.
$ pip install staticmap
Pillow and requests are also installed as dependent libraries.
Source code.
from staticmap import StaticMap
#Generate map object
#Image width(pixel)And the vertical width of the image(pixel)Specify
map = StaticMap(800, 600)
#Pillow's PIL with a map.Get Image object
#Specify zoom level and longitude / latitude
image = map.render(zoom=17, center=[136.882090, 35.170560])
#Save map image
image.save('komoot.png')
Execution result.
Source code.
from staticmap import StaticMap
#Generate map object
#Specify the width and height of the image and the tile URL of the OpenStreetMap standard tile layer
map = StaticMap(800, 600, url_template='http://a.tile.openstreetmap.org/{z}/{x}/{y}.png')
#Pillow's PIL with a map.Get Image object
#Specify zoom level and longitude / latitude
image = map.render(zoom=17, center=[136.882090, 35.170560])
#Save map image
image.save('osm.png')
Execution result.
Source code.
from staticmap import StaticMap
#Generate map object
#Specify the width and height of the image and the geospatial information authority tile URL of the Geographical Survey Institute
map = StaticMap(800, 600, url_template='https://cyberjapandata.gsi.go.jp/xyz/std/{z}/{x}/{y}.png')
#Pillow's PIL with a map.Get Image object
#Specify zoom level and list of longitude / latitude
image = map.render(zoom=14, center=[136.882090, 35.170560])
#Save map image
image.save('chiriin.png')
Execution result.
Recommended Posts