Get images of OpenStreetMap and Geographical Survey Institute maps with Python + staticmap

Overview

--Get images of OpenStreetMap and Geographical Survey Map using staticmap of Python library

This environment

installation of staticmap

Install the staticmap package.

$ pip install staticmap

Pillow and requests are also installed as dependent libraries.

staticmap Get the default map image

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.

komoot.png

Get a map image of OpenStreetMap

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.

osm.png

Get a map image of the Geographical Survey Institute map

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.

chiriin.png

Reference material

Recommended Posts

Get images of OpenStreetMap and Geographical Survey Institute maps with Python + staticmap
Get images of OpenStreetMap and Geographical Survey Institute maps with Python + py-staticmaps
Try to image the elevation data of the Geographical Survey Institute with Python
Get media timeline images and videos with Python + Tweepy
Get rid of dirty data with Python and regular expressions
Sample of HTTP GET and JSON parsing with python of pepper
Coexistence of Python2 and 3 with CircleCI (1.0)
Capturing images with Pupil, python and OpenCV
Importing and exporting GeoTiff images with Python
Get rid of DICOM images in Python
Get the number of articles accessed and likes with Qiita API + Python
Get and estimate the shape of the head using Dlib and OpenCV with python
Explanation of creating an application for displaying images and drawing with Python
Get git branch name and tag name with python
[Python] Get rid of dating with regular expressions
Implementation of TRIE tree with Python and LOUDS
Get CPU information of Raspberry Pi with Python
Wavelet transform of images with PyWavelets and OpenCV
Get Gmail subject and body with Python and Gmail API
Continuation of multi-platform development with Electron and Python
Get the stock price of a Japanese company with Python and make a graph
Example of reading and writing CSV with Python
Get a large amount of Starbucks Twitter data with python and try data analysis Part 1
Extract images and tables from pdf with python to reduce the burden of reporting
Display embedded images of mp3 and flac with mutagen
Try projective transformation of images using OpenCV with Python
Easy partial download of mp4 with python and youtube-dl!
Visualize the range of interpolation and extrapolation with python
Get comments on youtube Live with [python] and [pytchat]!
Create a batch of images and inflate with ImageDataGenerator
Get mail from Gmail and label it with Python3
Get the operation status of JR West with Python
[Python] Get user information and article information with Qiita API
Get an abstract understanding of Python modules and packages
Comparison of CoffeeScript with JavaScript, Python and Ruby grammar
Version control of Node, Ruby and Python with anyenv
I tried "morphology conversion" of images with Python + OpenCV
Get a list of CloudWatch Metrics and a correspondence table for Unit units with Python boto
Compare HTTP GET / POST with cURL (command) and Python (programming)
Perform isocurrent analysis of open channels with Python and matplotlib
Get a list of purchased DMM eBooks with Python + Selenium
Send experiment results (text and images) to slack with Python
Detect objects of a specific color and size with Python
[Python x Zapier] Get alert information and notify with Slack
Get additional data to LDAP with python (Writer and Reader)
Play with the password mechanism of GitHub Webhook and Python
Get the source of the page to load infinitely with python.
Get country code with python
Programming with Python and Tkinter
Encryption and decryption with Python
Python and hardware-Using RS232C with Python-
Get Youtube data with python
Get thread ID with python
Faster loading of Python images
Get started with Python! ~ ② Grammar ~
python with pyenv and venv
[python] Get quotient and remainder
Get stock price with Python
Get home directory with python
Get keyboard events with python
Source installation and installation of Python