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.3

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

Uploaded Source

Built Distributions

rasterio-1.4.3-cp313-cp313-win_amd64.whl (25.4 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

rasterio-1.4.3-cp313-cp313-macosx_14_0_arm64.whl (18.7 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

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

Uploaded CPython 3.13macOS 10.15+ x86-64

rasterio-1.4.3-cp312-cp312-win_amd64.whl (25.4 MB view details)

Uploaded CPython 3.12Windows x86-64

rasterio-1.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (22.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

rasterio-1.4.3-cp312-cp312-macosx_14_0_arm64.whl (18.7 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

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

Uploaded CPython 3.12macOS 10.15+ x86-64

rasterio-1.4.3-cp311-cp311-win_amd64.whl (25.5 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

rasterio-1.4.3-cp311-cp311-macosx_14_0_arm64.whl (18.8 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

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

Uploaded CPython 3.11macOS 10.15+ x86-64

rasterio-1.4.3-cp310-cp310-win_amd64.whl (25.4 MB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

rasterio-1.4.3-cp310-cp310-macosx_14_0_arm64.whl (18.8 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

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

Uploaded CPython 3.10macOS 10.15+ x86-64

rasterio-1.4.3-cp39-cp39-win_amd64.whl (25.4 MB view details)

Uploaded CPython 3.9Windows x86-64

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

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

rasterio-1.4.3-cp39-cp39-macosx_14_0_arm64.whl (18.8 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

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

Uploaded CPython 3.9macOS 10.15+ x86-64

File details

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

File metadata

  • Download URL: rasterio-1.4.3.tar.gz
  • Upload date:
  • Size: 443.0 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.3.tar.gz
Algorithm Hash digest
SHA256 201f05dbc7c4739dacb2c78a1cf4e09c0b7265b0a4d16ccbd1753ce4f2af350a
MD5 389b921999b91aa04e48b99b87d61923
BLAKE2b-256 de19ab4326e419b543da623ce4191f68e3f36a4d9adc64f3df5c78f044d8d9ca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 25.4 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.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1839960e2f3057a6daa323ccf67b330f8f2f0dbd4a50cc7031e88e649301c5c0
MD5 f1bffaad81759f2d27c65b5f44a0856a
BLAKE2b-256 df889db5f49ebfdd9c12365e4cac76c34ccb1a642b1c8cbab4124b3c681495de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d9bab1a0bb22b8bed1db34b5258db93d790ed4e61ef21ac055a7c6933c8d5e84
MD5 5baaddeaea00fc3bc5cdfddfa5402a5e
BLAKE2b-256 051994d6c66184c7d0f9374330c714f62c147dbb53eda9efdcc8fc6e2ac454c5

See more details on using hashes here.

File details

Details for the file rasterio-1.4.3-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.3-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 98a9c89eade8c779e8ac1e525269faaa18c6b9818fc3c72cfc4627df71c66d0d
MD5 7ca5e669875dc431e08d48581bfef329
BLAKE2b-256 bba83b6b11923300d6835453d1157fabb518338067a67366c5c52e9df9a2314f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp313-cp313-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 5d4fcb635379b3d7b2f5e944c153849e3d27e93f35ad73ad4d3f0b8a580f0c8e
MD5 64993bd0834d8c36c53628f6bbd9419d
BLAKE2b-256 2ee0718c06b825d1f62077913e5bff1e70b71ac673718b135d55a0256d88d4ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 25.4 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.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a962ad4c29feaf38b1d7a94389313127de3646a5b9b734fbf9a04e16051a27ff
MD5 4d054a8c61ee383e031a3e30ea587d2f
BLAKE2b-256 becc453816b489af94b9a243eda889865973d518989ba6923b2381f6d6722b43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e90c2c300294265c16becc9822337ded0f01fb8664500b4d77890d633d8cd0e
MD5 40ba633f2a87686558a0d1a6e00f8bb9
BLAKE2b-256 6772331727423b28fffdfd8bf18bdc55c18d374c0fefd2dde390cd833f8f4477

See more details on using hashes here.

File details

Details for the file rasterio-1.4.3-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.3-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 38a126f8dbf405cd3450b5bd10c6cc493a2e1be4cf83442d26f5e4f412372d36
MD5 a1e662c6bc43918ecca15709b88d9d3e
BLAKE2b-256 b2eae21010457847b26bb4aea3983e9b44afbcefef07defc5e9a3285a8fe2f0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp312-cp312-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 e703e4b2c74c678786d5d110a3f30e26f3acfd65f09ccf35f69683a532f7a772
MD5 c89aa1050a5453f38026eeb7fef0b095
BLAKE2b-256 5af2b7417292ceace70d815760f7e41fe5b0244ebff78ede11b1ffa9ca01c370

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 25.5 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.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4009f7ce4e0883d8e5b400970daa3f1ca309caac8916d955722ee4486654d452
MD5 9859d0e46c22e3b237521cb4b222fcd6
BLAKE2b-256 7e1f56462740694de764fde264051224fcbf800dad43cac92a66753153128866

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54eef32d20a0dfbba59a8bb9828e562c3e9e97e2355b8dfe4a5274117976059f
MD5 c9af1f292b8ee55dcc6ba1ce72f09bd3
BLAKE2b-256 aafa723fa6a48a419b044146cd92fa6a66ead8532d96c352fbc2f2a1546cb5b6

See more details on using hashes here.

File details

Details for the file rasterio-1.4.3-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.3-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 812c854e7177064aeb58def2d59752887ad6b3d39ff3f858ed9df3f2ddc95613
MD5 f59574a22fd3dd4947cc0e8cbff18edb
BLAKE2b-256 b359ca86697161206233eea6353237b0c0f02f6f70434144db162f964a7e1b19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp311-cp311-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 9c30114d95ebba4ff49f078b3c193d29ff56d832588649400a3fa78f1dda1c96
MD5 85fb5006e9c3fcb120c51c684f142c68
BLAKE2b-256 f3fdba3850e4cbccc47d03037f2c96889f7f221a674a7be6665c7da7cd483a07

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 25.4 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.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e79847a5a0e01399457a1e02d8c92040cb56729d054fe7796f0c17b246b18bf0
MD5 0348505e92a179e51dfb57dd0bedfcf6
BLAKE2b-256 512ff72f77633aecba9afda903f9201c566520cc2dfeb0e1e0d36c102aa18189

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5b8a4311582274de2346450e5361d092b80b8b5c7b02fda6203402ba101ffabf
MD5 5ced1da2fa1ba1269a5330143ef5af9b
BLAKE2b-256 c1f55cc3a8ee9deee2292432d69237ab4c5364f886844234d8e6dad29358aef0

See more details on using hashes here.

File details

Details for the file rasterio-1.4.3-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.3-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 1a6e6ca9ec361599b48c9918ce25adb1a9203b8c8ca9b34ad78dccb3aef7945a
MD5 44afbf63c721205836f8d739fe653366
BLAKE2b-256 28e697914b0c1824106ae9499446515915db3b4a8924d0568b6e888f4d305472

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp310-cp310-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 80f994b92e5dda78f13291710bd5c43efcfd164f69a8a2c20489115df9d178c8
MD5 fc9e39f711d4c2d06474bc02c22f53f2
BLAKE2b-256 b61bfbc6e3f11fe42898c787d27b6844f660bdd7081967d5f68b950c4bd9f043

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rasterio-1.4.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 25.4 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.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a702e21712ba237e34515d829847f9f5f06d8e665e864a7bb0a3d4d8f6dec10d
MD5 89a0e45f8ab34a5e5299134aa0b3f933
BLAKE2b-256 bde55a29b8b098067e8983b1592a3447d3928721d8ad3a7c4cee482e501942ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 597f8dcf494d0ca4254434496e83b1723fec206d23d64da5751a582a2b01e1d3
MD5 28ea18645df840472e88313f21b02d8f
BLAKE2b-256 e19352f8514173501efe3b1987d668868507f7f60e6cf246960ed132c5c2d1b3

See more details on using hashes here.

File details

Details for the file rasterio-1.4.3-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for rasterio-1.4.3-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3f411a6a5bcb81ab6dc9128a8bccd13d3822cfa4a50c239e3a0528751a1ad5fc
MD5 afcd661add377f3d1bc85408a1468c46
BLAKE2b-256 38af60768ad82f7e03a5180fb087b60cbe0522893b2153a313a0a530325eaff2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rasterio-1.4.3-cp39-cp39-macosx_10_15_x86_64.whl
Algorithm Hash digest
SHA256 af04f788f6f814569184bd9da6c5d9889512212385ab58c52720dfb1f972671d
MD5 9b6c630bc1b59f7ccd9071bfc558b914
BLAKE2b-256 7d60b5fb8d42b56eae56209fbf85392579841536bce15429bf5a1536f309e6db

See more details on using hashes here.

Supported by

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