Skip to main content

Fast and direct raster I/O for use with Numpy and SciPy

Project description

Rasterio reads and writes geospatial raster data.

https://github.com/rasterio/rasterio/actions/workflows/tests.yaml/badge.svg https://github.com/rasterio/rasterio/actions/workflows/test_gdal_latest.yaml/badge.svg https://github.com/rasterio/rasterio/actions/workflows/test_gdal_tags.yaml/badge.svg https://img.shields.io/pypi/v/rasterio

Geographic information systems use GeoTIFF and other formats to organize and store gridded, or raster, datasets. Rasterio reads and writes these formats and provides a Python API based on N-D arrays.

Rasterio 1.4 works with Python >= 3.9, Numpy >= 1.24, and GDAL >= 3.5. Official binary packages for Linux, macOS, and Windows with most built-in format drivers plus HDF5, netCDF, and OpenJPEG2000 are available on PyPI.

Read the documentation for more details: https://rasterio.readthedocs.io/.

Example

Here’s an example of some basic features that Rasterio provides. Three bands are read from an image and averaged to produce something like a panchromatic band. This new band is then written to a new single band TIFF.

import numpy as np
import rasterio

# Read raster bands directly to Numpy arrays.
#
with rasterio.open('tests/data/RGB.byte.tif') as src:
    r, g, b = src.read()

# Combine arrays in place. Expecting that the sum will
# temporarily exceed the 8-bit integer range, initialize it as
# a 64-bit float (the numpy default) array. Adding other
# arrays to it in-place converts those arrays "up" and
# preserves the type of the total array.
total = np.zeros(r.shape)

for band in r, g, b:
    total += band

total /= 3

# Write the product as a raster band to a new 8-bit file. For
# the new file's profile, we start with the meta attributes of
# the source file, but then change the band count to 1, set the
# dtype to uint8, and specify LZW compression.
profile = src.profile
profile.update(dtype=rasterio.uint8, count=1, compress='lzw')

with rasterio.open('example-total.tif', 'w', **profile) as dst:
    dst.write(total.astype(rasterio.uint8), 1)

The output:

http://farm6.staticflickr.com/5501/11393054644_74f54484d9_z_d.jpg

API Overview

Rasterio gives access to properties of a geospatial raster file.

with rasterio.open('tests/data/RGB.byte.tif') as src:
    print(src.width, src.height)
    print(src.crs)
    print(src.transform)
    print(src.count)
    print(src.indexes)

# Printed:
# (791, 718)
# {u'units': u'm', u'no_defs': True, u'ellps': u'WGS84', u'proj': u'utm', u'zone': 18}
# Affine(300.0379266750948, 0.0, 101985.0,
#        0.0, -300.041782729805, 2826915.0)
# 3
# [1, 2, 3]

A rasterio dataset also provides methods for getting read/write windows (like extended array slices) given georeferenced coordinates.

with rasterio.open('tests/data/RGB.byte.tif') as src:
    window = src.window(*src.bounds)
    print(window)
    print(src.read(window=window).shape)

# Printed:
# Window(col_off=0.0, row_off=0.0, width=791.0000000000002, height=718.0)
# (3, 718, 791)

Rasterio CLI

Rasterio’s command line interface, named “rio”, is documented at cli.rst. Its rio insp command opens the hood of any raster dataset so you can poke around using Python.

$ rio insp tests/data/RGB.byte.tif
Rasterio 0.10 Interactive Inspector (Python 3.4.1)
Type "src.meta", "src.read(1)", or "help(src)" for more information.
>>> src.name
'tests/data/RGB.byte.tif'
>>> src.closed
False
>>> src.shape
(718, 791)
>>> src.crs
{'init': 'epsg:32618'}
>>> b, g, r = src.read()
>>> b
masked_array(data =
 [[-- -- -- ..., -- -- --]
 [-- -- -- ..., -- -- --]
 [-- -- -- ..., -- -- --]
 ...,
 [-- -- -- ..., -- -- --]
 [-- -- -- ..., -- -- --]
 [-- -- -- ..., -- -- --]],
             mask =
 [[ True  True  True ...,  True  True  True]
 [ True  True  True ...,  True  True  True]
 [ True  True  True ...,  True  True  True]
 ...,
 [ True  True  True ...,  True  True  True]
 [ True  True  True ...,  True  True  True]
 [ True  True  True ...,  True  True  True]],
       fill_value = 0)

>>> np.nanmin(b), np.nanmax(b), np.nanmean(b)
(0, 255, 29.94772668847656)

Rio Plugins

