Skip to main content

A package for processing digital elevation models.

Project description

TopoCurve Logo

TopoCurve

TopoCurve is a Python library for processing digital elevation models (DEM) stored in GeoTIFF format. This library provides functionalities to extract metadata, calculate principal curvatures and curvature features, as well as plot elevation values. It also includes spectral filtering capabilities for advanced DEM processing.

Installation

To install TopoCurve, simply clone the repository and install the dependencies listed in requirements.txt:

git clone https://github.com/username/topo_curve.git
cd topo_curve
pip install -r requirements.txt

Usage

from TopoCurve import TopoCurve
from SpectralFiltering import SpectralFiltering

# Instantiate TopoCurve object with a GeoTIFF file
dem = TopoCurve('path/to/your/file.tif')

# Instantiate SpectralFiltering object with a GeoTIFF file
spectral_filter = SpectralFiltering('path/to/your/file.tif')

# Apply FFT filtering
dx, dy, filtered_elevation = spectral_filter.FFT(filter, 'filtertype', alphaIn)

# Calculate principal curvatures and curvature features
K1, K2, KM, KG = dem.CurveCalc(ZFilt, dx, dy, kt)

# Plot and save elevation values
dem.plot(input_array, 'output_image.png')

Example

from TopoCurve import TopoCurve
from SpectralFiltering import SpectralFiltering

# Instantiate TopoCurve object with a GeoTIFF file
dem = TopoCurve('references\DEM_files\Purgatory.tif')

# Instantiate SpectralFiltering object with a GeoTIFF file
spectral_filter = SpectralFiltering('references\DEM_files\Purgatory.tif')

# Apply FFT filtering
dx, dy, filtered_elevation = spectral_filter.FFT([190, 200], 'lowpass', 0)

# Calculate principal curvatures and curvature features
K1, K2, KM, KG = dem.CurveCalc(filtered_elevation, dx, dy, 0)

# Plot and save elevation values
dem.plot(filtered_elevation, 'output_image.png')

API Documentation

TopoCurve Class

TopoCurve(tiff_file)

Initialize the TopoCurve object with a GeoTIFF file.

  • Parameters:
    • tiff_file (str): Path to the GeoTIFF file.

CurveCalc(ZFilt, dx, dy, kt)

Calculate principal curvatures and curvature features.

  • Parameters:

    • ZFilt (numpy.ndarray): Filtered surface data.
    • dx (float): Grid spacing in the x direction.
    • dy (float): Grid spacing in the y direction.
    • kt (float): Threshold value.
  • Returns:

    • K1, K2 (tuple): Principal curvatures.
    • KM (tuple): Mean curvature.
    • KG (tuple): Gaussian curvature.

plot(input, filename)

Plot the elevation values and save the plot as an image file to reports/figures.

  • Parameters:
    • input (numpy.ndarray): Input elevation values.
    • filename (str): Name of the output image file.

Spectral Filtering Class

SpectralFiltering(tiff_file)

Initialize the SpectralFiltering object with a GeoTIFF file.

  • Parameters:
    • tiff_file (str): Path to the GeoTIFF file.

detrend()

Detrend the elevation values using least squares plane fitting.

  • Returns:
    • Z_detrended (numpy.ndarray): Detrended elevation values.
    • plane (numpy.ndarray): Trend component of the elevation values.

mirror_dem()

Mirror the elevation values.

  • Returns:
    • mirrored_array (numpy.ndarray): Mirrored elevation values.

tukeyWindow(alphaIn)

Apply a Tukey window to the elevation values.

  • Arguments:

    • alphaIn (float): Parameter controlling the shape of the Tukey window.
  • Returns:

    • tukey_array (numpy.ndarray): Elevation values after applying the Tukey window.

padding(alphaIn)

Pad the elevation values.

  • Arguments:

    • alphaIn (float): Parameter controlling the shape of the Tukey window.
  • Returns:

    • padded_window_array (numpy.ndarray): Padded elevation values.

FFT(filter, filterType, alphaIn)

Apply FFT filtering to the elevation values.

  • Arguments:

    • filter (float): Filter parameter.
    • filterType (str): Type of filter ('lowpass' or 'highpass').
    • alphaIn (float): Parameter controlling the shape of the Tukey window.
  • Returns:

    • dx (float): Grid spacing in the x direction.
    • dy (float): Grid spacing in the y direction.
    • ZFilt (numpy.ndarray): Filtered elevation values.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project Organization

├── LICENSE              
├── Makefile             
├── README.md           
├── TC-removebg-preview.png <- Project logo.

├── docs/                <- Documentation source files for the project:
│   ├── Makefile        
│   ├── commands.rst     
│   ├── conf.py          
│   ├── getting-started.rst 
│   ├── index.rst        
│   └── make.bat        

├── references/          <- Supporting files and research materials:
│   ├── DEM_files/       <- Contains Digital Elevation Model (DEM) test files.
│   ├── paper.md         <- Markdown file with detailed project research or report.
│   └── .gitkeep        

├── reports/             <- Generated analyses and reports:
│   ├── figures/         <- Directory for report graphics and visualizations.
│   └── .gitkeep    

├── requirements.txt     
├── setup.py             
├── src/                 <- Source code for the project:
│   ├── __init__.py      
│   ├── SpectralFiltering.py <- Contains FFT-based spectral filtering methods.
│   ├── TopoCurve.py     <- Core script for curvature calculations and DEM processing.
│   ├── code_play.py     <- Experimental script with templates for further development.
│   └── test.py          <- Unit tests to validate functionality.

├── test_environment.py  
└── tox.ini              

Credits

Project based on the cookiecutter data science project template. #cookiecutterdatascience

```

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

topocurve-0.1.1.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

topocurve-0.1.1-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file topocurve-0.1.1.tar.gz.

File metadata

  • Download URL: topocurve-0.1.1.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for topocurve-0.1.1.tar.gz
Algorithm Hash digest
SHA256 07fb65a5b3645d313e71277d9278b4c524b8ae295225dafc8d52c07be06c1b58
MD5 f819ab4feb024bb87cf8f1736e5a26d3
BLAKE2b-256 f7947eea4af154102303ff1845661e62b9f34949294dfda3f410f1edc734a0e9

See more details on using hashes here.

File details

Details for the file topocurve-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: topocurve-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for topocurve-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0844b7765d9f3db40f761de0d7416e370dcaac52f75a89f2744973d0105e8e7b
MD5 7fb5d58e141831f25767d7ab89ab4fa6
BLAKE2b-256 c4605faba6dc8fdef2176a2d6449f48b2ff67d6e8f0d662d02b32b49a5c200ec

See more details on using hashes here.

Supported by

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