Skip to content

adriannnv/generate-district-stl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STL generator of districts within a country.

This Python script generates 3D printable STL files of geographical districts from a Digital Elevation Model (DEM) and a GeoJSON file. It's designed to create physical terrain models for visualization, education, or personal projects.


Requirements

The script relies on several Python libraries. Install them via pip:

pip install geopandas rasterio numpy pyvista shapely

Usage

Run the script from the command line, providing the paths to your district boundaries and DEM files.

Basic Command

python your_script_name.py path/to/districts.geojson path/to/dem.tif

Optional Arguments

Customize the output with the following flags:

  • -o, --output <folder_name>: Specifies the output directory for the STL files. Defaults to stl_districts.
  • -e, --exaggeration <factor>: Sets the vertical exaggeration for terrain features. A higher value makes mountains appear taller. The default is 5.
  • -s, --scale <mm>: Defines the target size of the model's longest side in millimeters. Defaults to 180.
  • -c, --epsg <code_number>: Reprojects input files to a specified EPSG coordinate system. This is crucial if your GeoJSON and DEM files use different systems. For example, use 4326 for WGS 84.

Example

This command generates a model with a vertical exaggeration of 10 and a longest side of 200 mm, reprojecting the data to EPSG 32633.

python your_script_name.py data/districts.geojson data/elevation.tif -o output_models -e 10 -s 200 -c 32633
I used https://www.mapsforeurope.org/datasets/euro-dem for a DEM of europe then found out that ESPG:4026 fits my country exactly (Moldova)
my command looks like this.
python3 script.py moldova_districts.geojson eurodem.tif -c 4026
warning: it did turn a 1gb DEM (eurodem) to a temporary 41gb DEM. But hey it deletes itself after usage and works.

Input Files

Districts File (.geojson)

A GeoJSON file containing the district polygons. The script processes each polygon to create a separate STL file. By default, it uses the "shapeName" property for naming the output files; otherwise, it assigns a generic name like district_0.

DEM File (.tif)

A GeoTIFF file containing elevation data. The resolution of this file dictates the detail of the final 3D model.

About

Generate 3d printable stl's of a district within a country using DEMs and district polygons

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors