Skip to main content

🌍 Create 3d-printable STLs from satellite elevation data 🌏

Project description

mapa 🌍

PyPI Python Downloads Python Tests

mapa let's you create 3d-printable STL files from satellite elevation data (using DEM data).

Under the hood mapa uses:

Installation

pip install mapa

Usage

mapa provides the following approaches for creating STL files:

1. Using the mapa streamlit web app 🎈

Certainly the easiest way to interact with mapa is to use the streamlit web app. No need to install anything. Simply access it via your browser. It is based on the mapa-streamlit repo and can be accessed at:

https://share.streamlit.io/fgebhart/mapa-streamlit/main/app.py

Note, that the streamlit web app however, does not use the maximal available resolution of the ALOS DEM GeoTIFFs, as it would take too much time and cloud resources to compute STL files of e.g. multiple GBs. If you are keen in getting STL files with the highest resolution possible, I'd recommend following the next step.

2. Using the mapa interactive map 🗺

The second easiest way is using the mapa cli. After installing mapa, simply type

mapa

A jupyter notebook will be started with an interactive map. Follow the described steps by executing the cells to create a 3d model of whatever place you like.

Choose bounding box Create STL file
Slice STL file 3D print

3. Using the dem2stl cli 💻

The dem2stl cli lets you create a 3d-printable STL file based on your tiff file. You can run a demo computation to get a feeling of how the output STL will look like:

dem2stl --demo

If you have your tiff file ready, you may run something like

dem2stl --input your_file.tiff --output output.stl --model-size 200 --z-offset 3.0 --z-scale 1.5

The full list of options and their intention can be found with dem2stl --help:

Usage: dem2stl [OPTIONS]

  🌍 Convert DEM data into STL files 🌏

Options:
  --input TEXT                Path to input TIFF file.
  --output TEXT               Path to output STL file.
  --as-ascii                  Save output STL as ascii file. If not provided,
                              output file will be binary.
  --model-size INTEGER        Desired size of the generated 3d model in
                              millimeter.
  --max-res                   Whether maximum resolution should be used. Note,
                              that this flag potentially increases compute
                              time dramatically. The default behavior (i.e.
                              max_res=False) should return 3d models with
                              sufficient resolution, while the output stl file
                              should be < ~400 MB.
  --z-offset FLOAT            Offset distance in millimeter to be put below
                              the 3d model. Defaults to 4.0. Is not influenced
                              by z-scale.
  --z-scale FLOAT             Value to be multiplied to the z-axis elevation
                              data to scale up the height of the model.
                              Defaults to 1.0.
  --demo                      Converts a demo tiff of Hawaii into a STL file.
  --cut-to-format-ratio TEXT  Cut the input tiff file to a specified format.
                              Set to `1` if you want the output model to be
                              squared. Set to `0.5` if you want one side to be
                              half the length of the other side. Omit this
                              flag to keep the input format. This option is
                              particularly useful when an exact output format
                              ratio is required for example when planning to
                              put the 3d printed model into a picture frame.
                              Using this option will always try to cut the
                              shorter side of the input tiff.
  --version                   Show the version and exit.
  --help                      Show this message and exit.

4. Using mapa as python library 📚

In case you are building your own application you can simply use mapa's functionality within your application by importing the functions of the module.

from mapa import convert_tiff_to_stl

path_to_stl = convert_tiff_to_stl(
    input_file: "path/to/your/input_file.tiff",
    as_ascii: False,
    model_size: 200,
    output_file: "path/to/your/output_file.stl",
    max_res: False,
    z_offset: 3.0,
    z_scale: 1.5,
    cut_to_format_ratio: None,
)

Algorithm Deep Dive

In case you are curios about the algorithm which turns a GeoTIFF into a STL file, I'd recommend reading the header of algorithm.py.

Changelog

See Releases.

Contributing

Contributions, feedback or issues are welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mapa-0.6.1.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

mapa-0.6.1-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file mapa-0.6.1.tar.gz.

File metadata

  • Download URL: mapa-0.6.1.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.11.0-1028-azure

File hashes

Hashes for mapa-0.6.1.tar.gz
Algorithm Hash digest
SHA256 9021fe9666ceca8f738f70201ae5441385ef1310faae18fb97ece9b4769d31df
MD5 39cf8a1b8e4f6595015968d40f12831d
BLAKE2b-256 e0f3bd31702a102d842cff6fab5e8ed0f03375c16bf0cd5292d9e30f42eec577

See more details on using hashes here.

File details

Details for the file mapa-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: mapa-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.11.0-1028-azure

File hashes

Hashes for mapa-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4cdce2f1b1cd1fb66de325734a82e69e20dc5d684e698798e989900b79562758
MD5 2d7417aaaab009a984b22a06ede3fdff
BLAKE2b-256 778930a65bf7749d1cfcda3cdfdc5fd64d3f5d50a7fb30f2dc889d4ed70365be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page