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

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.0.tar.gz (440.5 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.13 Windows x86-64

rasterio-1.4.0-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.0-cp313-cp313-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.13 macOS 11.0+ ARM64

rasterio-1.4.0-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.0-cp312-cp312-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.12 Windows x86-64

rasterio-1.4.0-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.0-cp312-cp312-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

rasterio-1.4.0-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.0-cp311-cp311-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.11 Windows x86-64

rasterio-1.4.0-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.0-cp311-cp311-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rasterio-1.4.0-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.0-cp310-cp310-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.10 Windows x86-64

rasterio-1.4.0-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.0-cp310-cp310-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rasterio-1.4.0-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.0-cp39-cp39-win_amd64.whl (25.3 MB view details)

Uploaded CPython 3.9 Windows x86-64

rasterio-1.4.0-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.0-cp39-cp39-macosx_11_0_arm64.whl (18.9 MB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

rasterio-1.4.0-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.0.tar.gz.

File metadata

  • Download URL: rasterio-1.4.0.tar.gz
  • Upload date:
  • Size: 440.5 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.0.tar.gz
Algorithm Hash digest
SHA256 e0d2ff540a4e06016cca2fb46691a10afe71343ea998c50ad8247bb125542133
MD5 90a83a792068cbc240d5351d618a5ff6
BLAKE2b-256 8236ea3957389848a1de5cb118b0b2e097eabb38a5098845b23c55569376b8c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 25.3 MB
  • Tags: CPython 3.13, 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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2a5c0894c108e72de858a945a808b0761362cf87ff437a14638f40d0c9dce8b4
MD5 176ccd5c618592f71419c62e2c0a24ac
BLAKE2b-256 11f6dc3b5c61e30cd2d88a7701ae47735f8492feb3af27ce67a583debba67d78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e8a5ea119cd79f2cff4fe62df67f0544c29930ade60991bad508f821d13a3f87
MD5 9f4936908ed86c1cbb200fbbe6ddb4dc
BLAKE2b-256 4e29fd52c2e67d0531050d897b1c3546bbf690fd60ca94d59243d6fb467b76fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af7a50ad796e37d6f166c92eeb97b527adfb18e288e67f42d9c0b5a878368de8
MD5 48fe6522d9fa5be344a4017e9f26f2e1
BLAKE2b-256 5548ee30b6e9a1c122c5c1632377c044cf2a2db9e3f0d787e0dedbbbe572287f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 81e695330fab8536950644ef1f751f4c133b6874a0dda4572f8accc15db2273b
MD5 b417d35c1f342a05c6673878390e8d0d
BLAKE2b-256 b649b1485af2adde14651a016d810be31b6a97134f70545a496bdc21f0a869b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 25.3 MB
  • Tags: CPython 3.12, 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.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 91ee8869f00568e1f6b2d27597c32fe678a4aaffe4c63de7901f4f00eca04b41
MD5 e9d93eaf598ce66624985bb83a77c45c
BLAKE2b-256 5bc53ec4c3662f0f3338baac9d4bbe62d1ab250e06f39106f97d768b70d579ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 21bbc2026a72934f39ca2c1a16e244d86b0938008d2a650d3d98b03bb67d45de
MD5 78d3263b5685495fda3d1080cbf36873
BLAKE2b-256 c5127362bc530697ceb9f04259ab53dc2aa2d5f843b5d5aec7af087ff3999a8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8e8c4e44537221c2d2978e898ba0067ccbf62420ee9fa97762541b2748b233eb
MD5 fcc42a65a4cb7352baa03f06f1470f3f
BLAKE2b-256 229f2ee256918e994aa6cde2a608592faf0ab1bda5684694c07c92d604a918e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e143ecf7db77ab44749b5101525b7cf5dfaaddc429144f13814d3ebbc81f696f
MD5 57c8e45e45faa468025dbcb9c60b3cac
BLAKE2b-256 f02ad75985c0b1d73e1ed84b54534969939a2d6f5bb40dae68fd29834275d0c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 25.3 MB
  • Tags: CPython 3.11, 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.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2d1b2e6c0fea589b5af94cad9c36f687906b20b1336aabca4327714fecdd6a8f
MD5 c3d0403db33322ea1e2144bc3fcd3e40
BLAKE2b-256 1ef44ced80df128b3d13876a39f312b8893fed3ecb7dabd67d22bf3da59676a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c1a99a7513bf1c7a9d99a84f184c8ea9d6d570ba66ed2cb73a0d6c97e06d6cc9
MD5 06c09e0122c7879520e5b60c9105c3e6
BLAKE2b-256 1f14caec7045fd7d81947e7a0214d90bfcf2e36e6b261530b0a5d3f472861fdc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c705b4e1da234f0be03082846e717c554565206bc60a2165e462ffeb03d7d9f2
MD5 0ba248ba4b9dd2ca4fff33108a39f3ad
BLAKE2b-256 e694c016e719d85bd438093a2ecd64ae21354c277f4186c28bcecd60cdaf4306

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 3c940797f94d48e32777045607f03c08be4507843a95735a74100548189b9879
MD5 79d94a89c596b4df0ee41734bda6395e
BLAKE2b-256 276ba508bdddfc1e3f2e1d4ac802914b44863aaff5aea35b3d107d3e4270f7f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 25.3 MB
  • Tags: CPython 3.10, 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.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 41d49d94c3041bf0da18bc74bf6ceb90554f462705e2436b205253ce5556cb1c
MD5 b7e13567a2c4abc0dbd8c30ac8899223
BLAKE2b-256 8d476ff35bdd13c4c1e36b82493471bc26d34a01d3c2e37f4ada470bebf015ec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 831f2911e3d09abb0717a19add5631d7c3f3f7b4beedf5be05141df792ff771e
MD5 ec7c6896c32fcbb4ef8ad4e36f5def33
BLAKE2b-256 c3b114209767daf12c6b26a489484b9988a094b369d7cacfd7918d5489d4c24a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 96d303a80bafef3ac97a76b9f849aeb09b06746a20fbd99e6d27907e4c14d8ff
MD5 b812f0d48b168e90c20df3c1d6ca0c75
BLAKE2b-256 b6b364acf9be32ed046d2f26bf2ee9d0987400d209298df225157ccab1913fef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 6873606d053979b6ef97922d8a8a9a48271ad77c7564e43b1457db71def844c2
MD5 33a9baab8eb3c2c279ada63c0a2c44e6
BLAKE2b-256 3c727d9a37df434ccecf274ffbc90c8ca264e626fe08a80b2501dc82a5ff446c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.0-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.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 260269c7ebd4939153ce97b1b4b4c7ce5b7c50bf0bb4eeec124f389550b1d912
MD5 6908edfd2c2ffec93e376013e7717182
BLAKE2b-256 61cc635d3ce84ce9986d3e4bb5df92e2785331c790d94f82955e099cf2ee4cc5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52f943d3630ba6ef29fc11b27fc857001768873bf3b819c46e4162f6069f0f26
MD5 c41f908bee5228f270ca7b2b00ed7303
BLAKE2b-256 a27ca78a997d731bac1e3198d7e8f3ce808e49a76e8236618d06e0b4972cd50f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0cffd8f1b41f4832cf9a0aa91afb238e23e2d58698338cc183a0f4285199f90b
MD5 763ae8fe8e4f431243ed978a463e85ff
BLAKE2b-256 5825b7c407500babafc87857bf339cd9aad6ad8a269d39c73bd027ae946dc4fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.0-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 ed3a3847d4e7ab863aa0ff8b20b8f61923a15497136ea3051803cc6be75f0502
MD5 f86f576db18008cb4d05fbdb35143839
BLAKE2b-256 41ca4ed95d64a765a7f9a1975d8e7d5e79a876e8cddd46ab5a488846b8e3d440

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