Mosaic

The Mosaic module provides functionality for working with mosaics.

class Mosaic(api, uuid, data={})[source]

Bases: Raster

Parameters:
BASE_ENDPOINT: str = 'mosaics/'
__init__(api, uuid, data={})[source]

Initialize a Mosaic instance.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • uuid (str) – The unique identifier for the mosaic.

  • data (Dict, optional) – The data of the mosaic.

classmethod get_mosaics(api, **kwargs)[source]

Get a list of mosaics.

Parameters:

api (GeoboxClient) – The GeoboxClient instance for making requests.

Keyword Arguments:
  • q (str) – query filter based on OGC CQL standard. e.g. “field1 LIKE ‘%GIS%’ AND created_at > ‘2021-01-01’”.

  • seacrh (str) – search term for keyword-based searching among search_fields or all textual fields if search_fields does not have value. NOTE: if q param is defined this param will be ignored.

  • search_fields (str) – comma separated list of fields for searching.

  • order_by (str) – comma separated list of fields for sorting results [field1 A|D, field2 A|D, …]. e.g. name A, type D. NOTE: “A” denotes ascending order and “D” denotes descending order.

  • return_count (bool) – if true, the number of mosaics will be returned.

  • skip (int) – number of mosaics to skip. minimum value is 0.

  • limit (int) – maximum number of mosaics to return. minimum value is 1.

  • user_id (int) – specific user. privileges required.

  • shared (bool) – Whether to return shared mosaics. default is False.

Returns:

A list of Mosaic instances or the number of mosaics.

Return type:

List[‘Mosaic’] | int

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaics = Mosaic.get_mosaics(client, q="name LIKE '%GIS%'")
or
>>> mosaics = client.get_mosaics(q="name LIKE '%GIS%'")
classmethod get_mosaics_by_ids(api, ids, user_id=None)[source]

Get mosaics by their IDs.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • ids (List[str]) – The IDs of the mosaics.

  • user_id (int, optional) – specific user. privileges required.

Returns:

A list of Mosaic instances.

Return type:

List[Mosaic]

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaics = Mosaic.get_mosaics_by_ids(client, ids=['1, 2, 3'])
or
>>> mosaics = client.get_mosaics_by_ids(ids=['1, 2, 3'])
classmethod create_mosaic(api, name, display_name=None, description=None, pixel_selection=None, min_zoom=None, user_id=None)[source]

Create New Raster Mosaic

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • name (str) – The name of the mosaic.

  • display_name (str, optional) – The display name of the mosaic.

  • description (str, optional) – The description of the mosaic.

  • pixel_selection (str, optional) – The pixel selection of the mosaic.

  • min_zoom (int, optional) – The minimum zoom of the mosaic.

  • user_id (int, optional) – specific user. privileges required.

Returns:

The created mosaic.

Return type:

Mosaic

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.create_mosaic(client, name='mosaic_name')
or
>>> mosaic = client.create_mosaic(name='mosaic_name')
classmethod get_mosaic(api, uuid, user_id=None)[source]

Get a mosaic by uuid.

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • uuid (str) – The UUID of the mosaic.

  • user_id (int, optional) – specific user. privileges required.

Returns:

The mosaic object.

Return type:

Mosaic

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
or
>>> mosaic = client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
classmethod get_mosaic_by_name(api, name, user_id=None)[source]

Get a mosaic by name

Parameters:
  • api (GeoboxClient) – The GeoboxClient instance for making requests.

  • name (str) – the name of the mosaic to get

  • user_id (int, optional) – specific user. privileges required.

Returns:

returns the mosaic if a mosaic matches the given name, else None

Return type:

Mosaic | None

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic_by_name(client, name='test')
or
>>> mosaic = client.get_mosaic_by_name(name='test')
update(**kwargs)[source]

Update a mosaic.

Keyword Arguments:
  • name (str) – The name of the mosaic.

  • display_name (str) – The display name of the mosaic.

  • description (str) – The description of the mosaic.

  • pixel_selection (str) – The pixel selection of the mosaic.

  • min_zoom (int) – The minimum zoom of the mosaic.

Returns:

the updated data

Return type:

Dict

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.update(name='new_name', display_name='new_display_name', description='new_description', pixel_selection='new_pixel_selection', min_zoom=10)
delete()[source]

Delete the mosaic.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.delete()
property thumbnail: str

Get the thumbnail of the mosaic.

Returns:

The thumbnail url of the mosaic.

Return type:

str

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.thumbnail
get_point(lat, lng)[source]

Get the points of the mosaic.

Parameters:
  • lat (float) – The latitude of the point.

  • lng (float) – The longitude of the point.

Returns:

The points of the mosaic.

Return type:

List[float]

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.get_point(lat=60, lng=50)
get_render_png_url(x='{x}', y='{y}', z='{z}', **kwargs)[source]

Get the tile render URL of the mosaic.

Parameters:
  • x (int, optional) – The x coordinate of the tile.

  • y (int, optional) – The y coordinate of the tile.

  • z (int, optional) – The zoom level of the tile.

