XarraySourceConfig#

Note

All Configs are derived from rastervision.pipeline.config.Config, which itself is a pydantic Model.

pydantic model XarraySourceConfig[source]#

Configure an XarraySource.

Show JSON schema
{
   "title": "XarraySourceConfig",
   "description": "Configure an :class:`.XarraySource`.",
   "type": "object",
   "properties": {
      "channel_order": {
         "title": "Channel Order",
         "description": "The sequence of channel indices to use when reading imagery.",
         "type": "array",
         "items": {
            "type": "integer"
         }
      },
      "transformers": {
         "title": "Transformers",
         "default": [],
         "type": "array",
         "items": {
            "$ref": "#/definitions/RasterTransformerConfig"
         }
      },
      "bbox": {
         "title": "Bbox",
         "description": "User-specified bbox in pixel coords in the form (ymin, xmin, ymax, xmax). Useful for cropping the raster source so that only part of the raster is read from.",
         "type": "array",
         "minItems": 4,
         "maxItems": 4,
         "items": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            },
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ]
      },
      "type_hint": {
         "title": "Type Hint",
         "default": "xarray_source",
         "enum": [
            "xarray_source"
         ],
         "type": "string"
      },
      "stac": {
         "title": "Stac",
         "description": "STAC Item or ItemCollection to build the DataArray from.",
         "anyOf": [
            {
               "$ref": "#/definitions/STACItemConfig"
            },
            {
               "$ref": "#/definitions/STACItemCollectionConfig"
            }
         ]
      },
      "allow_streaming": {
         "title": "Allow Streaming",
         "description": "If False, load the entire DataArray into memory. Defaults to True.",
         "default": true,
         "type": "boolean"
      },
      "bbox_map_coords": {
         "title": "Bbox Map Coords",
         "description": "Optional user-specified bbox in EPSG:4326 coords of the form (ymin, xmin, ymax, xmax). Useful for cropping the raster source so that only part of the raster is read from. This is ignored if bbox is also specified. Defaults to None.",
         "type": "array",
         "minItems": 4,
         "maxItems": 4,
         "items": [
            {
               "type": "number"
            },
            {
               "type": "number"
            },
            {
               "type": "number"
            },
            {
               "type": "number"
            }
         ]
      },
      "temporal": {
         "title": "Temporal",
         "description": "Whether the data is a time-series.",
         "default": false,
         "type": "boolean"
      },
      "stackstac_args": {
         "title": "Stackstac Args",
         "description": "Optional arguments to pass to stackstac.stack().",
         "default": {},
         "type": "object"
      }
   },
   "required": [
      "stac"
   ],
   "additionalProperties": false,
   "definitions": {
      "RasterTransformerConfig": {
         "title": "RasterTransformerConfig",
         "description": "Configure a :class:`.RasterTransformer`.",
         "type": "object",
         "properties": {
            "type_hint": {
               "title": "Type Hint",
               "default": "raster_transformer",
               "enum": [
                  "raster_transformer"
               ],
               "type": "string"
            }
         },
         "additionalProperties": false
      },
      "STACItemConfig": {
         "title": "STACItemConfig",
         "description": "Specify a raster via a STAC Item.",
         "type": "object",
         "properties": {
            "uri": {
               "title": "Uri",
               "description": "URI to a JSON-serialized STAC Item.",
               "type": "string"
            },
            "assets": {
               "title": "Assets",
               "description": "Subset of assets to use. This should be a list of asset keys",
               "type": "array",
               "items": {
                  "type": "string"
               }
            },
            "type_hint": {
               "title": "Type Hint",
               "default": "stac_item",
               "enum": [
                  "stac_item"
               ],
               "type": "string"
            }
         },
         "required": [
            "uri"
         ],
         "additionalProperties": false
      },
      "STACItemCollectionConfig": {
         "title": "STACItemCollectionConfig",
         "description": "Specify a raster via a STAC ItemCollection.",
         "type": "object",
         "properties": {
            "uri": {
               "title": "Uri",
               "description": "URI to a JSON-serialized STAC ItemCollection.",
               "type": "string"
            },
            "assets": {
               "title": "Assets",
               "description": "Subset of assets to use. This should be a list of asset keys",
               "type": "array",
               "items": {
                  "type": "string"
               }
            },
            "type_hint": {
               "title": "Type Hint",
               "default": "stac_item_collection",
               "enum": [
                  "stac_item_collection"
               ],
               "type": "string"
            }
         },
         "required": [
            "uri"
         ],
         "additionalProperties": false
      }
   }
}

