rasterio.session module

Abstraction for sessions in various clouds.

class rasterio.session.AWSSession(session=None, aws_unsigned=None, aws_access_key_id=None, aws_secret_access_key=None, aws_session_token=None, region_name=None, profile_name=None, endpoint_url=None, requester_pays=False)

Bases: Session

Configures access to secured resources stored in AWS S3.

static aws_or_dummy(*args, **kwargs)

Create an AWSSession if boto3 is available, else DummySession

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static cls_from_path(path)

Find the session class suited to the data at path.

Parameters:

path (str) – A dataset path or identifier.

Return type:

class

property credentials

The session credentials as a dict

static from_environ(*args, **kwargs)

Create a session object suited to the environment.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static from_foreign_session(session, cls=None)

Create a session object matching the foreign session.

Parameters:
  • session (obj) – A foreign session object.

  • cls (Session class, optional) – The class to return.

Return type:

Session

static from_path(path, *args, **kwargs)

Create a session object suited to the data at path.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

get_credential_options()

Get credentials as GDAL configuration options

Return type:

dict

classmethod hascreds(config)

Determine if the given configuration has proper credentials

Parameters:
  • cls (class) – A Session class.

  • config (dict) – GDAL configuration as a dict.

Return type:

bool

class rasterio.session.AzureSession(azure_storage_connection_string=None, azure_storage_account=None, azure_storage_access_key=None, azure_unsigned=False)

Bases: Session

Configures access to secured resources stored in Microsoft Azure Blob Storage.

static aws_or_dummy(*args, **kwargs)

Create an AWSSession if boto3 is available, else DummySession

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static cls_from_path(path)

Find the session class suited to the data at path.

Parameters:

path (str) – A dataset path or identifier.

Return type:

class

property credentials

The session credentials as a dict

static from_environ(*args, **kwargs)

Create a session object suited to the environment.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static from_foreign_session(session, cls=None)

Create a session object matching the foreign session.

Parameters:
  • session (obj) – A foreign session object.

  • cls (Session class, optional) – The class to return.

Return type:

Session

static from_path(path, *args, **kwargs)

Create a session object suited to the data at path.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

get_credential_options()

Get credentials as GDAL configuration options

Return type:

dict

classmethod hascreds(config)

Determine if the given configuration has proper credentials

Parameters:
  • cls (class) – A Session class.

  • config (dict) – GDAL configuration as a dict.

Return type:

bool

class rasterio.session.DummySession(*args, **kwargs)

Bases: Session

A dummy session.

credentials

The session credentials.

Type:

dict

static aws_or_dummy(*args, **kwargs)

Create an AWSSession if boto3 is available, else DummySession

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static cls_from_path(path)

Find the session class suited to the data at path.

Parameters:

path (str) – A dataset path or identifier.

Return type:

class

static from_environ(*args, **kwargs)

Create a session object suited to the environment.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static from_foreign_session(session, cls=None)

Create a session object matching the foreign session.

Parameters:
  • session (obj) – A foreign session object.

  • cls (Session class, optional) – The class to return.

Return type:

Session

static from_path(path, *args, **kwargs)

Create a session object suited to the data at path.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

get_credential_options()

Get credentials as GDAL configuration options

Return type:

dict

classmethod hascreds(config)

Determine if the given configuration has proper credentials

Parameters:
  • cls (class) – A Session class.

  • config (dict) – GDAL configuration as a dict.

Return type:

bool

class rasterio.session.GSSession(google_application_credentials=None)

Bases: Session

Configures access to secured resources stored in Google Cloud Storage

static aws_or_dummy(*args, **kwargs)

Create an AWSSession if boto3 is available, else DummySession

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static cls_from_path(path)

Find the session class suited to the data at path.

Parameters:

path (str) – A dataset path or identifier.

Return type:

class

property credentials

The session credentials as a dict

static from_environ(*args, **kwargs)

Create a session object suited to the environment.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static from_foreign_session(session, cls=None)

Create a session object matching the foreign session.

