Skip to main content

rio-ds-mask

A Rasterio plugin for extracting an image’s dataset-level mask.

https://travis-ci.org/geowurster/rio-ds-mask.svg?branch=master https://coveralls.io/repos/github/geowurster/rio-ds-mask/badge.svg?branch=master

Usage

Usage: rio ds-mask [OPTIONS] INPUT OUTPUT

  Extract an image's dataset-level mask.

  Both output driver and datatype are derived from the input image if not
  given.

  In some cases this plugin alters GDAL's returned mask values.  When
  writing masks GDAL uses 0's for opaque and 255's for transparent, but when
  reading masks the returned value differs based on the image's datatype.  8
  bit images produce 8 bit masks where 0's are opaque and 255's are
  transparent, however 16 bit images use 0's for opaque and 1's for
  transparent, still stored as 8 bit.  If the image's datatype is 'int16' or
  'uint16' and the mask's maximum value is 1, then all 1's are translated to
  255's.  The mask's datatype is preserved.  I have not fully investigated
  all of GDAL's masking options to determine if the behavior is consistent.
  If it is found to be a deliberate choice then the normalization will be
  removed.

Options:
  -f, --format, --driver TEXT     Output format driver
  -t, --dtype [ubyte|uint8|uint16|int16|uint32|int32|float32|float64]
                                  Output data type.
  --co, --profile NAME=VALUE      Driver specific creation options.See the
                                  documentation for the selected output driver
                                  for more information.
  --help                          Show this message and exit.

This example command creates a singleband uint8 image that is acceptable to use as a GDAL mask band, meaning that pixels with a value of 255 are transparent and pixels with a vaue of 0 are opaque. The image is losslessly compressed and internally tiled.

$ rio ds-mask \
    --driver GTiff \
    tests/data/alpha.tif \
    mask.tif \
    --co COMPRESS=DEFLATE \
    --co TILED=YES

Installing

First install Rasterio, then:

$ pip install rio-ds-mask --user

Developing

$ git clone https://github.com/geowurster/rio-ds-mask.git
$ cd rio-ds-mask
$ pip install -e .\[all\]
$ pytest --cov rio-ds-mask --cov-report term-missing

License

See LICENSE.txt

Changelog

See CHANGES.md

Metadata

Release files for rio-ds-mask 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for rio-ds-mask 1.2
File Interpreter ABI Platform
rio_ds_mask-1.2-py2.py3-none-any.whl Python 2, Python 3 none any Details

Release files / rio_ds_mask-1.2-py2.py3-none-any.whl

Download URL rio_ds_mask-1.2-py2.py3-none-any.whl
Size 7.5 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
fe07f43f6ab5398cf1902001792f3a6a89fda4379c3008272017083f6d6a3232
BLAKE2b-256 checksum
How to use checksums
51efefdd7bc1030903cc5172316eeac383f721a8f65ff2a8a7c4f15c7cf19722
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2 This release

1 release file

1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page