Rio provides the ability to create subcommands using plugins. See cli.rst for more information on building plugins.

See the plugin registry for a list of available plugins.

Installation

See docs/installation.rst

Support

The primary forum for questions about installation and usage of Rasterio is https://rasterio.groups.io/g/main. The authors and other users will answer questions when they have expertise to share and time to explain. Please take the time to craft a clear question and be patient about responses.

Please do not bring these questions to Rasterio’s issue tracker, which we want to reserve for bug reports and other actionable issues.

Development and Testing

See CONTRIBUTING.rst.

Documentation

See docs/.

License

See LICENSE.txt.

Authors

The rasterio project was begun at Mapbox and was transferred to the rasterio Github organization in October 2021.

See AUTHORS.txt.

Changes

See CHANGES.txt.

Who is Using Rasterio?

See here.

Project details


Release history Release notifications | RSS feed

This version

1.4.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rasterio-1.4.1.tar.gz (440.9 kB view details)

Uploaded Source

Built Distributions

rasterio-1.4.1-cp313-cp313-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.13 Windows x86-64

rasterio-1.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

rasterio-1.4.1-cp313-cp313-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

rasterio-1.4.1-cp313-cp313-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.13 macOS 10.15+ x86-64

rasterio-1.4.1-cp312-cp312-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

rasterio-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

rasterio-1.4.1-cp312-cp312-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

rasterio-1.4.1-cp312-cp312-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.12 macOS 10.15+ x86-64

rasterio-1.4.1-cp311-cp311-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

rasterio-1.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

rasterio-1.4.1-cp311-cp311-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rasterio-1.4.1-cp311-cp311-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.11 macOS 10.15+ x86-64

rasterio-1.4.1-cp310-cp310-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

rasterio-1.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

rasterio-1.4.1-cp310-cp310-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rasterio-1.4.1-cp310-cp310-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.10 macOS 10.15+ x86-64

rasterio-1.4.1-cp39-cp39-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

rasterio-1.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

rasterio-1.4.1-cp39-cp39-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

rasterio-1.4.1-cp39-cp39-macosx_10_15_x86_64.whl (21.5 MB view details)

Uploaded CPython 3.9 macOS 10.15+ x86-64

File details

Details for the file rasterio-1.4.1.tar.gz.

File metadata

  • Download URL: rasterio-1.4.1.tar.gz
  • Upload date:
  • Size: 440.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rasterio-1.4.1.tar.gz
