DEMTOOLS
A collection of Python tools for working with DEM (Digital Elevation Model) raster files.
GDAL Installation: GDAL is required for this package. For conda environments, use
conda install gdalto install GDAL. For non-conda environments, download the appropriate wheel file from https://github.com/cgohlke/geospatial-wheels/releases to install GDAL.
Installation
pip install -e .
Features
- asproj: Assign a projection to GeoTIFF files without modifying pixel data (metadata only)
- chgnodata: Convert (replace) the nodata value of GeoTIFF files, updating pixel data accordingly
- defnodata: Assign a nodata value to GeoTIFF files without modifying pixel data (metadata only)
- chkdem (alias: deminfo): Check DEM raster file properties (resolution, projection, extent, nodata) — read-only
- mvdem: Relocate GeoTIFF files by setting a new upper-left coordinate, without modifying pixel data
- csv2tif: Convert a plain-numeric CSV raster grid to a GeoTIFF file
- tif2csv: Convert a GeoTIFF raster band to a plain-numeric CSV grid (the reverse of
csv2tif) - getmask: Extract the valid-data boundary of GeoTIFF files and save as shapefiles
- demext: Extract the bounding-box extent of GeoTIFF files and save as rectangle shapefiles
Usage
Command-line
# List all available commands
demtools -h
# Show details for a specific command
demtools-info csv2tif
# Assign a projection to all TIF files in the current directory
asproj -a --epsg 3826
asproj -i dem.tif -e 3826
# Convert nodata values for all TIF files in the current directory
chgnodata -a
# Convert nodata of a single file to -9999
chgnodata -i dem.tif -v -9999
# Set nodata metadata for all TIF files (no pixel data change)
defnodata -a -v -9999
# Check DEM raster properties (read-only)
chkdem -a
chkdem -i dem.tif
deminfo -i dem.tif
# Relocate a GeoTIFF by setting a new upper-left coordinate
mvdem -i dem.tif -x 500000 -y 2500000
# Convert a CSV grid to GeoTIFF (origin as lower-left or upper-left corner)
csv2tif -i grid.csv -o dem.tif --xll 250000 --yll 2500000 --cellsize 5 -e 32648
csv2tif -i grid.csv -o dem.tif --xul 250000 --yul 2500100 --cellsize 5 -e 32648
# Convert a GeoTIFF raster band back to a CSV grid
tif2csv -i dem.tif -o grid.csv
# Extract the valid-data boundary of all TIF files and save as shapefiles
getmask -a
getmask -i dem.tif -o SHP_MSK
# Extract the bounding-box extent of all TIF files and save as shapefiles
demext -a
demext -i dem.tif -o SHP_EXT
Python API
from demtools import asproj, chgnodata, defnodata, chkdem, mvdem, csv2tif, tif2csv, getmask, demext
# Assign a projection without touching pixel data
asproj.assign_projection("dem.tif", epsg=3826)
# Convert nodata value in a raster file
chgnodata.convert_nodata_value("dem.tif", output_nodata=-9999)
# Assign nodata metadata without touching pixel values
defnodata.define_nodata_value("dem.tif", nodata_value=-9999)
# Check DEM raster properties (read-only)
chkdem.check_dem_info("dem.tif")
# Relocate a raster by setting a new upper-left coordinate
mvdem.relocate_dem("dem.tif", x=500000, y=2500000)
# Convert CSV grid to GeoTIFF
csv2tif.csv_to_tif(
input_csv="grid.csv",
output_tif="dem.tif",
xll=250000,
yll=2500000,
cellsize=5,
nodata=-999,
epsg=32648,
)
# Convert a GeoTIFF raster band back to a CSV grid
tif2csv.tif_to_csv(
input_tif="dem.tif",
output_csv="grid.csv",
)
# Extract the valid-data boundary and save as a shapefile
getmask.save_mask_boundary("dem.tif", output_dir="SHP_MSK")
# Extract the bounding-box extent and save as a shapefile
demext.save_dem_extent("dem.tif", output_dir="SHP_EXT")
Notes
asproj,chgnodata,defnodata, andmvdemautomatically create aRAS_BAK/directory with backup copies before modifying files.chkdem(and itsdeminfoalias),tif2csv,getmask, anddemextare read-only and never modify the input file.getmaskwrites shapefiles to an output directory (defaultSHP_MSK/), one shapefile per input TIF, each holding a single polygon covering all of that file's valid-data pixels.demextwrites shapefiles to an output directory (defaultSHP_EXT/), one shapefile per input TIF, each holding a single rectangle polygon covering that file's full raster extent.csv2tifexpects a plain numeric CSV (no headers), with rows ordered from north to south;tif2csvwrites CSVs in the same row order.- GDAL must be installed separately via conda or a pre-built wheel; it is not listed in
requirements.txtas it cannot be reliably installed via pip on all platforms.
Metadata
Release files for demtools 0.13.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| demtools-0.13.0.tar.gz | 15.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| demtools-0.13.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.1 kB
Release files / demtools-0.13.0.tar.gz
| Download URL | demtools-0.13.0.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
77285b2c63bab41ce8e391333b00ba2172b9c3099b838321090bf9535efb2192
|
|
BLAKE2b-256 checksum How to use checksums |
ce88d3369c7d5fdf4135a560e3aa847ca9d7fe76e741f350960a51c89da5e309
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency logRelease files / demtools-0.13.0-py3-none-any.whl
| Download URL | demtools-0.13.0-py3-none-any.whl |
|---|---|
| Size | 24.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed5540b38f5c4cb51eddb0645525216fc2c5b33af33e19453e6d0cf85cc59a02
|
|
BLAKE2b-256 checksum How to use checksums |
e34e1953928eefbd68d1e1ff2dd1e9a2efa21526ff81a87d91f68b0050a79e0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 24, 2026.
Transparency log