- Notifications
You must be signed in to change notification settings - Fork29
Reading GeoTIFFs in Rust, nothing else!
License
georust/geotiff
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Important
This crate has went through a significant refactoring process to be built on top ofthetiff
crate in 2024/2025, but do expect breakingchanges post v0.1.0, as we may decide to do another redesign to work towardsasynchronous reading (see thread at#13).That said, there are still many features to add, so contributions are welcome!
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:
- Gavin Baker's TIFF (discontinued, it seems:https://github.com/gavinb/rust-tiff).
- The GeoTIFF library from Whitebox (https://github.com/jblindsay/whitebox-tools/tree/fe9c5be29b01d74d1e135b79cc6328f088755b1d/src/raster/geotiff).
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 theGDAL bindings for Rust. Depending on your usecase, it might be easier to use.
The library exposes aGeoTiff
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 aTiffResult<GeoTiff>
, and depending on whether the readoperation 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);
Wherex
corresponds to Longitude/Eastings andy
to Latitude/Northings, depending onwhether the GeoTIFF file uses a geographic or projected reference system. The0
refersto the band/channel number.
Simply run the tests using:
cargo test
Several documents describe the structure of a (Geo)TIFF:
- The official TIFF specification:http://download.osgeo.org/geotiff/spec/tiff6.pdf.
- The official GeoTIFF specitication:http://download.osgeo.org/geotiff/spec/geotiff.rtf
- The article "GeoTIFF – A standard image file format for GIS applications" by Mahammad and Ramakrishnan:https://www.geospatialworld.net/article/geotiff-a-standard-image-file-format-for-gis-applications/
About
Reading GeoTIFFs in Rust, nothing else!
Topics
Resources
License
Code of conduct
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.