rio mask

Masks in raster using GeoJSON features (masks out all areas not covered by features), and optionally crops the output raster to the extent of the features. Features are assumed to be in the same coordinate reference system as the input raster.

GeoJSON must be the first input file or provided from stdin:

> rio mask input.tif output.tif –geojson-mask features.json

> rio mask input.tif output.tif –geojson-mask - < features.json

If the output raster exists, it will be completely overwritten with the results of this operation.

The result is always equal to or within the bounds of the input raster.

–crop and –invert options are mutually exclusive.

–crop option is not valid if features are completely outside extent of input raster.

rio mask [OPTIONS] INPUTS... OUTPUT

Options

-o, --output <output>

Path to output file (optional alternative to a positional arg).

-j, --geojson-mask <geojson_mask>

GeoJSON file to use for masking raster. Use “-” to read from stdin. If not provided, original raster will be returned

-f, --format, --driver <driver>

Output format driver.

-a, --all, --all_touched

Use all pixels touched by features, otherwise (default) use only pixels whose center is within the polygon or that are selected by Bresenhams line algorithm

--crop

Crop output raster to the extent of the geometries. GeoJSON must overlap input raster to use –crop

-i, --invert

Inverts the mask, so that areas covered by features aremasked out and areas not covered are retained. Ignored if using –crop

--overwrite

Always overwrite an existing output file.

--co, --profile <NAME=VALUE>

Driver specific creation options. See the documentation for the selected output driver for more information.

Arguments

INPUTS... OUTPUT

Required argument(s)