Keyword Arguments:
  • indexes (str, optional) – list of comma separated band indexes to be rendered. e.g. 1, 2, 3

  • nodata (int, optional)

  • expression (str, optional) – band math expression. e.g. b1*b2+b3

  • rescale (List, optional) – comma (‘,’) separated Min,Max range. Can set multiple time for multiple bands.

  • color_formula (str, optional) – Color formula. e.g. gamma R 0.5

  • colormap_name (str, optional)

  • colormap (str, optional) – JSON encoded custom Colormap. e.g. {“0”: “#ff0000”, “1”: “#00ff00”} or [[[0, 100], “#ff0000”], [[100, 200], “#00ff00”]]

Returns:

The tile render URL of the mosaic.

Return type:

str

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.get_tile_render_url(x=1, y=1, z=1)
get_tile_png_url(x='{x}', y='{y}', z='{z}')[source]

Get the tile PNG URL of the mosaic.

Parameters:
  • x (int, optional) – The x coordinate of the tile.

  • y (int, optional) – The y coordinate of the tile.

  • z (int, optional) – The zoom level of the tile.

Returns:

The tile PNG URL of the mosaic.

Return type:

str

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.get_tile_png_url(x=1, y=1, z=1)
get_tile_json()[source]

Get the tile JSON of the raster.

Returns:

The tile JSON of the raster.

Return type:

str

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.get_tile_json()
wmts(scale=None)[source]

Get the WMTS URL

Parameters:

scale (int, optional) – The scale of the raster. values are: 1, 2

Returns:

The WMTS URL of the mosaic.

Return type:

str

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.wmts(scale=1)
property settings: Dict

Get the settings of the mosaic.

Returns:

The settings of the mosaic.

Return type:

Dict

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.settings
update_settings(settings)[source]

Update the settings

settings (Dict): settings dictionary

Returns:

updated settings

Return type:

Dict

Parameters:

settings (Dict)

Example

>>> from geobox import GeoboxClient
>>> client = GeoboxClient()
>>> mosaic1 = client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic2 = client.get_mosaic(uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic1.update_settings(mosaic2.settings)
set_settings(**kwargs)[source]

Set the settings of the mosaic.

Keyword Arguments:
  • nodata (int) – The nodata value of the raster.

  • indexes (list[int]) – The indexes of the raster.

  • rescale (list[int]) – The rescale of the raster.

  • colormap_name (str) – The colormap name of the raster.

  • color_formula (str) – The color formula of the raster.

  • expression (str) – The expression of the raster.

  • exaggeraion (int) – The exaggeraion of the raster.

  • min_zoom (int) – The min zoom of the raster.

  • max_zoom (int) – The max zoom of the raster.

  • use_cache (bool) – Whether to use cache of the raster.

  • cache_until_zoom (int) – The cache until zoom of the raster.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.set_settings(nodata=0,
...                         indexes=[1],
...                         rescale=[[0, 10000]],
...                         colormap_name='gist_rainbow',
...                         color_formula='Gamma R 0.5',
...                         expression='b1 * 2',
...                         exaggeraion=10,
...                         min_zoom=0,
...                         max_zoom=22,
...                         use_cache=True,
...                         cache_until_zoom=17)
get_rasters(user_id=None)[source]

Get the rasters of the mosaic

Parameters:

user_id (int, optional) – specific user. privileges required.

Returns:

The rasters of the mosaic.

Return type:

List[Raster]

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> rasters = mosaic.get_rasters()
add_rasters(rasters)[source]

Add a raster to the mosaic.

Parameters:

rasters (List[Raster]) – list of raster objects to add

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> rasters = client.get_rasters()
>>> mosaic.add_raster(rasters=rasters)
remove_rasters(rasters)[source]

Remove a raster from the mosaic.

Parameters:

rasters (List[Raster]) – list of raster objects to remove

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> rasters = client.get_raster()
>>> mosaic.remove_rasters(rasters=rasters)
share(users)[source]

Shares the mosaic with specified users.

Parameters:

users (List[User]) – The list of user objects to share the mosaic with.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> users = client.search_users(search='John')
>>> mosaic.share(users=users)
unshare(users)[source]

Unshares the mosaic with specified users.

Parameters:

users (List[User]) – The list of user objects to unshare the mosaic with.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> users = client.search_users(search='John')
>>> mosaic.unshare(users=users)
get_shared_users(search=None, skip=0, limit=10)[source]

Retrieves the list of users the file is shared with.

Parameters:
  • search (str, optional) – The search query.

  • skip (int, optional) – The number of users to skip.

  • limit (int, optional) – The maximum number of users to retrieve.

Returns:

The list of shared users.

Return type:

List[User]

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.get_shared_users(search='John', skip=0, limit=10)
seed_cache(from_zoom=None, to_zoom=None, extent=None, workers=1)[source]

Seed the cache of the mosaic.

Parameters:
  • from_zoom (int, optional) – The from zoom of the mosaic.

  • to_zoom (int, optional) – The to zoom of the mosaic.

  • extent (list[int], optional) – The extent of the mosaic.

  • workers (int, optional) – The number of workers to use. default is 1.

Returns:

The task of the seed cache.

Return type:

List[Task]

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> task = mosaic.seed_cache(from_zoom=0, to_zoom=22, extent=[0, 0, 100, 100], workers=1)
clear_cache()[source]

Clear the cache of the mosaic.

Returns:

None

Return type:

None

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.clear_cache()
property cache_size: int

Get the size of the cache of the mosaic.

Returns:

The size of the cache of the mosaic.

Return type:

int

Example

>>> from geobox import GeoboxClient
>>> from geobox.mosaic import Mosaic
>>> client = GeoboxClient()
>>> mosaic = Mosaic.get_mosaic(client, uuid="12345678-1234-5678-1234-567812345678")
>>> mosaic.cache_size