Results Tasks¶
ecoscope.platform.tasks.results ¶
Classes¶
DashboardJson ¶
SmoothingConfig ¶
Bases: BaseModel
Configuration for data smoothing.
Attributes¶
degree
class-attribute
instance-attribute
¶
degree: Annotated[int, AdvancedField(default=3, description='The degree of the spline. 1: Linear, 2: Quadratic, 3: Cubic (recommended), 4-5: Higher degree.')] = 3
method
class-attribute
instance-attribute
¶
method: Annotated[Literal['spline'], Field(description="The smoothing method to apply. Currently supports 'spline'.")] = 'spline'
resolution
class-attribute
instance-attribute
¶
resolution: Annotated[int, AdvancedField(default=10, description='The resolution multiplier for interpolation points. The number of output points will be len(x) * resolution.')] = 10
y_max
class-attribute
instance-attribute
¶
y_max: Annotated[float | SkipJsonSchema[None], AdvancedField(default=None, description='The maximum value to clamp smoothed values to.')] = None
y_min
class-attribute
instance-attribute
¶
y_min: Annotated[float | SkipJsonSchema[None], AdvancedField(default=None, description='The minimum value to clamp smoothed values to. Useful for data like precipitation where values should not go below zero.')] = None
Functions:¶
create_geojson_layer ¶
create_geojson_layer(geodataframe: Annotated[AnyGeoDataFrame | SkipJsonSchema[None], Field(description='The geodataframe to visualize.', exclude=True)] = None, data_url: Annotated[str | SkipJsonSchema[None], Field(description='URL to a GeoJSON file to visualize.')] = None, layer_style: Annotated[GeoJSONLayerStyle | SkipJsonSchema[None], AdvancedField(default=GeoJSONLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description='Restrict the on-hover tooltip to these column names. None (default) shows all properties.')] = None) -> Annotated[PydeckLayerDefinition, Field()]
Creates a GeoJSON layer definition based on the provided configuration.
Source code in ecoscope/platform/tasks/results/_pydeck.py
create_hexagon_layer ¶
create_hexagon_layer(geodataframe: Annotated[AnyGeoDataFrame | SkipJsonSchema[None], Field(description='The geodataframe to visualize.', exclude=True)] = None, data_url: Annotated[str | SkipJsonSchema[None], Field(description='URL to a GeoJSON file to visualize.')] = None, layer_style: Annotated[HexagonLayerStyle | SkipJsonSchema[None], AdvancedField(default=HexagonLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description='Restrict the on-hover tooltip to these column names. None (default) shows all properties.')] = None) -> Annotated[PydeckLayerDefinition, Field()]
Creates a hexagon layer definition based on the provided configuration.
Source code in ecoscope/platform/tasks/results/_pydeck.py
create_icon_layer ¶
create_icon_layer(geodataframe: Annotated[AnyGeoDataFrame | SkipJsonSchema[None], Field(description='The geodataframe to visualize.', exclude=True)] = None, data_url: Annotated[str | SkipJsonSchema[None], Field(description='URL to a GeoJSON file to visualize.')] = None, layer_style: Annotated[IconLayerStyle | SkipJsonSchema[None], AdvancedField(default=IconLayerStyle(), description='Style arguments for the layer.')] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description='Restrict the on-hover tooltip to these column names. None (default) shows all properties.')] = None) -> Annotated[PydeckLayerDefinition, Field()]
Creates an icon layer definition based on the provided configuration.
Source code in ecoscope/platform/tasks/results/_pydeck.py
create_map_v2_widget_single_view ¶
create_map_v2_widget_single_view(title: Annotated[str, Field(description='The title of the widget')], data: Annotated[MapWidgetData, Field(description='A deck.gl JSON spec as a dict'), SkippedDependencyFallback(_fallback_to_none)], view: Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)] = None) -> Annotated[WidgetSingleView, Field(description='The widget')]
Create a map widget with a single view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
Annotated[str, Field(description='The title of the widget')]
|
The title of the widget. |
required |
data
|
Annotated[MapWidgetData, Field(description='A deck.gl JSON spec as a dict'), SkippedDependencyFallback(_fallback_to_none)]
|
A deck.gl JSON spec as a dict. |
required |
view
|
Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)]
|
If grouped, the view of the widget. |
None
|
Returns:
| Type | Description |
|---|---|
Annotated[WidgetSingleView, Field(description='The widget')]
|
The widget. |
Source code in ecoscope/platform/tasks/results/_widget_tasks.py
create_map_widget_single_view ¶
create_map_widget_single_view(title: Annotated[str, Field(description='The title of the widget')], data: Annotated[PrecomputedHTMLWidgetData, Field(description='Path to precomputed HTML'), SkippedDependencyFallback(_fallback_to_none)], view: Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)] = None) -> Annotated[WidgetSingleView, Field(description='The widget')]
Create a map widget with a single view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
Annotated[str, Field(description='The title of the widget')]
|
The title of the widget. |
required |
data
|
Annotated[PrecomputedHTMLWidgetData, Field(description='Path to precomputed HTML'), SkippedDependencyFallback(_fallback_to_none)]
|
Path to precomputed HTML. |
required |
view
|
Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)]
|
If grouped, the view of the widget. |
None
|
Returns:
| Type | Description |
|---|---|
Annotated[WidgetSingleView, Field(description='The widget')]
|
The widget. |
Source code in ecoscope/platform/tasks/results/_widget_tasks.py
create_path_layer ¶
create_path_layer(geodataframe: Annotated[AnyGeoDataFrame | SkipJsonSchema[None], Field(description='The geodataframe to visualize.', exclude=True)] = None, data_url: Annotated[str | SkipJsonSchema[None], Field(description='URL to a GeoJSON file to visualize.')] = None, layer_style: Annotated[PathLayerStyle | SkipJsonSchema[None], AdvancedField(default=PathLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description='Restrict the on-hover tooltip to these column names. None (default) shows all properties.')] = None) -> Annotated[PydeckLayerDefinition, Field()]
Creates a polyline layer definition based on the provided configuration.
Source code in ecoscope/platform/tasks/results/_pydeck.py
create_plot_widget_single_view ¶
create_plot_widget_single_view(title: Annotated[str, Field(description='The title of the widget')], data: Annotated[PrecomputedHTMLWidgetData, Field(description='Path to precomputed HTML'), SkippedDependencyFallback(_fallback_to_none)], view: Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)] = None) -> Annotated[WidgetSingleView, Field(description='The widget')]
Create a plot widget with a single view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
Annotated[str, Field(description='The title of the widget')]
|
The title of the widget. |
required |
data
|
Annotated[PrecomputedHTMLWidgetData, Field(description='Path to precomputed HTML'), SkippedDependencyFallback(_fallback_to_none)]
|
Path to precomputed HTML. |
required |
view
|
Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)]
|
If grouped, the view of the widget. |
None
|
Returns:
| Type | Description |
|---|---|
Annotated[WidgetSingleView, Field(description='The widget')]
|
The widget. |
Source code in ecoscope/platform/tasks/results/_widget_tasks.py
create_point_layer ¶
create_point_layer(geodataframe: Annotated[AnyGeoDataFrame, Field(description='The geodataframe to visualize.', exclude=True)], layer_style: Annotated[PointLayerStyle | SkipJsonSchema[None], AdvancedField(default=PointLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description="If present, only the listed dataframe columns will display in the layer's picking info")] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False) -> Annotated[LayerDefinition, Field()]
Creates a point layer definition based on the provided configuration.
Args: geodataframe (geopandas.GeoDataFrame): The geodataframe to visualize. layer_style (LayerStyle): Style arguments for the data visualization.
Returns: The generated LayerDefinition
Source code in ecoscope/platform/tasks/results/_ecomap.py
create_polygon_layer ¶
create_polygon_layer(geodataframe: Annotated[AnyGeoDataFrame, Field(description='The geodataframe to visualize.', exclude=True)], layer_style: Annotated[PolygonLayerStyle | SkipJsonSchema[None], AdvancedField(default=PolygonLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description="If present, only the listed dataframe columns will display in the layer's picking info")] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False) -> Annotated[LayerDefinition, Field()]
Creates a polygon layer definition based on the provided configuration.
Args: geodataframe (geopandas.GeoDataFrame): The geodataframe to visualize. layer_style (PolygonLayerStyle): Style arguments for the data visualization.
Returns: The generated LayerDefinition
Source code in ecoscope/platform/tasks/results/_ecomap.py
create_polygon_layer_pydeck ¶
create_polygon_layer_pydeck(geodataframe: Annotated[AnyGeoDataFrame | SkipJsonSchema[None], Field(description='The geodataframe to visualize.', exclude=True)] = None, data_url: Annotated[str | SkipJsonSchema[None], Field(description='URL to a GeoJSON file to visualize.')] = None, layer_style: Annotated[PolygonLayerStyle | SkipJsonSchema[None], AdvancedField(default=PolygonLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description='Restrict the on-hover tooltip to these column names. None (default) shows all properties.')] = None) -> Annotated[PydeckLayerDefinition, Field()]
Creates a polyline layer definition based on the provided configuration.
Source code in ecoscope/platform/tasks/results/_pydeck.py
create_polyline_layer ¶
create_polyline_layer(geodataframe: Annotated[AnyGeoDataFrame, Field(description='The geodataframe to visualize.', exclude=True)], layer_style: Annotated[PolylineLayerStyle | SkipJsonSchema[None], AdvancedField(default=PolylineLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description="If present, only the listed dataframe columns will display in the layer's picking info")] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False) -> Annotated[LayerDefinition, Field()]
Creates a polyline layer definition based on the provided configuration.
Args: geodataframe (geopandas.GeoDataFrame): The geodataframe to visualize. layer_style (PolylineLayerStyle): Style arguments for the data visualization.
Returns: The generated LayerDefinition
Source code in ecoscope/platform/tasks/results/_ecomap.py
create_scatterplot_layer ¶
create_scatterplot_layer(geodataframe: Annotated[AnyGeoDataFrame | SkipJsonSchema[None], Field(description='The geodataframe to visualize.', exclude=True)] = None, data_url: Annotated[str | SkipJsonSchema[None], Field(description='URL to a GeoJSON file to visualize.')] = None, layer_style: Annotated[ScatterplotLayerStyle | SkipJsonSchema[None], AdvancedField(default=ScatterplotLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description='Restrict the on-hover tooltip to these column names. None (default) shows all properties.')] = None) -> Annotated[PydeckLayerDefinition, Field()]
Creates a scatterplot layer definition based on the provided configuration.
Source code in ecoscope/platform/tasks/results/_pydeck.py
create_single_value_widget_single_view ¶
create_single_value_widget_single_view(title: Annotated[str, Field(description='The title of the widget')], data: Annotated[Quantity | float | int | None, Field(description='Value to display.'), SkippedDependencyFallback(_fallback_to_none)], view: Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)] = None, decimal_places: Annotated[int, AdvancedField(default=1, description='The number of decimal places to display.')] = 1) -> Annotated[WidgetSingleView, Field(description='The widget')]
Create a single value widget with a single view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
Annotated[str, Field(description='The title of the widget')]
|
The title of the widget. |
required |
data
|
Annotated[Quantity | float | int | None, Field(description='Value to display.'), SkippedDependencyFallback(_fallback_to_none)]
|
The value to display. |
required |
view
|
Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)]
|
If grouped, the view of the widget. |
None
|
decimal_places
|
Annotated[int, AdvancedField(default=1, description='The number of decimal places to display.')]
|
The number of decimal places to display. |
1
|
Returns:
| Type | Description |
|---|---|
Annotated[WidgetSingleView, Field(description='The widget')]
|
The widget. |
Source code in ecoscope/platform/tasks/results/_widget_tasks.py
create_table_widget_single_view ¶
create_table_widget_single_view(title: Annotated[str, Field(description='The title of the widget')], data: Annotated[PrecomputedHTMLWidgetData, Field(description='Path to precomputed HTML'), SkippedDependencyFallback(_fallback_to_none)], view: Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)] = None) -> Annotated[WidgetSingleView, Field(description='The widget')]
Create a table widget with a single view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
Annotated[str, Field(description='The title of the widget')]
|
The title of the widget. |
required |
data
|
Annotated[PrecomputedHTMLWidgetData, Field(description='Path to precomputed HTML'), SkippedDependencyFallback(_fallback_to_none)]
|
Path to precomputed HTML. |
required |
view
|
Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)]
|
If grouped, the view of the widget. |
None
|
Returns:
| Type | Description |
|---|---|
Annotated[WidgetSingleView, Field(description='The widget')]
|
The widget. |
Source code in ecoscope/platform/tasks/results/_widget_tasks.py
create_text_layer ¶
create_text_layer(geodataframe: Annotated[AnyGeoDataFrame, Field(description='The geodataframe to visualize.', exclude=True)], layer_style: Annotated[TextLayerStyle | SkipJsonSchema[None], AdvancedField(default=TextLayerStyle(), description='Style arguments for the layer.')] = None) -> Annotated[LayerDefinition, Field()]
Creates a text layer definition based on the provided configuration.
Args: geodataframe (geopandas.GeoDataFrame): The geodataframe to visualize. layer_style (LayerStyle): Style arguments for the data visualization.
Returns: The generated LayerDefinition
Source code in ecoscope/platform/tasks/results/_ecomap.py
create_text_layer_pydeck ¶
create_text_layer_pydeck(geodataframe: Annotated[AnyGeoDataFrame | SkipJsonSchema[None], Field(description='The geodataframe to visualize.', exclude=True)] = None, data_url: Annotated[str | SkipJsonSchema[None], Field(description='URL to a GeoJSON file to visualize.')] = None, layer_style: Annotated[TextLayerStyle | SkipJsonSchema[None], AdvancedField(default=TextLayerStyle(), description='Style arguments for the layer.')] = None, legend: Annotated[LegendDefinition | SkipJsonSchema[None], AdvancedField(default=None, description='If present, includes this layer in the map legend')] = None, zoom: Annotated[bool, AdvancedField(default=False, description='If true, the map will be zoomed to the bounds of this layer', exclude=True)] = False, tooltip_columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(default=None, description='Restrict the on-hover tooltip to these column names. None (default) shows all properties.')] = None) -> Annotated[PydeckLayerDefinition, Field()]
Creates a text layer definition based on the provided configuration.
Source code in ecoscope/platform/tasks/results/_pydeck.py
create_text_widget_single_view ¶
create_text_widget_single_view(title: Annotated[str, Field(description='The title of the widget')], data: Annotated[TextWidgetData, Field(description='Text to display.'), SkippedDependencyFallback(_fallback_to_none)], view: Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)] = None) -> Annotated[WidgetSingleView, Field(description='The widget')]
Create a text widget with a single view.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
Annotated[str, Field(description='The title of the widget')]
|
The title of the widget. |
required |
data
|
Annotated[TextWidgetData, Field(description='Text to display.'), SkippedDependencyFallback(_fallback_to_none)]
|
Text to display. |
required |
view
|
Annotated[CompositeFilter | None, Field(description='If grouped, the view of the widget', exclude=True)]
|
If grouped, the view of the widget. |
None
|
Returns:
| Type | Description |
|---|---|
Annotated[WidgetSingleView, Field(description='The widget')]
|
The widget. |
Source code in ecoscope/platform/tasks/results/_widget_tasks.py
create_tiled_bitmap_layer ¶
create_tiled_bitmap_layer(url: Annotated[str, Field(description='The tile URL template with {z}, {x}, {y} placeholders.')], opacity: Annotated[float, Field(description='Layer opacity from 0 to 1.', ge=0, le=1)] = 1.0, max_zoom: Annotated[int, AdvancedField(description='Maximum zoom level.', default=20)] = 20, min_zoom: Annotated[int, AdvancedField(description='Minimum zoom level.', default=0)] = 0) -> Annotated[TileLayer, Field()]
Creates a tiled bitmap layer definition from a tile URL.
Source code in ecoscope/platform/tasks/results/_pydeck.py
draw_bar_chart ¶
draw_bar_chart(dataframe: DataFrame[JsonSerializableDataFrameModel], bar_chart_configs: Annotated[list[BarConfig], Field(description='Bar chart configuration.', title='Bar Chart Configuration')], category: Annotated[str, Field(description='The column name in the dataframe to group by and use as the x-axis categories.')], layout_kwargs: Annotated[LayoutStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional kwargs passed to plotly.go.Figure(layout).')] = None, widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this tile layer belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str, Field()]
Generates a bar chart from the provided params
Args: dataframe (pd.DataFrame): The input dataframe. bar_configs (list[BarConfig]): a list of BarConfigs specifying the the bar chart labels, columns, and functions for aggregation. category (str): The column name in the dataframe to group by and use as the x-axis categories. layout_kwargs (LayoutStyle): Additional styling options passed to plotly.go.Figure(layout).
Returns: The generated chart html as a string
Source code in ecoscope/platform/tasks/results/_ecoplot.py
draw_ecomap ¶
draw_ecomap(geo_layers: Annotated[LayerDefinition | list[LayerDefinition], Field(description='A list of map layers to add to the map.', exclude=True)], tile_layers: Annotated[list[TileLayer] | SkipJsonSchema[None], Field(description='A list of named tile layer with opacity, ie OpenStreetMap.')] = None, static: Annotated[bool, Field(description='Set to true to disable map pan/zoom.')] = False, title: Annotated[str | SkipJsonSchema[None], AdvancedField(default=None, description=' The map title. Note this is the title drawn on the map canvas itself, and will result\n in duplicate titles if set in the context of a dashboard in which the iframe/widget\n container also has a title set on it.\n ')] = None, north_arrow_style: Annotated[NorthArrowStyle | SkipJsonSchema[None], Field(description='Additional arguments for configuring the North Arrow.')] = None, legend_style: Annotated[LegendStyle | SkipJsonSchema[None], Field(description='Additional arguments for configuring the legend.')] = None, max_zoom: Annotated[int, Field(description='Max zoom level.')] = 20, view_state: Annotated[ViewState | SkipJsonSchema[None], Field(description='Manually set the view state of the map, overrides any layer zoom settings.', exclude=True)] = None, widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this tile layer belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str, Field()]
Creates a map based on the provided layer definitions and configuration.
Args: geo_layers (LayerDefinition | list[LayerDefinition]): A list of map layers to add to the map. tile_layers (list): A named tile layer, ie OpenStreetMap. static (bool): Set to true to disable map pan/zoom. title (str): The map title. north_arrow_style (NorthArrowStyle): Additional arguments for configuring the North Arrow. legend_style (WidgetStyleBase): Additional arguments for configuring the Legend. max_zoom (int): The maximum zoom level of the map view_state (ViewState): Manually set the view state of the map, overrides any layer zoom settings. widget_id (str): The id of the dashboard widget that this tile layer belongs to. If set this MUST match the widget title as defined downstream in create_widget tasks
Returns: str: A static HTML representation of the map.
Source code in ecoscope/platform/tasks/results/_ecomap.py
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 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 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
draw_ecoplot ¶
draw_ecoplot(dataframe: DataFrame[JsonSerializableDataFrameModel], group_by: Annotated[str, Field(description='The dataframe column to group by.')], ecoplot_configs: Annotated[list[EcoplotConfig], Field(description='ecoplot configs.')], tickformat: Annotated[str, AdvancedField(default='%b-%Y', description='The time format for timeseries data.')] = '%b-%Y', widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this tile layer belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str, Field()]
Generates an EcoPlot from the provided params
Args: dataframe (pd.DataFrame): The input dataframe. group_by (str): The dataframe column to group by. ecoplot_configs (list[EcoplotConfig]): the ecoplot configs widget_id (str): The id of the dashboard widget that this tile layer belongs to. If set this MUST match the widget title as defined downstream in create_widget tasks
Returns: The generated plot html as a string
Source code in ecoscope/platform/tasks/results/_ecoplot.py
draw_historic_timeseries ¶
draw_historic_timeseries(dataframe: DataFrame[JsonSerializableDataFrameModel], current_value_column: Annotated[str, Field(description='The name of the dataframe column to pull slice values from')], current_value_title: Annotated[str, Field(description='The title shown in the plot legend for current value')], historic_min_column: Annotated[str | SkipJsonSchema[None], Field(description='The name of the dataframe column to pull historic min values from')] = None, historic_max_column: Annotated[str | SkipJsonSchema[None], Field(description='The name of the dataframe column to pull historic max values from')] = None, historic_band_title: Annotated[str | SkipJsonSchema[None], Field(description='The title shown in the plot legend for historic band')] = 'Historic Min-Max', historic_mean_column: Annotated[str | SkipJsonSchema[None], Field(description='The name of the dataframe column to pull historic mean values from')] = None, historic_mean_title: Annotated[str | SkipJsonSchema[None], Field(description='The title shown in the plot legend for historic mean values')] = 'Historic Mean', layout_style: Annotated[LayoutStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional kwargs passed to plotly.go.Figure(layout).')] = None, upper_lower_band_style: Annotated[PlotStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional kwargs for upper_lower_band passed to plotly.graph_objects.Scatter.')] = PlotStyle(mode='lines', line=LineStyle(color='green')), historic_mean_style: Annotated[PlotStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional kwargs passed for historic_mean to plotly.graph_objects.Scatter.')] = None, current_value_style: Annotated[PlotStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional kwargs for current_value passed to plotly.graph_objects.Scatter.')] = None, time_column: Annotated[str | SkipJsonSchema[None], Field(description='The name of the dataframe column to pull historic max values from')] = 'img_date', widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this tile layer belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str, Field()]
Creates a timeseries plot compared with historical values Parameters
df: pd.Dataframe The data to plot current_value_column: str The name of the dataframe column to pull slice values from current_value_title: str The title of the current value historic_min_column: str The name of the dataframe column to pull historic min values from. historic_min_column and historic_max_column should exist together. historic_max_column: str The name of the dataframe column to pull historic max values from. historic_min_column and historic_max_column should exist together. historic_mean_column: str The name of the dataframe column to pull historic mean values from layout_kwargs: dict Additional kwargs passed to plotly.go.Figure(layout) upper_lower_band_style: PlotStyle Additional kwargs for upper_lower_band passed to plotly.graph_objects.Scatter historic_mean_style: PlotStyle Additional kwargs passed for historic_mean to plotly.graph_objects.Scatter current_value_style: PlotStyle Additional kwargs for current_value passed to plotly.graph_objects.Scatter time_column: str The name of the dataframe column to pull time values from widget_id str: The id of the dashboard widget that this tile layer belongs to. If set this MUST match the widget title as defined downstream in create_widget tasks Returns
fig : The generated chart html as a string
Source code in ecoscope/platform/tasks/results/_ecoplot.py
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 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 | |
draw_line_chart ¶
draw_line_chart(dataframe: DataFrame[JsonSerializableDataFrameModel], x_column: Annotated[str, Field(description='The dataframe column to plot in the x/time axis.')], y_column: Annotated[str, Field(description='The dataframe column to plot in the y/time axis.')], category_column: Annotated[str | SkipJsonSchema[None], Field(description='The column name in the dataframe to group by and plot separate traces.')] = None, line_kwargs: Annotated[LineStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Line style settings')] = None, layout_kwargs: Annotated[LayoutStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional kwargs passed to plotly.go.Figure(layout).')] = None, smoothing: Annotated[SmoothingConfig | SkipJsonSchema[None], AdvancedField(default=None, description='Configuration for line smoothing. When set, creates a smoothed line with original data point markers.')] = None, widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this tile layer belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str, Field()]
Generates a line chart from the provided params
Args: dataframe (pd.DataFrame): The input dataframe. x_column (str): The dataframe column to plot in the x/time axis. y_column (str): The dataframe column to plot in the y/time axis. category_column (str): The column name in the dataframe to group by and plot separate traces. line_kwargs (LineStyle): Additional styling options passed to each line of the chart. layout_kwargs (LayoutStyle): Additional styling styling options passed to plotly.go.Figure(layout). smoothing (SmoothingConfig): Configuration for line smoothing. When set, creates two layers: a smoothed line and original data point markers.
Returns: The generated chart html as a string
Source code in ecoscope/platform/tasks/results/_ecoplot.py
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 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
draw_map ¶
draw_map(geo_layers: Annotated[PydeckLayerDefinition | list[PydeckLayerDefinition] | SkipJsonSchema[None], Field(description='A list of map layers to add to the map.', exclude=True)] = None, tile_layers: Annotated[list[TileLayer | BitmapLayerDefinition] | SkipJsonSchema[None], Field(description='A list of tile layers (base maps and/or overlays).')] = None, static: Annotated[bool, Field(description='Set to true to disable map pan/zoom.')] = False, output_type: Annotated[Literal['html', 'json'], Field(description='Whether to return rendered HTML or a deck.gl JSON spec dict.')] = 'html', title: Annotated[str | SkipJsonSchema[None], AdvancedField(default='', description=' The map title. Note this is the title drawn on the map canvas itself, and will result\n in duplicate titles if set in the context of a dashboard in which the iframe/widget\n container also has a title set on it.\n ')] = None, legend_style: Annotated[LegendStyle | SkipJsonSchema[None], AdvancedField(default=LegendStyle(), description='Additional arguments for configuring the legend.')] = None, max_zoom: Annotated[int, AdvancedField(default=20, description=' The maximum zoom level allowed by the map.\n This setting will be overridden if provided\n tile layers max zoom levels are lower than this value.\n ')] = 20, view_state: Annotated[ViewState | SkipJsonSchema[None], AdvancedField(default=ViewState(), description='Manually set the view state of the map.')] = None, widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this tile layer belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str | DeckJsonSpec, Field()]
Creates a map based on the provided layer definitions and configuration.
Args: geo_layers (PydeckLayerDefinition | list[PydeckLayerDefinition] | None): Map layers to add to the map. tile_layers (list): A named tile layer, ie OpenStreetMap. static (bool): Set to true to disable map pan/zoom. title (str): The map title. legend_style (WidgetStyleBase): Additional arguments for configuring the Legend. max_zoom (int): The maximum zoom level of the map view_state (ViewState): Manually set the view state of the map, overrides any layer zoom settings. widget_id (str): The id of the dashboard widget that this tile layer belongs to. If set this MUST match the widget title as defined downstream in create_widget tasks
str | DeckJsonSpec: A static HTML representation of the map, or a validated
deck.gl JSON spec if output_type="json".
Source code in ecoscope/platform/tasks/results/_pydeck.py
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 | |
draw_pie_chart ¶
draw_pie_chart(dataframe: DataFrame[JsonSerializableDataFrameModel], value_column: Annotated[str, Field(description='The name of the dataframe column to pull slice values from.')], label_column: Annotated[str | SkipJsonSchema[None], AdvancedField(default=None, description='The name of the dataframe column to label slices with, required if the data in value_column is numeric.')] = None, color_column: Annotated[str | SkipJsonSchema[None], AdvancedField(default=None, description='The name of the dataframe column to color slices with.')] = None, plot_style: Annotated[PlotStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional style kwargs passed to go.Pie().')] = None, layout_style: Annotated[LayoutStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional kwargs passed to plotly.go.Figure(layout).')] = None, widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this tile layer belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str, Field()]
Generates a pie chart from the provided params
Args: dataframe (pd.DataFrame): The input dataframe. value_column (str): The name of the dataframe column to pull slice values from. label_column (str): The name of the dataframe column to label slices with, required if the data in value_column is numeric. plot_style (PlotStyle): Additional style kwargs passed to go.Pie(). layout_style (LayoutStyle): Additional kwargs passed to plotly.go.Figure(layout). widget_id (str): The id of the dashboard widget that this tile layer belongs to. If set this MUST match the widget title as defined downstream in create_widget tasks
Returns: The generated chart html as a string
Source code in ecoscope/platform/tasks/results/_ecoplot.py
draw_table ¶
draw_table(dataframe: Annotated[AnyDataFrame, Field(description='The dataframe to render as a table.', exclude=True)], columns: Annotated[list[str] | SkipJsonSchema[None], AdvancedField(description='The list of dataframe columns to render in the table. Leave empty to render all columns', default=None)] = None, table_config: Annotated[TableConfig | SkipJsonSchema[None], AdvancedField(description='Configuration options for the table.', default=None)] = None, widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this table belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str, Field()]
Creates an HTML table of the provided dataframe.
Source code in ecoscope/platform/tasks/results/_table.py
draw_time_series_bar_chart ¶
draw_time_series_bar_chart(dataframe: DataFrame[JsonSerializableDataFrameModel], x_axis: Annotated[str, Field(description='The dataframe column to plot in the x/time axis.')], y_axis: Annotated[str, Field(description='The dataframe column to plot in the y axis.')], category: Annotated[str, Field(description='The dataframe column to stack in the y axis.')], agg_function: Annotated[AggOperations, Field(description='The aggregate function to apply to the group.')], time_interval: Annotated[Literal['year', 'month', 'week', 'day', 'hour'], Field()], color_column: Annotated[str | SkipJsonSchema[None], AdvancedField(default=None, description='The name of the dataframe column to color bars with.')] = None, plot_style: Annotated[PlotStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional style kwargs passed to go.Bar().')] = None, layout_style: Annotated[BarLayoutStyle | SkipJsonSchema[None], AdvancedField(default=None, description='Additional kwargs passed to plotly.go.Figure(layout).')] = None, widget_id: Annotated[str | SkipJsonSchema[None], Field(description=' The id of the dashboard widget that this tile layer belongs to.\n If set this MUST match the widget title as defined downstream in create_widget tasks\n ', exclude=True)] = None) -> Annotated[str, Field()]
Generates a stacked time series bar chart from the provided params
Args: dataframe (pd.DataFrame): The input dataframe. x_axis (str): The dataframe column to plot in the x axis. y_axis (str): The dataframe column to plot in the y axis. category (str): The dataframe column to stack in the y axis. agg_function (str): The aggregate function to apply to the group. time_interval (str): Sets the time interval of the x axis. color_column (str): The name of the dataframe column to color bars with. plot_style (PlotStyle): Style arguments passed to plotly.graph_objects.Bar and applied to all groups. layout_style (LayoutStyle): Additional kwargs passed to plotly.go.Figure(layout). widget_id (str): The id of the dashboard widget that this tile layer belongs to. If set this MUST match the widget title as defined downstream in create_widget tasks
Returns: The generated chart html as a string
Source code in ecoscope/platform/tasks/results/_ecoplot.py
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 303 304 305 306 307 308 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 | |
gather_dashboard ¶
gather_dashboard(details: Annotated[WorkflowDetails, Field(description='Workflow details')], widgets: Annotated[NestedWidgetList | FlatWidgetList | GroupedOrSingleWidget, Field(description='The widgets to display.', exclude=True)], groupers: Annotated[AllGrouper | list[ValueGrouper | TemporalGrouper | SpatialGrouper] | SkipJsonSchema[None], Field(description=' Groupers that are used to group the widgets.\n If all widgets are ungrouped, this field defaults to `None`.\n ', exclude=True)] = None, time_range: Annotated[TimeRange | SkipJsonSchema[None], Field(description='Time range filter')] = None, warning: Annotated[str | SkipJsonSchema[None], Field(exclude=True)] = None) -> Annotated[Dashboard, Field()]
Source code in ecoscope/platform/tasks/results/_dashboard.py
gather_output_files ¶
gather_output_files(files: Annotated[list[str | list[tuple[CompositeFilter, str]]], Field(description='The files to gather.', exclude=True)]) -> OutputFiles
Gather the output files from the tasks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
Annotated[list[str | list[tuple[CompositeFilter, str]]], Field(description='The files to gather.', exclude=True)]
|
A list of files to gather output files from. |
required |
Returns:
| Type | Description |
|---|---|
OutputFiles
|
A list of output files. |
Source code in ecoscope/platform/tasks/results/_output_files.py
merge_tile_layers ¶
merge_tile_layers(base_layers: Annotated[list[TileLayer] | SkipJsonSchema[None], Field(description='Static base tile layers to prepend.')] = None, overlay: Annotated[BitmapLayerDefinition | SkipJsonSchema[None], Field(description='Per-group overlay tile layer to append.')] = None) -> Annotated[list[TileLayer | BitmapLayerDefinition], Field()]
Merges static base tile layers with a per-group overlay into a single list.
Source code in ecoscope/platform/tasks/results/_pydeck.py
merge_widget_views ¶
merge_widget_views(widgets: Annotated[list[WidgetSingleView], Field(description='The widgets to merge', exclude=True)]) -> Annotated[list[GroupedWidget], Field(description='The merged widgets')]
Merge widgets with the same title and widget_type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
widgets
|
Annotated[list[WidgetSingleView], Field(description='The widgets to merge', exclude=True)]
|
The widgets to merge. |
required |
Returns:
| Type | Description |
|---|---|
Annotated[list[GroupedWidget], Field(description='The merged widgets')]
|
The merged grouped widgets. |
Source code in ecoscope/platform/tasks/results/_widget_tasks.py
persist_geoarrow_for_pydeck ¶
persist_geoarrow_for_pydeck(gdf: Annotated[AnyGeoDataFrame, Field(description='GeoDataframe to persist as GeoArrow-encoded parquet')], root_path: Annotated[str, Field(description='Root path to persist parquet to')], filename: Annotated[str | None, Field(description='Optional filename within `root_path`. Auto-generated from a df content hash if absent. The `.parquet` extension is appended automatically.', exclude=True)] = None) -> Annotated[str, Field(description='Path to persisted parquet')]
Persist a gdf as GeoArrow-encoded parquet, ready for use in geoarrow layers.
Intended for use with the maps created by this module, use
tasks.io.persist_df(filetype='geoparquet') instead when writing for
standard WKB-expecting consumers (e.g. QGIS, PostGIS)
Source code in ecoscope/platform/tasks/results/_map_utils.py
rewrite_file_urls_for_screenshots ¶
rewrite_file_urls_for_screenshots(html: Annotated[str, Field(description='HTML string output from draw_map.')], file_urls: Annotated[list[str], Field(description='The file url strings to replace in `html`.')]) -> Annotated[str, Field()]
Rewrites file_urls in map HTML to http://127.0.0.1:<port>/
so that Playwright can fetch local files without CORS restrictions when
serve_local_files=True is set on ScreenshotConfig.
Only the filename (stem + extension) is preserved — the full local path is
dropped. For example file:///some/long/path/data.geojson becomes
http://127.0.0.1:8099/data.geojson.
The port defaults to 8099 and can be overridden via the
ECOSCOPE_SCREENSHOT_FILE_SERVER_PORT environment variable.
Source code in ecoscope/platform/tasks/results/_pydeck.py
set_base_maps ¶
set_base_maps(base_maps: Annotated[list[TileLayer] | SkipJsonSchema[None], Field(json_schema_extra=_preset_or_custom_json_schema_extra, title=' ', description='Select tile layers to use as base layers in map outputs. The first layer in the list will be the bottommost layer displayed.')] = None) -> Annotated[list[TileLayer], Field()]
Source code in ecoscope/platform/tasks/results/_map_utils.py
set_layer_opacity ¶
shift_radius_values ¶
shift_radius_values(gdf: Annotated[AnyGeoDataFrame, Field(description='Source geodataframe.', exclude=True)], radius_column: Annotated[str, Field(description='Column name whose values will be lifted/imputed for use as a scatterplot radius accessor.')]) -> Annotated[AnyGeoDataFrame, Field()]
Shifts the given radius column so that values are >= 1 and NaNs are replaced with 1. Intended for use when displaying the given gdf as a scatterplot layer, where the numeric values in radius_column determine the size of the scatterplot points.
Source code in ecoscope/platform/tasks/results/_pydeck.py
view_state_from_geodataframes ¶
view_state_from_geodataframes(geodataframes: list[AnyGeoDataFrame], max_zoom: float = 20) -> Annotated[ViewState, Field()]
Source code in ecoscope/platform/tasks/results/_pydeck.py
view_state_from_layers ¶
view_state_from_layers(layers: list[PydeckLayerDefinition], max_zoom: float = 20) -> Annotated[ViewState, Field()]