Parameters:
  • session (obj) – A foreign session object.

  • cls (Session class, optional) – The class to return.

Return type:

Session

static from_path(path, *args, **kwargs)

Create a session object suited to the data at path.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

get_credential_options()

Get credentials as GDAL configuration options

Return type:

dict

classmethod hascreds(config)

Determine if the given configuration has proper credentials

Parameters:
  • cls (class) – A Session class.

  • config (dict) – GDAL configuration as a dict.

Return type:

bool

class rasterio.session.OSSSession(oss_access_key_id=None, oss_secret_access_key=None, oss_endpoint=None)

Bases: Session

Configures access to secured resources stored in Alibaba Cloud OSS.

static aws_or_dummy(*args, **kwargs)

Create an AWSSession if boto3 is available, else DummySession

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static cls_from_path(path)

Find the session class suited to the data at path.

Parameters:

path (str) – A dataset path or identifier.

Return type:

class

property credentials

The session credentials as a dict

static from_environ(*args, **kwargs)

Create a session object suited to the environment.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static from_foreign_session(session, cls=None)

Create a session object matching the foreign session.

Parameters:
  • session (obj) – A foreign session object.

  • cls (Session class, optional) – The class to return.

Return type:

Session

static from_path(path, *args, **kwargs)

Create a session object suited to the data at path.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

get_credential_options()

Get credentials as GDAL configuration options

Return type:

dict

classmethod hascreds(config)

Determine if the given configuration has proper credentials

Parameters:
  • cls (class) – A Session class.

  • config (dict) – GDAL configuration as a dict.

Return type:

bool

class rasterio.session.Session

Bases: object

Base for classes that configure access to secured resources.

credentials

Keys and values for session credentials.

Type:

dict

Notes

This class is not intended to be instantiated.

static aws_or_dummy(*args, **kwargs)

Create an AWSSession if boto3 is available, else DummySession

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static cls_from_path(path)

Find the session class suited to the data at path.

Parameters:

path (str) – A dataset path or identifier.

Return type:

class

static from_environ(*args, **kwargs)

Create a session object suited to the environment.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static from_foreign_session(session, cls=None)

Create a session object matching the foreign session.

Parameters:
  • session (obj) – A foreign session object.

  • cls (Session class, optional) – The class to return.

Return type:

Session

static from_path(path, *args, **kwargs)

Create a session object suited to the data at path.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

get_credential_options()

Get credentials as GDAL configuration options

Return type:

dict

classmethod hascreds(config)

Determine if the given configuration has proper credentials

Parameters:
  • cls (class) – A Session class.

  • config (dict) – GDAL configuration as a dict.

Return type:

bool

class rasterio.session.SwiftSession(session=None, swift_storage_url=None, swift_auth_token=None, swift_auth_v1_url=None, swift_user=None, swift_key=None)

Bases: Session

Configures access to secured resources stored in OpenStack Swift Object Storage.

static aws_or_dummy(*args, **kwargs)

Create an AWSSession if boto3 is available, else DummySession

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static cls_from_path(path)

Find the session class suited to the data at path.

Parameters:

path (str) – A dataset path or identifier.

Return type:

class

property credentials

The session credentials as a dict

static from_environ(*args, **kwargs)

Create a session object suited to the environment.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

static from_foreign_session(session, cls=None)

Create a session object matching the foreign session.

Parameters:
  • session (obj) – A foreign session object.

  • cls (Session class, optional) – The class to return.

Return type:

Session

static from_path(path, *args, **kwargs)

Create a session object suited to the data at path.

Parameters:
  • path (str) – A dataset path or identifier.

  • args (sequence) – Positional arguments for the foreign session constructor.

  • kwargs (dict) – Keyword arguments for the foreign session constructor.

Return type:

Session

get_credential_options()

Get credentials as GDAL configuration options :rtype: dict

classmethod hascreds(config)

Determine if the given configuration has proper credentials :param cls: A Session class. :type cls: class :param config: GDAL configuration as a dict. :type config: dict

Return type:

bool

rasterio.session.parse_bool(v)

CPLTestBool equivalent