Algorithm Hash digest
SHA256 d750362bb792d2311f94803ff309baec48486ecba75c9b905ea9b1f5eb06ef9f
MD5 88ec246641b7369009a744bed7a2f727
BLAKE2b-256 5de992a09209093831ef02a42bb58e3ef73d20e49931ea6043d82c29319780d9

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2e6a8fbdf31053a3ff95c138976ffc8ee547f361326cb42bd26fcee26422e157
MD5 2dc2122bf5d3898ee19f727f51e20a4a
BLAKE2b-256 e4d20b8c752e9c47c7859f116330465f94995668484191fd7bb7aff0d42ab455

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2466adf39009115de23209a4b343fdb0db9a3aef97119d826d09df26b7f3beb9
MD5 6963e10536a53b1bda1de10a2cd1c2d3
BLAKE2b-256 0261c0a9bf081d23a47d17e1eed3031f5c2d11449da8f977760f73c96106ac72

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0c2f21b4fe0f6f8af0a902c4f86fb51d25a058fabf4dada1d453f8dce6be7938
MD5 639c0b3a78df6294fed9bf526e7c7bb2
BLAKE2b-256 13d7a1118060427123cf03ce38eff1b2178e742e82c205fb8a5b6908a8d0b31b

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp313-cp313-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 c5b626dc0c08dc593e462265ce974266f3e1dd90fa67807bef33704d88c62a28
MD5 2e33fc10808157217f31fbfbabe7747d
BLAKE2b-256 efbe3ec2b6a45e3ee77a660447d3f83ed22e316452593be5e6730c24ce22a232

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e7b18c4ccf0d813b6056704af86e14d6841e29ec558a9bce2f1ce2e3ee2ef70d
MD5 9beae99b65e7c9fd07c2b416eaeb2b60
BLAKE2b-256 6774159ea0e648347918a7c1d4b56b17b881453e49828feac18ab05f29896b43

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b85f7d912b868ce8dd25e01d5042c8426cc9208a715f093081503ee864e870b
MD5 58a9bd518d78acc296e7bb0f9c6a3531
BLAKE2b-256 cf9b4b3a407a3083806cf4de0add82553a8b79744a3bda0df758212d10289d23

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af5e0559eb8da3cf0adbc1d26ce86e505ea82814012b7b6711855674ae3f6425
MD5 80c283ab1c6bd5bc1bba53675249f1da
BLAKE2b-256 9288c5722be244f426db8024139fc958079b71879a935e469886edc5dbe6130a

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp312-cp312-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 a0cd7b8eda7d3b0097a42a047d2604c3f1f27b4093e2a4e1e7ad379c9f639f65
MD5 23a800bd2f198a402fb7e6cd835ee7ec
BLAKE2b-256 6a98ba5e1f4764ecde8678c6b8653150314964677ad35425b1e0d3ccc8d71a0a

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 6832fb300615e5d8649346b4aad557330cfae23bc5499832d106c415cc85173b
MD5 9c3f211784207617cab2dcfcde267032
BLAKE2b-256 fcb978aedee3aa850424037aa21da482fd659200039d16e7407ffe25e07548b5

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ef99c77d2c52bd95b42ff862c252a74c7528ec3b3cbb665c783e3948ebd811cf
MD5 fa1834160fcf606c3448e76c21b5cc29
BLAKE2b-256 7a5a9462fc26a16035cc8042ceb1604af55cad00b14cd73ef38e91942e113476

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 50fb06c2895cc055f34d813600cb5dc56b170d02c216913fdf80b573d771e972
MD5 9ce589fbd698d51a2b6383957fb773a4
BLAKE2b-256 26dc638c5e075a08f3895fbbbcbaabc4122c1fe73d30cb053c88cbdcd4f561ed

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp311-cp311-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5037188f3582cdb21a308d6cacfc6a4f2828cd05d382f8b848c8bb405a0778b4
MD5 8d7242b40669a2a61e9669e60cd6845e
BLAKE2b-256 26ea91fa2792084a4bfebd48c0c9b3d7a48777ab047213ca02f7fe6d24188958

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 33be7bc0e50c1a27a47faaac934d98275aea68db14d045130303bbd32db34d96
MD5 f78067b509c1f5bcb3a50f15f50039dd
BLAKE2b-256 fa6406a089ee86d32a3790763e2f9b3fba98c020fbbf78d21d7e02b10007180d

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f0903fe08724e99b7404c8069474eab08c50b06c3436476f8fa63e381bd0a36
MD5 57a36a5573951b62aafe83e1074349f2
BLAKE2b-256 a82d6c68d781c0dd711e1537854b29a5ca68b25cea952175d32dca72edbe7f33

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 919c3fada8825b385fa057f9dfdde502b10f65b940ce3299cc932252edb1c57b
MD5 2e8dfae30db9bcf8a982a479bbbeaa8a
BLAKE2b-256 b0c41bb5bf595c29714386fc3d600cddf88c700d4b7527cd97322dbdd93adfaa

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp310-cp310-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 b30c4f60951e70f25cca03c8c127ff1cb6eb4670c551d8561cb71f8cd5aaad3f
MD5 ac13b1617c0cc1b5d2a6905fbcb7adb8
BLAKE2b-256 2af28864969ee9707f62eff4fe9806c4df039357002adf21a8e06ee097a77c8c

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: rasterio-1.4.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 25.3 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for rasterio-1.4.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 22a7222911e96a77a5b09f1ea444cff574cc704872801b685edf5057e016ff47
MD5 66eb128876e7091dcaefac0aa8901a1d
BLAKE2b-256 782574566621cd0605fed39d660cd4015cf2ea85059637e474a7ccfcb6d2525e

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4a89441afa7cbd2f5df4e822b0d9f581971f805fa6884b59911cf238bdfa9b6
MD5 7288ed1c4eeba5d660e96fefd02d4616
BLAKE2b-256 30dc63c5e2a1ce56ffa21a11680bb0870693825e2e7e723f90cca5df1273f56d

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b53e08a86d9180d87021b0ea0d5d4eacf7c252adfaa85dafcd8f1e3daf89dbf9
MD5 7f86b56222d46a7f4fccaf7fd49a9fc6
BLAKE2b-256 c451701300256b943254a15f103154226e0f16c0d076286dcb83fb75160f5743

See more details on using hashes here.

File details

Details for the file rasterio-1.4.1-cp39-cp39-macosx_10_15_x86_64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.1-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 03f0d04ed18b4311ec807fe00fff85a9c744cb340e494dbb208ed1dc39dc1cd4
MD5 3972190617ddf95745954f5bd7e08abc
BLAKE2b-256 20ef7633241f7955e4abb604565bfa210bd467b2389bf685fc11bbd5264fe93d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page