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.
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
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.
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:
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