Overview
This guide shows you how to prepare and analyze your own land use and cover (LUC) raster datasets with OpenLand. You’ll learn how to load rasters, format them correctly, edit legends, and optimize performance for large datasets.Data Requirements
File Format
OpenLand accepts raster data in multiple formats:- GeoTIFF (.tif, .tiff) - Recommended
- RasterBrick objects
- RasterStack objects
- RasterLayer objects
- List of Raster objects
Naming Convention
Critical: Raster files must follow the naming pattern:landscape_2000.tiflanduse_2010.tifmyregion_2020.tif
Spatial Requirements
All rasters in your time series must have:- Identical extent: Same geographic boundaries
- Identical resolution: Same pixel size
- Identical projection: Same coordinate reference system
- Integer pixel values: Categories encoded as whole numbers (1, 2, 3, etc.)
Loading Data from Files
Method 1: Directory Path
Load all.tif files from a directory:
- Lists all
.tiffiles in the directory - Sorts them by filename
- Stacks them into a time series
- Extracts transition data
Method 2: RasterStack or RasterBrick
Load rasters already in R:Method 3: Named List
Use a named list of rasters:Data Validation
Check Raster Consistency
Before processing, verify your rasters are compatible:compareRaster() returns TRUE, your rasters are compatible.
Summary Functions
Use OpenLand’s built-in validation functions:Preparing Category Legends
Understanding the Legend Table
After runningcontingencyTable(), you receive a legend table with three columns:
categoryValue: The pixel value (integer)categoryName: Random placeholder names (must be edited)color: Random colors (must be edited)
Editing Category Names
- Names must be in the same order as
categoryValue - The
levelsparameter controls the legend display order - Use descriptive, consistent names
Assigning Colors
Colors must match the order ofcategoryValue:
Verify Your Legend
Always check the legend table after editing:Determining Pixel Resolution
Thepixelresolution parameter is crucial for area calculations:
[1] 30 30 (30 meters in x and y directions)
Common resolutions:
- Landsat: 30 meters
- Sentinel-2: 10 or 20 meters
- MODIS: 250, 500, or 1000 meters
- Custom: varies
contingencyTable().
Complete Example Workflow
Here’s a complete example analyzing agricultural expansion:Best Practices for Large Datasets
Memory Management
Large rasters can consume significant memory:Processing Time Considerations
For very large datasets:- Test with a subset: Crop a smaller region first
- Monitor progress: OpenLand shows progress during
crosstaboperations - Save intermediate results: Save the output of
contingencyTable()
Optimizing Raster Files
Before processing:Handling Missing Data
If your rasters have NA values:Common Issues and Solutions
Issue: “maps not found”
Cause: No.tif files in the specified directory.
Solution:
- Verify the directory path
- Ensure files have
.tifextension - Check file naming convention includes underscore and year
Issue: “Rasters do not match”
Cause: Rasters have different extents, resolutions, or projections. Solution: Reproject and resample to match:Issue: Incorrect time ordering
Cause: Files not sorted correctly by year. Solution: Verify naming convention:Issue: Colors not displaying correctly
Cause: Color vector length doesn’t match number of categories. Solution:Testing with Sample Data
Before processing your full dataset, test with sample data:Next Steps
Once your data is loaded and legends are prepared:- Run Intensity Analysis to identify change patterns
- Create visualizations to communicate results
- Explore spatial analysis functions like
acc_changes()for spatial analysis
Additional Resources
- Raster package documentation: https://rspatial.org/raster/
- GeoTIFF specification: https://www.earthdatascience.org/courses/earth-analytics/
- Color palette generators: ColorBrewer, Coolors