Config
  • extra: str = forbid

  • validate_assignment: bool = True

Fields
field allow_streaming: bool = True#

If False, load the entire DataArray into memory. Defaults to True.

field bbox: Optional[Tuple[int, int, int, int]] = None#

User-specified bbox in pixel coords in the form (ymin, xmin, ymax, xmax). Useful for cropping the raster source so that only part of the raster is read from.

field bbox_map_coords: Optional[Tuple[float, float, float, float]] = None#

Optional user-specified bbox in EPSG:4326 coords of the form (ymin, xmin, ymax, xmax). Useful for cropping the raster source so that only part of the raster is read from. This is ignored if bbox is also specified. Defaults to None.

field channel_order: Optional[List[int]] = None#

The sequence of channel indices to use when reading imagery.

field stac: Union[STACItemConfig, STACItemCollectionConfig] [Required]#

STAC Item or ItemCollection to build the DataArray from.

field stackstac_args: Dict[str, Any] = {}#

Optional arguments to pass to stackstac.stack().

field temporal: bool = False#

Whether the data is a time-series.

field transformers: List[RasterTransformerConfig] = []#
field type_hint: Literal['xarray_source'] = 'xarray_source'#
build(tmp_dir: Optional[str] = None, use_transformers: bool = True) XarraySource[source]#

Build an instance of the corresponding type of object using this config.

For example, BackendConfig will build a Backend object. The arguments to this method will vary depending on the type of Config.

Parameters
Return type

XarraySource

classmethod deserialize(inp: str | dict | Config) Self#

Deserialize Config from a JSON file or dict, upgrading if possible.

If inp is already a Config, it is returned as is.

Parameters

inp (str | dict | Config) – a URI to a JSON file or a dict.

Return type

Self

classmethod from_dict(cfg_dict: dict) Self#

Deserialize Config from a dict.

Parameters

cfg_dict (dict) – Dict to deserialize.

Return type

Self

classmethod from_file(uri: str) Self#

Deserialize Config from a JSON file, upgrading if possible.

Parameters

uri (str) – URI to load from.

Return type

Self

recursive_validate_config()#

Recursively validate hierarchies of Configs.

This uses reflection to call validate_config on a hierarchy of Configs using a depth-first pre-order traversal.

revalidate()#

Re-validate an instantiated Config.

Runs all Pydantic validators plus self.validate_config().

Adapted from: https://github.com/samuelcolvin/pydantic/issues/1864#issuecomment-679044432

to_file(uri: str, with_rv_metadata: bool = True) None#

Save a Config to a JSON file, optionally with RV metadata.

Parameters
  • uri (str) – URI to save to.

  • with_rv_metadata (bool) – If True, inject Raster Vision metadata such as plugin_versions, so that the config can be upgraded when loaded.

Return type

None

update(pipeline: Optional[RVPipelineConfig] = None, scene: Optional[SceneConfig] = None) None#

Update any fields before validation.

Subclasses should override this to provide complex default behavior, for example, setting default values as a function of the values of other fields. The arguments to this method will vary depending on the type of Config.

Parameters
Return type

None

validate_config()#

Validate fields that should be checked after update is called.

This is to complement the builtin validation that Pydantic performs at the time of object construction.

validate_list(field: str, valid_options: List[str])#

Validate a list field.

Parameters
  • field (str) – name of field to validate

  • valid_options (List[str]) – values that field is allowed to take

Raises

ConfigError – if field is invalid