Reading GeoTIFFs in Rust, nothing else!

Related tags

Geospatial geotiff
Overview

A TIFF Library for Rust

Version

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 TIFF struct that can be used to open GeoTIFFs and interact with them. Its use is simple:

TIFF::open("geotiff.tif");

TIFF::open(...) returns an Option, depending if the open operation was successful or not. Individual values can then be read (for the moment, only at pixels) using:

x.get_value_at(longitude, latitude);

Where longitude corresponds to the image_length and latitude to the image_width. This might be a bit counter intuitive, but seems consistent with GDAL (have to look into this).

Caution: the longitude and latitude are only in pixels, no coordinate transformations are applied!

Development and Testing

Simply run the tests using:

cargo test

TIFF Basics

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

You might also like...
Geospatial primitives and algorithms for Rust

geo Geospatial Primitives, Algorithms, and Utilities The geo crate provides geospatial primitive types such as Point, LineString, and Polygon, and pro

Rust bindings for GEOS

geos Rust bindings for GEOS C API. The supported geos version is = 3.5 Disclaimer GEOS can be a tad strict on the validity on the input geometry and

Rust bindings for the latest stable release of PROJ

PROJ Coordinate transformation via bindings to the PROJ v7.2.1 API. Two coordinate transformation operations are currently provided: projection (and i

Spatial Data Structures for Rust
Spatial Data Structures for Rust

spade Documentation Using spade Examples Project state Performance License Spade (SPAtial DatastructurEs, obviously!) implements a few nifty data stru

Rust implementation of the Martinez-Rueda Polygon Clipping Algorithm

Boolean operations on geo shapes This is an implementation of the Martinez-Rueda Polygon Clipping Algorithm in rust to integrate smoothly into the alr

Fast 2D Delaunay triangulation in Rust. A port of Delaunator.

delaunator-rs A very fast static 2D Delaunay triangulation library for Rust. A port of Delaunator. Documentation Example use delaunator::{Point, trian

port of MapBox's earcut triangulation code to Rust language
port of MapBox's earcut triangulation code to Rust language

Earcutr This is a port of the MapBox company's Earcut computer code, which triangulates polygons. Please see https://github.com/mapbox/earcut for more

Rust bindings for GDAL

gdal [] GDAL bindings for Rust. So far, you can: open a raster dataset for reading/writing get size and number of bands get/set projection and geo-tra

Rust read/write support for GPS Exchange Format (GPX)

gpx gpx is a library for reading and writing GPX (GPS Exchange Format) files. It uses the primitives provided by geo-types to allow for storage of GPS

Comments
  • Panic at `geotiff-0.0.2/src/reader.rs:303:17`

    Panic at `geotiff-0.0.2/src/reader.rs:303:17`

    I got thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0' on loading a geotiff, which libgeotiff happily parses. Unfortunately, I can not share the tiff in question.

    opened by wucke13 0
  • Cloud optomized GeoTiffs

    Cloud optomized GeoTiffs

    I am looking for ways to work with Cloud Optimized GeoTiffs in rust. I don't think this library currently supports them, and I don't think there is a good crate just now that does.

    Would there be interest in adding that functionality to this crate? I would be happy to try to do a first pass at an implementation if that's something of interest.

    opened by stuartlynn 1
  • Various changes. Not ready for merging.

    Various changes. Not ready for merging.

    This isn't ready for merging, but as I'm about to abandon it, and it's 90% of the way towards something useful I thought I'd leave it here so perhaps someone else can pick it up if it helps them.

    • Adds support for Tiled images.
    • Adds LZW compression support.
    • Adds support for floating point data (changed the signature of the api to use f64, even for integer data)

    Unfortunately the image I was hoping to decode uses the Floating point horizontal differencing. predictor which I cannot find documentation on anywhere (seems to be proprietary Adobe standard and the only implementation I could find is https://gitlab.com/libtiff/libtiff/-/blob/master/libtiff/tif_predict.c

    This seems to be a dealbreaker, so I'm giving up.

    opened by peterbraden 7
Owner
GeoRust
A collection of geospatial tools and libraries written in Rust
GeoRust
Rust crate for performing coordinate transforms

Synopsis A Rust crate use for performing coordinate transformations. The crate relies on nalgebra vectors to perform the coordinate transformations. C

Dave 25 Aug 20, 2022
An fast, offline reverse geocoder (>1,000 HTTP requests per second) in Rust.

Rust Reverse Geocoder A fast reverse geocoder in Rust. Inspired by Python reverse-geocoder. Links Crate 2.0.0 Docs 1.0.1 Docs Description rrgeo takes

Grant Miner 91 Dec 29, 2022
Geospatial primitives and algorithms for Rust

geo Geospatial Primitives, Algorithms, and Utilities The geo crate provides geospatial primitive types such as Point, LineString, and Polygon, and pro

GeoRust 989 Dec 29, 2022
Rust bindings for GDAL

gdal [] GDAL bindings for Rust. So far, you can: open a raster dataset for reading/writing get size and number of bands get/set projection and geo-tra

GeoRust 211 Jan 4, 2023
Rust bindings for the latest stable release of PROJ

PROJ Coordinate transformation via bindings to the PROJ v7.2.1 API. Two coordinate transformation operations are currently provided: projection (and i

GeoRust 96 Dec 21, 2022
Geohash for Rust

Rust-Geohash Rust-Geohash is a Rust library for Geohash algorithm. Ported from node-geohash module. Documentation Docs Check the API doc at docs.rs Li

GeoRust 74 Sep 8, 2022
Rust read/write support for well-known text (WKT)

wkt Rust read/write support for well-known text (WKT). License Licensed under either of Apache License, Version 2.0 (LICENSE-APACHE or http://www.apac

GeoRust 40 Dec 11, 2022
Google Encoded Polyline encoding & decoding in Rust.

polyline Google Encoded Polyline encoding & decoding in Rust. A Note on Coordinate Order This crate uses Coordinate and LineString types from the geo-

GeoRust 14 Dec 11, 2022
Geocoding library for Rust.

geocoding Rust utilities to enrich addresses, cities, countries, and landmarks with geographic coordinates through third-party geocoding web services.

GeoRust 55 Dec 12, 2022
Rust read/write support for GPS Exchange Format (GPX)

gpx gpx is a library for reading and writing GPX (GPS Exchange Format) files. It uses the primitives provided by geo-types to allow for storage of GPS

GeoRust 63 Dec 5, 2022