Skip to content

Read, write, and project with World Files for georeferenced images

License

Notifications You must be signed in to change notification settings

amandasaurus/world_image_file_rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

world_image_file

Build Status Crates.io Documentation

Read, writes and uses World Files for georeferenced images.

Example

A world file can be created from a string, or read from a file with WorldFile::from_path(&path):

use world_image_file::WorldFile;
let contents = "32.0\n0.0\n0.0\n-32.0\n691200.0\n4576000.0\n";
let w = WorldFile::from_string(&contents).unwrap();

Coordinates can be converted from image pixel to 'world' coordinates, and vice-versa.

use world_image_file::WorldFile;
let contents = "32.0\n0.0\n0.0\n-32.0\n691200.0\n4576000.0\n";
let w = WorldFile::from_string(&contents).unwrap();
assert_eq!(w.image_to_world((171., 343.)), (696672., 4565024.));
assert_eq!(w.world_to_image((696672., 4565024.)), (171., 343.));

Pixel coordinates can be fractional. (10.0, 2.0) refers to the top left of pixel (10, 2). (10.5, 2.5) is in the middle of pixel (10, 2).

World Files do not store any SRID/spatial reference system (SRS)/coordinate reference system (CRS) data. World Files were originally defined by ESRI.

Currently Result<WorldFile, ()> is returned (i.e. all errors are flatted to ()), but this may change to be more descriptive, and would not be seen as a breaking change.

Copyright & Licence

Copyright GNU Affero GPL v3 (or later). See the file LICENCE

About

Read, write, and project with World Files for georeferenced images

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages