Toolkit to work with imagery collected by satellites and UAVs
Project description
OversightML Imagery Toolkit
The OversightML Imagery Toolkit is a Python package that contains image processing and photogrammetry routines commonly used during the analysis of imagery collected by satellites and unmanned aerial vehicles (UAVs). It builds upon GDAL by providing additional support for images compliant with the National Imagery Transmission Format (NITF) and Sensor Independent Complex Data (SICD) standards.
Installation
The intent is to vend / distribute this software through a Python Package Index. If your environment has a distribution, you should be able to install it using pip:
pip install osml-imagery-toolkit[gdal]
If you are working from a source code, you can build and install the package from the root directory of the distribution.
pip install .[gdal]
Note that GDAL is listed as an extra dependency for this package. This is done to facilitate environments that either don't want to use GDAL or those that have their own custom installation steps for that library. Future versions of this package will include image IO backbones that have fewer dependencies.
Documentation
You can find documentation for this library in the ./doc
directory. Sphinx is used to construct a searchable HTML
version of the API documents.
tox -e docs
Example Usage
This library contains four core packages under the aws.osml
namespace.
- photogrammetry: convert locations between the image (x, y) and geodetic (lon, lat, elev) coordinate systems
- gdal: help load and manage datasets loaded by GDAL
- image_processing: common image manipulation routines
- formats: utilities for handling format specific information; normally not accessed directly
from aws.osml.gdal import GDALImageFormats, GDALCompressionOptions, load_gdal_dataset
from aws.osml.image_processing import GDALTileFactory
from aws.osml.photogrammetry import ImageCoordinate, GeodeticWorldCoordinate, SensorModel
Tiling with Updated Image Metadata
Many applications break large remote sensing images into smaller chips or tiles for distributed processing or dissemination. GDAL's Translate function provides basic capabilities, but it does not correctly update geospatial metadata to reflect the new image extent. These utilities provide those functions so tile consumers can correctly interpret the pixel information they have been provided. For NITF imagery that includes the addition of a new ICHIPB TRE. With SICD the XML ImageData elements are adjusted to identify the sub-image bounds.
# Load the image and create a sensor model
ds, sensor_model = load_gdal_dataset("./imagery/sample.nitf")
tile_factory = GDALTileFactory(ds,
sensor_model,
GDALImageFormats.NITF,
GDALCompressionOptions.NONE
)
# Bounds are [left_x, top_y, width, height]
nitf_encoded_tile_bytes = tile_factory.create_encoded_tile([0, 0, 1024, 1024])
Tiling for Display
Some images, for example 11-bit panchromatic images or SAR imagery with floating point complex data, can not be displayed directly without remapping the pixels into an 8-bit per pixel grayscale or RGB color model. The TileFactory supports creation of tiles suitable for human review by setting both the output_type and range_adjustment options.
viz_tile_factory = GDALTileFactory(ds,
sensor_model,
GDALImageFormats.PNG,
GDALCompressionOptions.NONE,
output_type=gdalconst.GDT_Byte,
range_adjustment=RangeAdjustmentType.DRA)
viz_tile = viz_tile_factory.create_encoded_tile([0, 0, 1024, 1024])
More Precise Sensor Models
OversightML provides implementations of the Replacement Sensor Model (RSM), Rational Polynomial Camera (RPC), and Sensor Independent Complex Data (SICD) sensor models to assist in geo positioning. When loading a dataset, the toolkit will construct the most accurate sensor model from the available image metadata. That sensor model can be used in conjunction with an optional elevation model to convert between image and geodetic coordinates.
ds, sensor_model = load_gdal_dataset("./imagery/sample.nitf")
elevation_model = DigitalElevationModel(
SRTMTileSet(version="1arc_v3"),
GDALDigitalElevationModelTileFactory("./local-SRTM-tiles"))
# Note the order of ImageCoordinate is (x, y)
geodetic_location_of_ul_corner = sensor_model.image_to_world(
ImageCoordinate([0, 0]),
elevation_model=elevation_model)
lon_degrees = -77.404453
lat_degrees = 38.954831
meters_above_ellipsoid = 100.0
image_location = sensor_model.world_to_image(
GeodeticWorldCoordinate([radians(lon_degrees),
radians(lat_degrees),
meters_above_ellipsoid]))
Contributing
This project welcomes contributions and suggestions. If you would like to submit a pull request, see our Contribution Guide for more information.
Security
See CONTRIBUTING for more information.
License
This library is licensed under the MIT-0 License. See the LICENSE file.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for osml-imagery-toolkit-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d76e4c28091f7d97ecb5dd5c8f183d925322e6b2c7915049aaad73b1c51b380 |
|
MD5 | c762f725419e361c457618d0d264d88a |
|
BLAKE2b-256 | 4feb8c9c57c97c43bac47a27b467ca33e6e61ca2e8a6f4bd42760d7d96ea6989 |
Hashes for osml_imagery_toolkit-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f635587a031923f920c157735b4543f6262e55d43651e90a90ac2bdb2aeef8f1 |
|
MD5 | 200ac9a6b1062d541a56f7f520a84231 |
|
BLAKE2b-256 | dc13dc70ab3164fed736a09ae62f024712e3badadada03f24254ab97ed163f45 |