Create a web map using Python and GDAL

Learn how to process GIS data for free using open source Python and GDAL. The data used this time is a digital elevation model of basic map information provided by the Geographical Survey Institute.

The above webmap is created with a combination of Python and GDAL.

Installation

First, use Miniconda to install Python and the required libraries. After the download is complete, open the Miniconda command line and launch the Python virtual environment (using the default Python 3 version):

conda create --name myenv
conda activate myenv

Then install the libraries used for Python scripts:

conda install -c conda-forge gdal numpy beautifulsoup4

Finally, download the Python script used to create the webmap:

git clone https://github.com/danielhoshizaki/hillshade

How to use

First, make sure you have a digital elevation model file in the `./data/raw``` directory. If you have downloaded other files, put them in `./data/raw``` at this stage.

You need to change some of the code before turning the Python script. You need to specify the path to the library GDAL installed with `conda```. GDAL is a cooperative software, but the installation is very complicated, so let's use the absolute path this time. To find the GDAL binary, use the Linux `find``` or the Windos search box. If you search for the directory of the myenv virtual environment created above, it will come out immediately. Look for gdaldem.exe and gdalbuildvrt.exe in the directory and gdal2tiles.py in the directory. Once you find it, set the gdal_bin_path and gdal_tiles_path in your Python script.

When you're ready, launch the script and wait for the webmap.

How it works

Python scripts can be broadly divided into two roles. One is to convert a raw digital elevation model file (Zipped XML file) to GeoTiff using a function called `` `convert```. The second role is to have GDAL process the data directly through the command line. There are three commands to send directly to GDAL: The following data processing is performed:

  1. Convert GeoTiff of each DEM to shading GeoTiff
  2. Combine all shading GeoTiffs into a virtual dataset vrt
  3. Convert virtual dataset to web map

The last gdal2tiles command creates a new `` `./data/WTMS``` directory. There is a file called Leaflet.html in the directory, so double-click it. Your own web map is complete! However, this web map can only be viewed on your own PC .. If you want others to see it, put it on Github Pages or AWS S3, or do your best to put it on the web suburbs!

Recommended Posts

Create a web map using Python and GDAL
Create a Mac app using py2app and Python3! !!
Create a python GUI using tkinter
[Python] Create a Batch environment using AWS-CDK
Create a simple scheduled batch using Docker's Python Image and parse-crontab
Create a GIF file using Pillow in Python
I tried web scraping using python and selenium
Create a Python module
Launch a web server with Python and Flask
Create a Python environment
Create a MIDI file in Python using pretty_midi
I tried to create a sample to access Salesforce using Python and Bottle
I want to make a web application using React and Python flask
Create a web app that converts PDF to text using Flask and PyPDF2
[Python] How to create a local web server environment with SimpleHTTPServer and CGIHTTPServer
Create a data collection bot in Python using Selenium
Create a color sensor using a Raspberry Pi and a camera
Try creating a compressed file using Python and zlib
(Python) Try to develop a web application using Django
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 1 ~
[Python] 2 Create a risk-return map for your asset portfolio
[Python] Create a ValueObject with a complete constructor using dataclasses
Implementing a generator using Python> link> yield and next ()> yield
[Python] How to create Correlation Matrix and Heat Map
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 2 ~
Create a decent shell and python environment on Windows
Create a company name extractor with python using JCLdic
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 3 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 4 ~
HTTP server and HTTP client using Socket (+ web browser) --Python3
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 5 ~
Create a dictionary in Python
Create JIRA tickets using Python
Create a python numpy array
Web scraping using Selenium (Python)
Create a directory with python
What is a python map?
Create a web surveillance camera with Raspberry Pi and OpenCV
Building a Python environment on a Mac and using Jupyter lab
[Python] Chapter 01-03 About Python (Write and execute a program using PyCharm)
Let's create a PRML diagram with Python, Numpy and matplotlib.
Get a Python web page, character encode it, and display it
[Python] Create an event-driven web crawler using AWS's serverless architecture
Create code that outputs "A and pretending B" in python
Python: Create a dictionary from a list of keys and values
Shoot time-lapse from a PC camera using Python and OpenCV
I made a Chatbot using LINE Messaging API and Python
I want to create a karaoke sound source by separating instruments and vocals using Python
Python a + = b and a = a + b are different
Creating a web application using Flask ②
I made a Line-bot using Python!
Authentication using tweepy-User authentication and application authentication (Python)
Create a DI Container in Python
Drawing a silverstone curve using python
Create a nested dictionary using defaultdict
Create a virtual environment with Python!
Create a binary file in Python
Create a python environment on centos
Clustering and visualization using Python and CytoScape
Creating a web application using Flask ①
Create a Python general-purpose decorator framework