This project allows you to generate detailed terrain maps with various geographical features like roads, rivers, buildings, and country boundaries. It fetches elevation data from a Terrarium dataset and geographical data from OpenStreetMap (OSM) to create visually rich maps. It generates a high-quality, print-ready file.
![]() |
|
![]() |
![]() |
To run this project, you'll need Python and a few libraries.
Make sure you have Python 3.8 or newer installed. You can download it from python.org.
-
Clone the repository (if it's in a Git repository):
git clone [https://github.com/mdimitri/elevationAnalysis.git](https://github.com/mdimitri/elevationAnalysis.git) cd elevationAnalysisIf not, just make sure both
mapSelector.pyandmakeMap_epsg4326.pyare in the same directory. -
Install the required Python libraries: Open your terminal or command prompt and run:
pip install requests pillow numpy matplotlib geopandas pandas shapely rasterio pyproj tqdm scikit-image osm2geojson geodatasets pyperclip
mapSelector.py: This is a new graphical user interface (GUI) script. It allows you to visually select a geographical area on a base map and download the corresponding elevation data as a.npzfile.makeMap_epsg4326.py: This is the main map generation script. It takes the elevation data generated bymapSelector.py, fetches various geographical features from OpenStreetMap, and then uses Matplotlib to render a detailed map. It can also cache fetched data to speed up subsequent runs.
First, use the mapSelector.py GUI to download the terrain heightmap for your desired area.
- Open your terminal or command prompt and run:
python mapSelector.py
- A new window will appear with a world map. Click and drag to select your desired geographical area.
- When you release the mouse, a popup will ask for confirmation to download the tiles. Click "Yes".
- Once the download is complete, the script will save the elevation data as a
.npzfile in theheightmap_datadirectory. The filename will be automatically copied to your clipboard.
Now that you have the elevation data, you can generate the detailed map.
- Open
makeMap_epsg4326.pyin a text editor. - In the
main()function, find therasterPathvariable. - Change the value of
rasterPathto the path of the.npzfile you downloaded in Step 1. - (Optional) You can also adjust the following variables in the
main()function to customize your map:dpi: The resolution of the output image in dots per inch.resolutionFactor: A factor to scale the output resolution.resolution: Controls the detail of geographical features.subsample: A number to subsample the elevation data for faster rendering.exagerateTerrain: Set toTruefor hill shading to create a 3D effect.
- Save the file and run it from your terminal or command prompt:
python makeMap_epsg4326.py
- The script will generate a PNG file of your map in the current directory.
Contributions are welcome! Feel free to fork the project, open issues, or submit pull requests with improvements!
Copyright (c) [2025] [Geographical Map Generator]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- Terrarium Tiles: For providing global elevation data.
- OpenStreetMap (OSM): For the rich geographical feature data.
- Matplotlib: For plotting and visualization.
- GeoPandas, Shapely, rasterio, pyproj, osm2geojson: For geospatial data handling.


