geotiff

Crates.iogeotiff
lib.rsgeotiff
version0.1.0
created_at2021-02-05 13:01:17.4056+00
updated_at2025-06-10 08:40:01.267435+00
descriptionA GeoTIFF library for Rust
homepage
repositoryhttps://github.com/georust/geotiff
max_upload_size
id351049
size3,098,900
geotiff-publishers (github:georust:geotiff-publishers)

documentation

README

A GeoTIFF library for Rust

geotiff on crates.io docs.rs

[!IMPORTANT] This crate has went through a significant refactoring process to be built on top of the tiff crate in 2024/2025, but do expect breaking changes post v0.1.0, as we may decide to do another redesign to work towards asynchronous reading (see thread at https://github.com/georust/geotiff/issues/13). That said, there are still many features to add, so contributions are welcome!

Motivation (pre-2020)

I needed this library to import elevation models for a routing library. As elevation models usually come in GeoTIFF format, but no such library was available for Rust, I created this library, taking other libraries as inspiration:

The purpose of this library is to simply read GeoTIFFs, nothing else. It should work for other TIFFs as well, I guess, but TIFFs come in many flavors, and it's not intended to cover them all.

In its current state, it works for very basic GeoTIFFs, which sufficed to extract elevation data for use in the routing library. In case you want to extend the library or have suggestions for improvement, feel free to contact me, open an issue ticket or send a pull request.

You might also consider the GDAL bindings for Rust. Depending on your usecase, it might be easier to use.

Library Usage

The library exposes a GeoTiff struct that can be used to open GeoTIFFs and interact with them. Its use is simple:

use geotiff::GeoTiff;

let reader = GeoTiff::read("geotiff.tif")?;

GeoTiff::read(...) returns a TiffResult<GeoTiff>, and depending on whether the read operation was successful or not, individual values can then be read (for the moment, only at pixels) using:

use geo_types::Coord;

reader.get_value_at::<u8>(&Coord { x: 10, y: 20 }, 0);

Where x corresponds to Longitude/Eastings and y to Latitude/Northings, depending on whether the GeoTIFF file uses a geographic or projected reference system. The 0 refers to the band/channel number.

Development and Testing

Simply run the tests using:

cargo test

TIFF Basics

Several documents describe the structure of a (Geo)TIFF:

Commit count: 41

cargo fmt