API
The section shows information about the API relevant for the developers. Once the platform
is hosted, you can view the documentation at /redoc
endpoint.
Example
Stacture
stacture.api.base
BaseAPI()
Bases: ABC
get_api_router()
abstractmethod
get_collection_links(request, collection_id, collection_conf)
abstractmethod
LinkType
Bases: BaseModel
href: str
instance-attribute
hreflang: str | None = None
class-attribute
instance-attribute
length: int | None = None
class-attribute
instance-attribute
rel: str
instance-attribute
title: str | None = None
class-attribute
instance-attribute
type: str | None = None
class-attribute
instance-attribute
stacture.api.core
ConfigAnnotated = Annotated[Config, Depends(get_config)]
module-attribute
router = APIRouter()
module-attribute
CoreAPI()
Bases: BaseAPI
get_api_router()
get_collection_links(request, collection_id, collection_conf)
Source code in stacture/stacture/api/core.py
get_landing_page_links(request)
Source code in stacture/stacture/api/core.py
collection(request, collection_id, config)
async
collections(request, config)
async
Source code in stacture/stacture/api/core.py
get_collection_description(request, registry, config, collection_id)
async
Source code in stacture/stacture/api/core.py
landing_page(request, config)
async
Source code in stacture/stacture/api/core.py
stacture.api.coverages
__all__ = ['CoveragesAPI']
module-attribute
CoveragesAPI()
Bases: BaseAPI
get_api_router()
get_collection_links(request, collection_id, collection_conf)
Source code in stacture/stacture/api/coverages/api.py
stacture.api.maps
FLOAT_LIST_PATTERN = '^(-?\\d+(\\.\\d+)?,){3}-?\\d+(\\.\\d+)?$'
module-attribute
GetMapCommon = Annotated[GetMapParameters, Depends(get_map_common)]
module-attribute
HEX_COLOR_PATTERN = '^0x(?:[0-9a-fA-F]{3}){1,2}$'
module-attribute
LOGGER = structlog.get_logger()
module-attribute
MAP_REL = 'http://www.opengis.net/def/rel/ogc/1.0/map'
module-attribute
maps_api = MapsAPI()
module-attribute
router = APIRouter()
module-attribute
GetMapParameters
Bases: BaseModel
accept: str
instance-attribute
bbox: BBox
instance-attribute
bgcolor: str
instance-attribute
height: int
instance-attribute
transparent: bool
instance-attribute
width: int
instance-attribute
MapsAPI()
Bases: BaseAPI
get_api_router()
get_collection_links(request, collection_id, collection_conf)
Source code in stacture/stacture/api/maps.py
collection_map(collection_id, common, config)
async
Source code in stacture/stacture/api/maps.py
collection_map_styled(collection_id, style_id, common)
get_map_common(width, height, bbox, bbox_crs='EPSG:4326', accept='*/*', transparent=False, bgcolor='0xFFFFFF')
Source code in stacture/stacture/api/maps.py
parse_bbox(bbox=None)
Source code in stacture/stacture/api/maps.py
parse_bgcolor(bgcolor='0xFFFFFF')
Source code in stacture/stacture/api/maps.py
stacture.api.registry
APIRegistry()
get_registry()
cached
Source code in stacture/stacture/api/registry.py
stacture.interactions.utils
ASSET_HREF_RE = re.compile('#/assets/([^/]+)/?(?:bands/([0-9]*))?')
module-attribute
LOGGER = structlog.get_logger()
module-attribute
WarpOptions
Bases: TypedDict
bbox: tuple[float, float, float, float] | None
instance-attribute
bbox_crs: str | None
instance-attribute
crs: str | None
instance-attribute
resolution_x: float | None
instance-attribute
resolution_y: float | None
instance-attribute
scale_x: float | None
instance-attribute
scale_y: float | None
instance-attribute
size_x: PositiveInt | None
instance-attribute
size_y: PositiveInt | None
instance-attribute
add_outlines(node, geometry, outline_color, width, height, bbox, crs)
Adds outline rendering, by wrapping the node in a geometry rasterization node Only adds that rasterization step when, geometry and outline color are passed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
Item
|
the Item to get the outline geometry |
required |
node |
Node
|
the node to wrap with |
required |
outline_color |
str | None
|
the name of the color of the outlines |
required |
width |
PositiveInt
|
rasterized image width |
required |
height |
PositiveInt
|
rasterized image height |
required |
bbox |
tuple[float, float, float, float]
|
bbox of the rasterized image |
required |
crs |
str
|
crs of the rasterized image |
required |
Returns:
Type | Description |
---|---|
DatacubeNodes
|
dag.Node: the potentially wrapped node |
Source code in stacture/stacture/interactions/utils.py
create_coverage_render_workflow(items, coverage_config, bbox, bbox_crs, output_crs, size_x, size_y, properties, mediatype)
async
Source code in stacture/stacture/interactions/utils.py
create_dag_from_asset(item, asset, warp_options, band_index=None, resample_alg='nearest', preferred_alternate_asset_name=None)
Create a DAG for a given asset. Returns the DAG itself, as well as any functions the DAG uses.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
Item
|
The item to create the DAG for |
required |
asset |
Asset
|
The Asset to create the DAG for |
required |
Returns:
Type | Description |
---|---|
tuple[DatacubeNodes, dict[str, DatacubeNodes]]
|
tuple[dag.Node, dict[str, dag.Node]]: The created DAG, and a dictionary of all function it uses. |
Source code in stacture/stacture/interactions/utils.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
|
create_dag_from_render(item, render, warp_options, preferred_alternate_asset_name=None)
Create a DAG from a render extension
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
Item
|
The Item to create the DAG for |
required |
render |
dict
|
the render object |
required |
width |
PositiveInt
|
output width |
required |
height |
PositiveInt
|
output height |
required |
bbox |
tuple[float, float, float, float]
|
output bbox |
required |
crs |
str
|
output CRS |
required |
Returns:
Type | Description |
---|---|
tuple[DatacubeNodes, dict[str, DatacubeNodes]]
|
dag.Node: the resulting DAG |
Source code in stacture/stacture/interactions/utils.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
create_render_image_workflow(items, map_config, style, width, height, bbox, crs, mediatype, background_color, transparent, preferred_alternate_asset_name)
async
builds an imageworkflow based on rendering request inputs
Source code in stacture/stacture/interactions/utils.py
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
|
get_classes(asset, item)
Source code in stacture/stacture/interactions/utils.py
resolve_asset_href_and_band(item, asset_href)
Resolve an asset href as defined in the (virtual-asset extension)[https://github.com/stac-extensions/virtual-assets#object-referencing-using-vrthrefs]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item |
Item
|
The Item to resolve the href on. |
required |
asset_href |
str
|
The href |
required |
Raises:
Type | Description |
---|---|
ValueError
|
When the href is not local to the item. |
Returns:
Type | Description |
---|---|
tuple[Asset, int | None]
|
tuple[pystac.Asset, int | None]: the resolved asset and an optional band index |
Source code in stacture/stacture/interactions/utils.py
send_terravis_coverage_request(workflow, url)
async
stacture.source.fs.s3
open_from_credentials(fs_config)
open_from_profile(fs_config)
open_fs(fs_config)
async
Source code in stacture/stacture/source/fs/s3.py
stacture.source.base
BBox(minx, maxx, miny, maxy, crs)
dataclass
BaseSource(extra=None, preferred_alternate_asset_name=None)
Bases: ABC
Source code in stacture/stacture/source/base.py
extra = extra
instance-attribute
preferred_alternate_asset_name = preferred_alternate_asset_name
instance-attribute
extend_item(raw_item)
get_collection()
abstractmethod
async
get_item(identifier)
abstractmethod
async
Query(bbox=None, time=None, filter=None, limit=None, offset=None)
dataclass
bbox: BBox | None = None
class-attribute
instance-attribute
filter: Node | None = None
class-attribute
instance-attribute
limit: int | None = None
class-attribute
instance-attribute
offset: int | None = None
class-attribute
instance-attribute
time: TimeInterval | None = None
class-attribute
instance-attribute
TimeInterval(start, end)
dataclass
end: datetime | None
instance-attribute
start: datetime | None
instance-attribute
deepmerge(destination, source)
a = { 'first' : { 'all_rows' : { 'pass' : 'dog', 'number' : '1' } } } b = { 'first' : { 'all_rows' : { 'fail' : 'cat', 'number' : '5' } } } merge(b, a) == { 'first' : { 'all_rows' : { 'pass' : 'dog', 'fail' : 'cat', 'number' : '5' } } } True
Source code in stacture/stacture/source/base.py
stacture.source.stac_api
LOGGER = structlog.get_logger()
module-attribute
HTTPMethod
Bases: Enum
CONNECT = 'CONNECT'
class-attribute
instance-attribute
DELETE = 'DELETE'
class-attribute
instance-attribute
GET = 'GET'
class-attribute
instance-attribute
HEAD = 'HEAD'
class-attribute
instance-attribute
OPTIONS = 'OPTIONS'
class-attribute
instance-attribute
PATCH = 'PATCH'
class-attribute
instance-attribute
POST = 'POST'
class-attribute
instance-attribute
PUT = 'PUT'
class-attribute
instance-attribute
TRACE = 'TRACE'
class-attribute
instance-attribute
STACAPISource(href, collection, filter_=None, method=HTTPMethod.GET, extra=None, preferred_alternate_asset_name=None)
Bases: BaseSource
Source code in stacture/stacture/source/stac_api.py
api_url = href
instance-attribute
collection = collection
instance-attribute
filter = filter_
instance-attribute
method = method
instance-attribute
build_stac_api_params(query)
builds stac parameters from a query
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
Query
|
Query object |
required |
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
stac parameters |
Source code in stacture/stacture/source/stac_api.py
get_collection()
async
Source code in stacture/stacture/source/stac_api.py
get_item(identifier)
async
Source code in stacture/stacture/source/stac_api.py
request(client, method, url, params=None)
async
Source code in stacture/stacture/source/stac_api.py
search_items(query)
async
Source code in stacture/stacture/source/stac_api.py
stacture.source.stac_item
STACItemSource(href, fs, preferred_alternate_asset_name=None)
Bases: BaseSource
Source code in stacture/stacture/source/stac_item.py
fs = fs
instance-attribute
href = href
instance-attribute
get_collection()
async
get_item(identifier)
async
stacture.ows.base
BaseOWS
request(name, default_version=None)
stacture.ows.registry
OWSRegistry()
ows = {}
instance-attribute
get_handler(service, version, request)
stacture.ows.router
router = APIRouter()
module-attribute
wms = WebMapService()
module-attribute
ows_get(request, request_params, config)
async
Source code in stacture/stacture/ows/router.py
stacture.ows.wms
LOGGER = structlog.get_logger()
module-attribute
WebMapService
VERSIONS = (Version(1, 1, 0), Version(1, 1, 1), Version(1, 3, 0))
class-attribute
instance-attribute
get_capabilities(config, url, version, acceptversions=None)
async
Source code in stacture/stacture/ows/wms.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
get_map(config, layers, styles, bbox, width, height, _format, transparent=False, bgcolor='0xFFFFFF', time=None, exceptions='XML')
async
Source code in stacture/stacture/ows/wms.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
version_negotiation(versions, accepted_versions)
staticmethod
Source code in stacture/stacture/ows/wms.py
Terravis
terravis.client
LOGGER = structlog.get_logger()
module-attribute
coverage(endpoint, workflow)
async
Source code in stacture/terravis/client.py
image(endpoint, workflow)
async
Source code in stacture/terravis/client.py
statistics(endpoint, workflow)
async
Source code in stacture/terravis/client.py
terravis.utils
BadRequest(*args, **kwargs)
Bases: StactureHTTPException
Convenience Stacture HTTPException for 400 Bad Request errors
Source code in stacture/terravis/utils.py
HTTPNotFound(*args, **kwargs)
Bases: StactureHTTPException
Convenience Stacture HTTPException for 404 Not Found errors
Source code in stacture/terravis/utils.py
HttpNotImplemented(*args, **kwargs)
Bases: StactureHTTPException
Convenience Stacture HTTPException for 501 Not Implemented errors
Source code in stacture/terravis/utils.py
StactureHTTPException(*args, error_type=None, **kwargs)
Bases: HTTPException
Extension of basic fastapi errors with error_type
This type is serialized to the caller to provide more context. This can be used to decide if an error is the caller's fault or the caller's caller.
Source code in stacture/terravis/utils.py
error_type = error_type
instance-attribute
terravis.workflow
BaseWorkflow
Bases: BaseModel
credentials_profile: Annotated[str | None, StringConstraints(pattern='^[^\\./:]+$')] = None
class-attribute
instance-attribute
functions: dict[str, DatacubeNodes] = Field(default_factory=dict)
class-attribute
instance-attribute
root: DatacubeNodes
instance-attribute
check_circular_references()
Source code in stacture/terravis/workflow.py
check_function_and_args()
Source code in stacture/terravis/workflow.py
CoverageWorkflow
Bases: BaseWorkflow
encoding_options: dict[str, str] = Field(default_factory=dict)
class-attribute
instance-attribute
format: str
instance-attribute
ImageWorkflow
Bases: BaseWorkflow
encoding_options: dict[str, str] = Field(default_factory=dict)
class-attribute
instance-attribute
format: str
instance-attribute
StatisticsWorkflow
Bases: BaseWorkflow
WorkflowType
Bases: str
, Enum
COVERAGE = 'coverage'
class-attribute
instance-attribute
IMAGE = 'image'
class-attribute
instance-attribute
STATISTICS = 'statistics'
class-attribute
instance-attribute
find_args(node)
find_call_names(node)
terravis.runner
LOGGER = structlog.get_logger()
module-attribute
AsyncThreadedWorkflowRunner(engine, loop=None)
Bases: WorkflowRunner
Source code in stacture/terravis/runner.py
loop = loop or asyncio.new_event_loop()
instance-attribute
execute_workflow(workflow)
Source code in stacture/terravis/runner.py
RunContext(functions, arguments=dict(), parent=None, call_parent=None, path='$.workflow')
dataclass
arguments: dict[str, Any] = field(default_factory=dict)
class-attribute
instance-attribute
call_parent: Union[RunContext, None] = None
class-attribute
instance-attribute
full_path: str
property
full_paths: list[str]
property
functions: Mapping[str, Node]
instance-attribute
parent: Union[RunContext, None] = None
class-attribute
instance-attribute
path: str = '$.workflow'
class-attribute
instance-attribute
make_call_child(function_name, arguments)
WorkflowRunner(engine)
Source code in stacture/terravis/runner.py
ADOPT_TYPES = (Node, Scalar, *get_args(Geometry))
class-attribute
instance-attribute
engine = engine
instance-attribute
execute_workflow(workflow)
run_node(node, context)
Source code in stacture/terravis/runner.py
terravis.engine
DatacubeResult = TypeVar('DatacubeResult')
module-attribute
SET_ENV_THREAD_LOCK = threading.Lock()
module-attribute
VectorResult = TypeVar('VectorResult')
module-attribute
Engine(config, credentials_profile=None)
Bases: ABC
, Generic[DatacubeResult, VectorResult]
Source code in stacture/terravis/engine.py
config = config
instance-attribute
credentials_profile = credentials_profile
instance-attribute
handler_map: dict[type, Callable]
instance-attribute
encode_image(result, format_, encode_options)
abstractmethod
process_node(node, **kwargs)
Source code in stacture/terravis/engine.py
select_format(format_, default)
abstractmethod
set_access_credentials()
Source code in stacture/terravis/engine.py
EngineMeta(name, bases, dct)
Bases: ABCMeta
Metaclass for the Engine
class to create a static map for
all handler methods by their respective handled types.
Source code in stacture/terravis/engine.py
handle(*node_classes)
Function-decorator to mark a class function as a handler for a given node type.
Source code in stacture/terravis/engine.py
terravis.dag
DatacubeNodes = Annotated[OpenDatacube | CreateDatacube | Slice | Select | Stack | Warp | Arithmetic | Rescale | Cast | Function | Hillshade | Slope | Aspect | TRI | TPI | Roughness | Pansharpen | Rasterize | Colorize | Merge | Call | DatacubeArg, pydantic.Field(discriminator='op')]
module-attribute
Geometry = GeometryCollection | Polygon | MultiPolygon | LineString | MultiLineString | Point | MultiPoint
module-attribute
ResultType = TypeVar('ResultType', bound=ValueType)
module-attribute
VectorNodes = Annotated[OpenVector | Contours | VectorArg, pydantic.Field(discriminator='op')]
module-attribute
Argument
Bases: BaseModel
name: str
instance-attribute
Arithmetic
ArithmeticOp
Bases: str
, Enum
ADD = '+'
class-attribute
instance-attribute
DIV = '/'
class-attribute
instance-attribute
MUL = '*'
class-attribute
instance-attribute
SUB = '-'
class-attribute
instance-attribute
Aspect
algorithm: DEMAlgorithm = DEMAlgorithm.HORN
class-attribute
instance-attribute
arg: DatacubeNodes
instance-attribute
op: Literal['Aspect'] = 'Aspect'
class-attribute
instance-attribute
scale: float
instance-attribute
trignonometric: bool
instance-attribute
zero_for_flat: bool
instance-attribute
Call
Cast
ColorMap
Bases: BaseModel
entries: list[ColorMapEntry]
instance-attribute
type: ColorMapType = ColorMapType.ramp
class-attribute
instance-attribute
ColorMapEntry
Bases: BaseModel
color: str
instance-attribute
label: str | None = None
class-attribute
instance-attribute
opacity: float = 1.0
class-attribute
instance-attribute
quantity: float
instance-attribute
ColorMapType
Bases: str
, Enum
intervals = 'intervals'
class-attribute
instance-attribute
ramp = 'ramp'
class-attribute
instance-attribute
values = 'values'
class-attribute
instance-attribute
Colorize
Contours
arg: DatacubeNodes
instance-attribute
base: float
instance-attribute
id_field: str = 'id'
class-attribute
instance-attribute
interval: float
instance-attribute
layer_name: str = 'contours'
class-attribute
instance-attribute
op: Literal['Contours'] = 'Contours'
class-attribute
instance-attribute
value_field: str = 'data'
class-attribute
instance-attribute
CreateDatacube
bbox: tuple[float, float, float, float]
instance-attribute
crs: str | None = None
class-attribute
instance-attribute
datatype: DataType = DataType.Byte
class-attribute
instance-attribute
init_values: list[float]
instance-attribute
op: Literal['CreateDatacube'] = 'CreateDatacube'
class-attribute
instance-attribute
resolution: tuple[float, float] | None = None
class-attribute
instance-attribute
size: tuple[pydantic.PositiveInt, pydantic.PositiveInt]
instance-attribute
DEMAlgorithm
Bases: str
, Enum
HORN = 'Horn'
class-attribute
instance-attribute
ZEVENBERGEN_THORNE = 'ZevenbergenThorne'
class-attribute
instance-attribute
DataType
Bases: str
, Enum
Byte = 'Byte'
class-attribute
instance-attribute
Float32 = 'Float32'
class-attribute
instance-attribute
Float64 = 'Float64'
class-attribute
instance-attribute
Int16 = 'Int16'
class-attribute
instance-attribute
Int32 = 'Int32'
class-attribute
instance-attribute
Int64 = 'Int64'
class-attribute
instance-attribute
Int8 = 'Int8'
class-attribute
instance-attribute
UInt16 = 'UInt16'
class-attribute
instance-attribute
UInt32 = 'UInt32'
class-attribute
instance-attribute
UInt64 = 'UInt64'
class-attribute
instance-attribute
Datacube
Bases: ValueType
DatacubeArg
Function
Hillshade
algorithm: DEMAlgorithm = DEMAlgorithm.HORN
class-attribute
instance-attribute
altitude: float
instance-attribute
arg: DatacubeNodes
instance-attribute
azimuth: float = 315.0
class-attribute
instance-attribute
mode: HillshadeMode = HillshadeMode.NORMAL
class-attribute
instance-attribute
op: Literal['Hillshade'] = 'Hillshade'
class-attribute
instance-attribute
scale: float
instance-attribute
z_factor: float
instance-attribute
HillshadeMode
Bases: str
, Enum
COMBINED = 'combined'
class-attribute
instance-attribute
IGOR = 'igor'
class-attribute
instance-attribute
MULTI_DIRECTIONAL = 'multiDirectional'
class-attribute
instance-attribute
NORMAL = 'normal'
class-attribute
instance-attribute
Mask
Merge
Metadata
Bases: ValueType
Node
Bases: BaseModel
, Generic[ResultType]
OpenDatacube
OpenVector
Pansharpen
Rasterize
arg: Union[VectorNodes, Geometry]
instance-attribute
bbox: tuple[float, float, float, float]
instance-attribute
burn_values: list[int] | str | None = None
class-attribute
instance-attribute
crs: str
instance-attribute
nodata_value: float | None = None
class-attribute
instance-attribute
op: Literal['Rasterize'] = 'Rasterize'
class-attribute
instance-attribute
size: tuple[pydantic.PositiveInt, pydantic.PositiveInt]
instance-attribute
value_field: str = 'data'
class-attribute
instance-attribute
ResampleAlg
Bases: str
, Enum
AVERAGE = 'average'
class-attribute
instance-attribute
BILINEAR = 'bilinear'
class-attribute
instance-attribute
CUBIC = 'cubic'
class-attribute
instance-attribute
CUBIC_SPLINE = 'cubic_spline'
class-attribute
instance-attribute
GAUSS = 'gauss'
class-attribute
instance-attribute
LANCZOS = 'lanczos'
class-attribute
instance-attribute
MODE = 'mode'
class-attribute
instance-attribute
NEAREST = 'nearest'
class-attribute
instance-attribute
RMS = 'rms'
class-attribute
instance-attribute
Rescale
Roughness
Scalar
Bases: ValueType
value: int | float | str | datetime
instance-attribute
ScalarArg
Select
Slice
Slope
algorithm: DEMAlgorithm = DEMAlgorithm.HORN
class-attribute
instance-attribute
arg: DatacubeNodes
instance-attribute
format: SlopeFormat = SlopeFormat.DEGREE
class-attribute
instance-attribute
op: Literal['Slope'] = 'Slope'
class-attribute
instance-attribute
scale: float
instance-attribute
SlopeFormat
Bases: str
, Enum
DEGREE = 'degree'
class-attribute
instance-attribute
PERCENT = 'percent'
class-attribute
instance-attribute
Stack
TPI
TRI
TRIAlgorithm
Bases: str
, Enum
RILEY = 'Riley'
class-attribute
instance-attribute
WILSON = 'Wilson'
class-attribute
instance-attribute
ValueType
Bases: BaseModel
Vector
Bases: ValueType
VectorArg
Warp
arg: DatacubeNodes
instance-attribute
bbox: tuple[float, float, float, float] | None = None
class-attribute
instance-attribute
bbox_crs: str | None = None
class-attribute
instance-attribute
crs: str | None = None
class-attribute
instance-attribute
op: Literal['Warp'] = 'Warp'
class-attribute
instance-attribute
resample_alg: ResampleAlg = ResampleAlg.NEAREST
class-attribute
instance-attribute
resolution_x: float | None = None
class-attribute
instance-attribute
resolution_y: float | None = None
class-attribute
instance-attribute
scale_x: float | None = None
class-attribute
instance-attribute
scale_y: float | None = None
class-attribute
instance-attribute
size_x: pydantic.PositiveInt | None = None
class-attribute
instance-attribute
size_y: pydantic.PositiveInt | None = None
class-attribute
instance-attribute
descend_tree(node, check_types, extractor)
Helper function to extract collected information about specific nodes in the tree.
Source code in stacture/terravis/dag.py
terravis.runner
LOGGER = structlog.get_logger()
module-attribute
AsyncThreadedWorkflowRunner(engine, loop=None)
Bases: WorkflowRunner
Source code in stacture/terravis/runner.py
loop = loop or asyncio.new_event_loop()
instance-attribute
execute_workflow(workflow)
Source code in stacture/terravis/runner.py
RunContext(functions, arguments=dict(), parent=None, call_parent=None, path='$.workflow')
dataclass
arguments: dict[str, Any] = field(default_factory=dict)
class-attribute
instance-attribute
call_parent: Union[RunContext, None] = None
class-attribute
instance-attribute
full_path: str
property
full_paths: list[str]
property
functions: Mapping[str, Node]
instance-attribute
parent: Union[RunContext, None] = None
class-attribute
instance-attribute
path: str = '$.workflow'
class-attribute
instance-attribute
make_call_child(function_name, arguments)
WorkflowRunner(engine)
Source code in stacture/terravis/runner.py
ADOPT_TYPES = (Node, Scalar, *get_args(Geometry))
class-attribute
instance-attribute
engine = engine
instance-attribute
execute_workflow(workflow)
run_node(node, context)
Source code in stacture/terravis/runner.py
terravis.gdal.engine
ARITHMETIC_OP_TO_OPERATOR = {dag.ArithmeticOp.ADD: operator.add, dag.ArithmeticOp.SUB: operator.sub, dag.ArithmeticOp.MUL: operator.mul, dag.ArithmeticOp.DIV: operator.truediv}
module-attribute
DATATYPE_MAP = {dag.DataType.Byte: gdal.GDT_Byte, dag.DataType.Int8: gdal.GDT_Byte, dag.DataType.UInt16: gdal.GDT_UInt16, dag.DataType.Int16: gdal.GDT_Int16, dag.DataType.UInt32: gdal.GDT_UInt32, dag.DataType.Int32: gdal.GDT_Int32, dag.DataType.Float32: gdal.GDT_Float32, dag.DataType.Float64: gdal.GDT_Float64}
module-attribute
FUNCTION_MAP: dict[str, Callable] = {'sin': np.sin, 'cos': np.cos, 'tan': np.tan, 'arcsin': np.arcsin, 'arccos': np.arccos, 'arctan': np.arctan, 'hypot': np.hypot, 'arctan2': np.arctan2, 'degrees': np.degrees, 'radians': np.radians, 'unwrap': np.unwrap, 'deg2rad': np.deg2rad, 'rad2deg': np.rad2deg, 'sinh': np.sinh, 'cosh': np.cosh, 'tanh': np.tanh, 'arcsinh': np.arcsinh, 'arccosh': np.arccosh, 'arctanh': np.arctanh, 'exp': np.exp, 'expm1': np.expm1, 'exp2': np.exp2, 'log': np.log, 'log10': np.log10, 'log2': np.log2, 'log1p': np.log1p}
module-attribute
LOGGER = structlog.get_logger()
module-attribute
MEM_DRIVER: gdal.Driver = gdal.GetDriverByName('MEM')
module-attribute
MEM_DRIVER_VEC: ogr.Driver = ogr.GetDriverByName('Memory')
module-attribute
MIMETYPE_TO_DRIVER_NAME = {'image/png': 'PNG', 'image/jpeg': 'JPEG', 'image/tiff': 'GTiff'}
module-attribute
NUMPY_DTYPE_MAP = {np.dtype(np.float16): np.float32}
module-attribute
RESAMPLEALG_MAP = {dag.ResampleAlg.NEAREST: gdal.GRA_NearestNeighbour, dag.ResampleAlg.AVERAGE: gdal.GRA_Average, dag.ResampleAlg.BILINEAR: gdal.GRA_Bilinear, dag.ResampleAlg.CUBIC: gdal.GRA_Cubic, dag.ResampleAlg.CUBIC_SPLINE: gdal.GRA_CubicSpline, dag.ResampleAlg.LANCZOS: gdal.GRA_Lanczos, dag.ResampleAlg.MODE: gdal.GRA_Mode, dag.ResampleAlg.RMS: gdal.GRA_RMS}
module-attribute
GDALDatacube(dataset)
dataclass
dataset: gdal.Dataset
instance-attribute
from_ndarry(data, gt, crs)
classmethod
Source code in stacture/terravis/gdal/engine.py
GDALEngine(config, credentials_profile=None)
Bases: Engine[GDALDatacube, GDALVector]
Source code in stacture/terravis/engine.py
arithmetic(node, lhs, rhs)
Source code in stacture/terravis/gdal/engine.py
aspect(node, arg)
Source code in stacture/terravis/gdal/engine.py
cast(node, arg)
Source code in stacture/terravis/gdal/engine.py
colorize(node, arg)
Source code in stacture/terravis/gdal/engine.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
|
contours(node, arg)
Source code in stacture/terravis/gdal/engine.py
create_datacube(node)
Source code in stacture/terravis/gdal/engine.py
encode_coverage(result, format_, encode_options)
Encodes a coverage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
GDALDatacube
|
Result to encode as an image |
required |
format_ |
str
|
Format to encode the image as |
required |
encode_options |
dict[str, str]
|
additional encoding options |
required |
Returns:
Type | Description |
---|---|
IOBase
|
io.IOBase: image bytes |
Source code in stacture/terravis/gdal/engine.py
encode_image(result, format_, encode_options)
Encodes an image
Parameters:
Name | Type | Description | Default |
---|---|---|---|
result |
GDALDatacube
|
Result to encode as an image |
required |
format_ |
str
|
Format to encode the image as |
required |
encode_options |
dict[str, str]
|
additional encoding options |
required |
Returns:
Type | Description |
---|---|
IOBase
|
io.IOBase: image bytes |
Source code in stacture/terravis/gdal/engine.py
function(node, args)
Source code in stacture/terravis/gdal/engine.py
hillshade(node, arg)
Source code in stacture/terravis/gdal/engine.py
mask(node, arg, mask)
Source code in stacture/terravis/gdal/engine.py
merge(node, args)
Source code in stacture/terravis/gdal/engine.py
open_datacube(node)
Source code in stacture/terravis/gdal/engine.py
open_vector(node)
pansharpen(node, pan, spectral)
Source code in stacture/terravis/gdal/engine.py
rasterize(node, arg)
Source code in stacture/terravis/gdal/engine.py
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 |
|
rescale(node, arg)
Source code in stacture/terravis/gdal/engine.py
roughness(node, arg)
Source code in stacture/terravis/gdal/engine.py
select(node, arg)
Source code in stacture/terravis/gdal/engine.py
select_format(format_, default)
Source code in stacture/terravis/gdal/engine.py
slice(node, arg)
slope(node, arg)
Source code in stacture/terravis/gdal/engine.py
stack(node, args)
Source code in stacture/terravis/gdal/engine.py
statistics(result)
Source code in stacture/terravis/gdal/engine.py
tpi(node, arg)
tri(node, arg)
Source code in stacture/terravis/gdal/engine.py
warp(node, arg)
Source code in stacture/terravis/gdal/engine.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 |
|
GDALVector(datasource)
dataclass
datasource: ogr.DataSource
instance-attribute
terravis.gdal.utils
CIS_RGBX = {CI_RGB, CI_RGBA}
module-attribute
CIS_TREAT_AS_RGBX = CIS_RGBX | {CI_UNDEFINED_3, CI_UNDEFINED_4}
module-attribute
CI_RGB = (gdal.GCI_RedBand, gdal.GCI_GreenBand, gdal.GCI_BlueBand)
module-attribute
CI_RGBA = (gdal.GCI_RedBand, gdal.GCI_GreenBand, gdal.GCI_BlueBand, gdal.GCI_AlphaBand)
module-attribute
CI_UNDEFINED_3 = (gdal.GCI_Undefined, gdal.GCI_Undefined, gdal.GCI_Undefined)
module-attribute
CI_UNDEFINED_4 = (gdal.GCI_Undefined, gdal.GCI_Undefined, gdal.GCI_Undefined, gdal.GCI_Undefined)
module-attribute
DATA_TYPE_INFO = {gdal.GDT_Byte: (False, False, 8), gdal.GDT_UInt16: (False, False, 16), gdal.GDT_UInt32: (False, False, 32), gdal.GDT_Int16: (False, True, 16), gdal.GDT_Int32: (False, True, 32), gdal.GDT_Float32: (True, True, 32), gdal.GDT_Float64: (True, True, 64)}
module-attribute
convert_dtype(dtype)
Maps numpy dtype to a larger itemsize to avoid value overflow during mathematical operations
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dtype |
dtype
|
input dtype |
required |
Returns:
Name | Type | Description |
---|---|---|
dtype |
dtype
|
either one size larger dtype or original dtype |
Source code in stacture/terravis/gdal/utils.py
find_datatype(floating, signed, num_bits)
Source code in stacture/terravis/gdal/utils.py
gdal_datatype_parameters(value)
Source code in stacture/terravis/gdal/utils.py
gdal_datatype_union(dt1, dt2)
gdal_datatype_union_and_value(dt1, value)
get_color_interpretations(ds)
get_ds_bbox(ds)
Source code in stacture/terravis/gdal/utils.py
get_ds_mask_flags(ds)
iter_bands(ds)
read_as_array(ds)
read_rgb_and_alpha(ds)
Reads the RGB-A values of a dataset. When the dataset already is in RGBA (or unknown with 4 bands), RGB and alpha is returned. Otherwise, the dataset mask will be used as alpha values.
RGB is in the range of the datatype, alpha is transformed to float from 0..1
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ds |
Dataset
|
the dataset to read the RGBA data from |
required |
Returns:
Type | Description |
---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: the RGB and alpha values |
Source code in stacture/terravis/gdal/utils.py
terravis.gdal.vsi
This module provides Python file-object like access to VSI files.
PROTOCOL_MAP = {'s3': ('vsis3', False), 'http': ('vsicurl', True), 'https': ('vsicurl', True), 'ftp': ('vsicurl', True)}
module-attribute
UINT32_MAX = numpy.iinfo('uint32').max
module-attribute
remove = gdal.Unlink
module-attribute
rename = gdal.Rename
module-attribute
unlink = gdal.Unlink
module-attribute
TemporaryVSIFile(filename, mode='r')
Bases: VSIFile
Subclass of VSIFile, that automatically deletes the physical file upon deletion.
Source code in stacture/terravis/gdal/vsi.py
close()
from_buffer(buf, mode='wb', filename=None)
classmethod
Creates a :class:TemporaryVSIFile
from a string.
Source code in stacture/terravis/gdal/vsi.py
VSIFile(filename, mode='r')
File-like object interface for VSI file API.
:param filename: the path to the file; this might also be any VSI special
path like "/vsicurl/..." or "/vsizip/...". See the GDAL
documentation
<http://trac.osgeo.org/gdal/wiki/UserDocs/ReadInZip>
and manuals
<http://www.gdal.org/gdal_virtual_file_systems.html>
for reference.
:param mode: the file opening mode
Source code in stacture/terravis/gdal/vsi.py
closed: bool
property
Return a boolean value to indicate whether or not the file is already closed.
name: str
property
Returns the filename referenced by this file
read1 = read
class-attribute
instance-attribute
readinto1 = readinto
class-attribute
instance-attribute
size: int
property
Return the size of the file in bytes
__exit__(etype=None, evalue=None, tb=None)
__iter__()
close()
fileno()
isatty()
next()
Satisfaction of the iterator protocol. Return the next line in the
file or raise StopIteration
.
read(size=UINT32_MAX)
Read from the file. If no size
is specified, read until the end
of the file.
Source code in stacture/terravis/gdal/vsi.py
readinto(into)
readline(length=None, windowsize=1024)
Read a single line from the file and return it.
:param length: the maximum number of bytes to read to look for a whole line. :param windowsize: the windowsize to search for a newline character.
Source code in stacture/terravis/gdal/vsi.py
readlines(sizehint=0)
Read the remainder of the file (or up to sizehint
bytes) and
return the lines.
:param sizehint: the number of bytes to scan for lines. :return: the lines :rtype: list of strings
Source code in stacture/terravis/gdal/vsi.py
seek(offset, whence=os.SEEK_SET)
seekable()
tell()
truncate(size=None)
Truncates the file to the given size or to the size until the current position.
:param size: the new size of the file.
Source code in stacture/terravis/gdal/vsi.py
write(data)
writeable()
join(first, *paths)
Joins the given VSI path specifiers. Similar to :func:os.path.join
but takes care of the VSI-specific handles such as vsicurl
, vsizip
,
etc.
Source code in stacture/terravis/gdal/vsi.py
open_(filename, mode='r')
A function mimicking the builtin function
:func:open <__builtins__.open>
but returning a :class:VSIFile
instead.
:param filename: the path to the file; this might also be any VSI special
path like "/vsicurl/..." or "/vsizip/...". See the GDAL
documentation
<http://trac.osgeo.org/gdal/wiki/UserDocs/ReadInZip>
_
for reference.
:param mode: the file opening mode
:returns: a :class:VSIFile
Source code in stacture/terravis/gdal/vsi.py
to_vsi_path(href, streaming=False)
Converts URLs to VSI compatible paths.
e.g: s3://bucket/path/to/file becomes /vsis3/bucket/path/to/file
Parameters:
Name | Type | Description | Default |
---|---|---|---|
href |
str
|
the URL to transform |
required |
streaming |
bool
|
Whether to use the streaming interface |
False
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
the VSI path |