A Rust library and CLI tool for generating fake GeoTIFF files. Perfect for testing GIS applications, creating fixtures, and generating sample raster data.
- Generate GeoTIFF files with customizable dimensions, bands, and data types
- Support for COG creation
- Multiple built-in data patterns (gradient, sine wave, noise)
- Support for custom data generation patterns
- Configurable parameters (projection, transform)
- Available as both a library and CLI tool
- Supports various data types (u8, u16, i16, u32, i32, f32, f64)
Add this to your Cargo.toml
:
[dependencies]
rasterfakers = "0.2.0"
cargo install rasterfakers --force
Note: RasterFakers depends on the GDAL library. Please ensure GDAL is installed on your system.
use rasterfakers::{FakeGeoTiffBuilder, GeoTransform, SineWavePattern};
// Create a Cloud Optimized GeoTIFF with custom settings
let geotiff = FakeGeoTiffBuilder::new()
.dimensions(256, 256)?
.bands(3)?
.projection("EPSG:4326")
.geotransform(GeoTransform::default())
.output_path("output_cog.tiff")
.data_generator(Box::new(SineWavePattern))
.cloud_optimized(true)
.build::<f32>()?;
geotiff.write()?;
# Generate a basic GeoTIFF
rasterfakers -o output.tiff
# Generate a Cloud Optimized GeoTIFF
rasterfakers -o cog_output.tiff --cloud-optimized
# Customize dimensions, data type, and pattern
rasterfakers -o custom_cog.tiff -w 512 -e 512 -t f32 -n sine --cloud-optimized
# Specify projection and resolution
rasterfakers -o projected_cog.tiff -p "EPSG:4326" -r "0.1,0.1" -c "30.0,10.0" --cloud-optimized
Options:
-o, --output <PATH> Output file path
-w, --width <N> Width of the GeoTIFF [default: 256]
-e, --height <N> Height of the GeoTIFF [default: 256]
-b, --bands <N> Number of bands [default: 1]
-t, --data-type <TYPE> Data type (u8, u16, i16, u32, i32, f32, f64) [default: f64]
-p, --projection <PROJ> Projection (e.g., EPSG:4326) [default: EPSG:4326]
-r, --pixel-resolution <RES> Pixel resolution (e.g., "0.25,0.25") [default: "1.0,1.0"]
-c, --upper-left-corner <COORDS> Upper-left corner coordinates [default: "0.0,0.0"]
-n, --pattern <PATTERN> Data pattern (gradient, sine, noise) [default: gradient]
--cloud-optimized Generate a Cloud Optimized GeoTIFF
-h, --help Print help
-V, --version Print version
Check out the examples directory for more detailed usage examples:
examples/basic_usage.rs
: Simple library usageexamples/custom_pattern.rs
: Creating custom data patternsexamples/cli_examples.sh
: Various CLI usage examples
You can create custom data patterns by implementing the DataGenerator
trait:
use rasterfakers::DataGenerator;
struct CustomPattern;
impl DataGenerator for CustomPattern {
fn generate(&self, x: usize, y: usize, band: usize) -> f64 {
// Your custom pattern logic here
(x * y * band) as f64
}
}
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.