GeoServer SpatialDatasetEngine Reference

Last Updated: December 2019

This guide provides and overview the GeoServerSpatialDatasetEngine, which implements the SpatialDatasetEngine pattern.

Key Concepts

There are quite a few concepts to understand before working with GeoServer and spatial dataset services. Definitions of each are provided here for quick reference.

Resources are the spatial datasets. These can vary in format ranging from a single file or multiple files to database tables depending on the type resource.

Feature Type: is a type of resource containing vector data or data consisting of discreet features such as points, lines, or polygons and any tables of attributes that describe the features.

Coverage: is a type of resource containing raster data or numeric gridded data.

Layers: are resources that have been published. Layers associate styles and other settings with the resource that are needed to generate maps of the resource via OGC services.

Layer Groups: are preset groups of layers that can be served as WMS services as though they were one layer.

Stores: represent repositories of spatial datasets such as database tables or directories of shapefiles. A store containing only feature types is called a Data Store and a store containing only coverages is called a Coverage Store.

Workspaces: are arbitrary groupings of data to help with organization of the data. It would be a good idea to store all of the spatial datasets for your app in a workspace resembling the name of your app to avoid conflicts with other apps.

Styles: are a set of rules that dictate how a layer will be rendered when accessed via WMS. A layer may be associated with many styles and a style may be associated with many layers. Styles on GeoServer are written in Styled Layer Descriptor (SLD) format.

Styled Layer Descriptor (SLD): An XML-based markup language that can be used to specify how spatial datasets should be rendered. See GeoServer's SLD Cookbook for a good primer on SLD.

Web Feature Service (WFS): An OGC standard for exchanging vector data (i.e.: feature types) over the internet. WFS can be used to not only query for the features (points, lines, and polygons) but also the attributes associated with the features.

Web Coverage Service (WCS): An OGC standard for exchanging raster data (i.e.: coverages) over the internet. WCS is roughly the equivalent of WFS but for coverages, access to the raw coverage information, not just the image.

Web Mapping Service (WMS): An OGC standard for generating and exchanging maps of spatial data over the internet. WMS can be used to compose maps of several different spatial dataset sources and formats.

Example Usage

Consider the following example for uploading a shapefile to a GeoServer spatial dataset service:

Upload Shapefile

from my_first_app.app import MyFirstApp as app

# First get an engine
engine = app.get_spatial_dataset_service('primary_geoserver', as_engine=True)

# Create a workspace named after our app
engine.create_workspace(workspace_id='my_app', uri='http://www.example.com/apps/my-app')

# Path to shapefile base for foo.shp, side cars files (e.g.: .shx, .dbf) will be
# gathered in addition to the .shp file.
shapefile_base = '/path/to/foo'

# Notice the workspace in the store_id parameter
result = dataset_engine.create_shapefile_resource(store_id='my_app:foo', shapefile_base=shapefile_base)

# Check if it was successful
if not result['success']:
    raise

A new shapefile Data Store will be created called 'foo' in workspace 'my_app' and a resource will be created for the shapefile called 'foo'. A layer will also automatically be configured for the new shapefile resource.

Retrieve Services for a Layer

Publishing the spatial dataset with a spatial dataset service would be pointless without using the service to render the data on a map. This can be done by querying the data using the OGC web services WFS, WCS, or WMS. The dictionary that is returned when retrieving layers, layer groups, or resources includes a key for each OGC service available for the object returned. Feature type resources will provide a "wfs" key, coverage resources will provide a "wcs" key, and layers and layergroups will provide a "wms" key. The value will be another dictionary of OGC queries for different endpoints. For example:

# Get a feature type layer
response = engine.get_layer(layer_id='sf:roads', debug=True)

# Response dictionary includes "wms" key with links to maps in various formats
{'result': {'advertised': True,
            'attribution': None,
            'catalog': 'http://localhost:8181/geoserver/',
            'default_style': 'simple_roads',
            'enabled': None,
            'href': 'http://localhost:8181/geoserver/rest/layers/sf%3Aroads.xml',
            'name': 'sf:roads',
            'resource': 'sf:roads',
            'resource_type': 'layer',
            'styles': ['sf:line'],
            'wms': {'georss': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=rss',
                    'geotiff8': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/geotiff8',
                    'geptiff': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/geotiff',
                    'gif': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/gif',
                    'jpeg': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/jpeg',
                    'kml': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=kml',
                    'kmz': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=kmz',
                    'openlayers': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=application/openlayers',
                    'pdf': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=application/pdf',
                    'png': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/png',
                    'png8': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/png8',
                    'svg': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/svg',
                    'tiff': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/tiff',
                    'tiff8': 'http://localhost:8181/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=sf:roads&styles=simple_roads&transparent=true&tiled=no&srs=EPSG:26713&bbox=589434.8564686741,4914006.337837095,609527.2102150217,4928063.398014731&width=731&height=512&format=image/tiff8'}},
 'success': True}

These links can be passed to a web mapping client like OpenLayers or Google Maps to render the map interactively on a web page. Note that the OGC mapping services are very powerful and the links provided represent only a simple query. You can construct custom OGC URLs queries without much difficulty. For excellent primers on WFS, WCS, and WMS with GeoServer, visit these links:

Tip

When you are learning how to use the spatial dataset engine methods, run the commands with the debug parameter set to true. This will automatically pretty print the result dictionary to the console so that you can inspect its contents:

# Example method with debug option
engine.list_layers(debug=True)

API

The following reference provides a summary the class used to define the GeoServerSpatialDatasetEngine objects.

class tethys_dataset_services.engines.GeoServerSpatialDatasetEngine(endpoint, apikey=None, username=None, password=None, public_endpoint=None, node_ports=None)

Definition for GeoServer Dataset Engine objects.

create_coverage_layer(layer_id, coverage_type, coverage_file, default_style='', other_styles=None, debug=False)

Create a coverage store, coverage resource, and layer in the given workspace.

Parameters:
  • layer_id (string) -- Identifier of the coverage layer to be created. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

  • coverage_type (str) -- Type of coverage store to create (e.g.: GeoServerAPI.CT_ARC_GRID, GeoServerAPI.CT_GEOTIFF, GeoServerAPI.CT_GRASS_GRID).

  • coverage_file (str) -- Path to coverage file or zip archive containing coverage file.

  • default_style (str, optional) -- The name of the default style (note: it is assumed this style belongs to the workspace).

  • other_styles (list, optional) -- A list of other default style names (assumption: these styles belong to the workspace).

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

create_coverage_store(store_id, coverage_type, debug=False)

Create a new coverage store.

Parameters:
  • store_id (string) -- Identifier for the store to be created. Can be a store name or a workspace name combination (e.g.: "name" or "workspace:name"). Note that the workspace must be an existing workspace. If no workspace is given, the default workspace will be assigned.

  • coverage_type (str) -- Type of coverage store to create (e.g.: GeoServerAPI.CT_ARC_GRID, GeoServerAPI.CT_GEOTIFF, GeoServerAPI.CT_GRASS_GRID).

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

create_layer_from_postgis_store(store_id, table, debug=False)

Add an existing postgis table as a feature resource to a postgis store that already exists.

Parameters:
  • store_id (string) -- Identifier for the store to add the resource to. Can be a store name or a workspace name combination (e.g.: "name" or "workspace:name"). Note that the workspace must be an existing workspace. If no workspace is given, the default workspace will be assigned. # noqa: E501

  • table (string) -- Name of existing table to add as a feature resource. A layer will automatically be created for this resource. Both the resource and the layer will share the same name as the table. # noqa: E501

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.create_layer_from_postgis_store(store_id='workspace:store_name', table='table_name')

create_layer_group(layer_group_id, layers, styles, debug=False)

Create a layer group. The number of layers and the number of styles must be the same.

Parameters:
  • layer_group_id (string) -- Identifier of the layer group to create. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

  • layers (iterable) -- A list of layer names to be added to the group. Must be the same length as the styles list.

  • styles (iterable) -- A list of style names to associate with each layer in the group. Must be the same length as the layers list.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

layers = ('layer1', 'layer2')

styles = ('style1', 'style2')

response = engine.create_layer_group(layer_group_id='layer_group_name', layers=layers, styles=styles)

create_postgis_store(store_id, host, port, database, username, password, max_connections=5, max_connection_idle_time=30, evictor_run_periodicity=30, validate_connections=True, debug=False)

Use this method to link an existing PostGIS database to GeoServer as a feature store. Note that this method only works for data in vector formats.

Parameters:
  • store_id (string) -- Identifier for the store to add the resource to. Can be a store name or a workspace name combination (e.g.: "name" or "workspace:name"). Note that the workspace must be an existing workspace. If no workspace is given, the default workspace will be assigned.

  • host (string) -- Host of the PostGIS database (e.g.: 'www.example.com').

  • port (string) -- Port of the PostGIS database (e.g.: '5432')

  • database (string) -- Name of the database.

  • username (string) -- Database user that has access to the database.

  • password (string) -- Password of database user.

  • max_connections (int, optional) -- Maximum number of connections allowed in connection pool. Defaults to 5.

  • max_connection_idle_time (int, optional) -- Number of seconds a connections can stay idle before the evictor considers closing it. Defaults to 30 seconds.

  • evictor_run_periodicity (int, optional) -- Number of seconds between idle connection evictor runs. Defaults to 30 seconds.

  • validate_connections (bool, optional) -- Test connections before using. Defaults to True.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

engine.create_postgis_store(store_id='workspace:name', host='localhost', port='5432', database='database_name', username='user', password='pass')

create_shapefile_resource(store_id, shapefile_base=None, shapefile_zip=None, shapefile_upload=None, overwrite=False, charset=None, debug=False)

Use this method to add shapefile resources to GeoServer.

This method will result in the creation of three items: a feature type store, a feature type resource, and a layer. If store_id references a store that does not exist, it will be created. The feature type resource and the subsequent layer will be created with the same name as the feature type store. Provide shapefile with either shapefile_base, shapefile_zip, or shapefile_upload arguments. # noqa: E501

Parameters:
  • store_id (string) -- Identifier for the store to add the resource to. Can be a store name or a workspace name combination (e.g.: "name" or "workspace:name"). Note that the workspace must be an existing workspace. If no workspace is given, the default workspace will be assigned. # noqa: E501

  • shapefile_base (string, optional) -- Path to shapefile base name (e.g.: "/path/base" for shapefile at "/path/base.shp")

  • shapefile_zip (string, optional) -- Path to a zip file containing the shapefile and side cars.

  • shapefile_upload (FileUpload list, optional) -- A list of Django FileUpload objects containing a shapefile and side cars that have been uploaded via multipart/form-data form. # noqa: E501

  • overwrite (bool, optional) -- Overwrite the file if it already exists.

  • charset (string, optional) -- Specify the character encoding of the file being uploaded (e.g.: ISO-8559-1)

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

# For example.shp (path to file but omit the .shp extension)

shapefile_base = "/path/to/shapefile/example"

response = engine.create_shapefile_resource(store_id='workspace:store_name', shapefile_base=shapefile_base)

# Using zip

shapefile_zip = "/path/to/shapefile/example.zip"

response = engine.create_shapefile_resource(store_id='workspace:store_name', shapefile_zip=shapefile_zip)

# Using upload

file_list = request.FILES.getlist('files')

response = engine.create_shapefile_resource(store_id='workspace:store_name', shapefile_upload=file_list)

create_sql_view_layer(store_id, layer_name, geometry_type, srid, sql, default_style, geometry_name='geometry', other_styles=None, parameters=None, reload_public=False, debug=False)

Direct call to GeoServer REST API to create SQL View feature types and layers.

Parameters:
  • store_id (string) -- Identifier of existing postgis store with tables that will be queried by the sql view. (e.g.: "store_name" or "workspace:store_name").

  • layer_name (string) -- Identifier of the sql view layer to create. (The layer will be created on the workspace of the existing store).

  • geometry_name -- Name of the PostGIS column/field of type geom.

  • geometry_type -- Type of geometry in geometry field (e.g.: Point, LineString)

  • srid (int) -- EPSG spatial reference id. EPSG spatial reference ID.

  • sql -- The SQL query that defines the feature type.

  • default_style -- The name of the default style. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

  • other_styles -- A list of other default style names. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

  • parameters -- A list of parameter dictionaries { name, default_value, regex_validator }.

  • reload_public -- (bool, optional): Reload the catalog using the public endpoint. Defaults to False.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

create_style(style_id, sld_template, sld_context=None, overwrite=False, debug=False)

Create style layer from an SLD template.

Args

style_id (string): Identifier of the style to create ('<workspace>:<name>'). sld_template: path to SLD template file. sld_context: a dictionary with context variables to be rendered in the template. overwrite (bool, optional): Will overwrite existing style with same name if True. Defaults to False.

create_workspace(workspace_id, uri, debug=False)

Create a new workspace.

Parameters:
  • workspace_id (string) -- Identifier of the workspace to create. Must be unique.

  • uri (string) -- URI associated with your project. Does not need to be a real web URL, just a unique identifier. One suggestion is to append the URL of your project with the name of the workspace (e.g.: http:www.example.com/workspace-name). # noqa: E501

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.create_workspace(workspace_id='workspace_name', uri='www.example.com/workspace_name')

delete_coverage_store(store_id, recurse=True, purge=True)

Delete the specified coverage store.

Parameters:
  • store_id (string) -- Identifier for the store to be deleted. Can be a store name or a workspace name combination (e.g.: "name" or "workspace:name"). Note that the workspace must be an existing workspace. If no workspace is given, the default workspace will be assigned.

  • recurse (bool) -- recursively delete any dependent objects if True.

  • purge (bool) -- delete configuration files from filesystem if True. remove file from disk of geoserver.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

delete_layer(layer_id, datastore, recurse=False)
Parameters:
  • layer_id (string) -- Identifier of the layer to delete. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

  • datastore -- Name of datastore

  • recurse (bool) -- recursively delete any dependent objects if True.

delete_layer_group(layer_group_id)
Parameters:

layer_group_id (string) -- Identifier of the layer group to delete. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

delete_resource(resource_id, store_id, purge=False, recurse=False, debug=False)

Delete a resource.

Parameters:
  • resource_id (string) -- Identifier of the resource to delete. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • store_id (string) -- Return only resources belonging to a certain store.

  • purge (bool, optional) -- Purge if True.

  • recurse (bool, optional) -- Delete recursively any dependencies if True (i.e.: layers or layer groups it belongs to). # noqa: E501

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.delete_resource('workspace:resource_name')

delete_store(store_id, purge=False, recurse=False, debug=False)

Delete a store.

Parameters:
  • store_id (string) -- Identifier of the store to delete.

  • purge (bool, optional) -- Purge if True.

  • recurse (bool, optional) -- Delete recursively if True.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.delete_store('workspace:store_name')

delete_style(style_id, purge=False)

Delete the style with the given workspace and style name.

Parameters:
  • style_id (string) -- Identifier of the style to delete. Can be a store name or a workspace name combination (e.g.: "name" or "workspace:name").

  • purge (bool) -- delete configuration files from filesystem if True. remove file from disk of geoserver.

Returns:

delete_workspace(workspace_id, purge=False, recurse=False, debug=False)

Delete a workspace.

Parameters:
  • workspace_id (string) -- Identifier of the workspace to delete.

  • purge (bool, optional) -- Purge if True.

  • recurse (bool, optional) -- Delete recursively if True.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.delete_resource('workspace_name')

enable_time_dimension(coverage_id)

Enable time dimension for a given image mosaic layer

Parameters:

coverage_id (str) -- name of the image mosaic layer including workspace. (e.g: workspace:name).

Raises:

requests.RequestException -- if enable time dimension operation cannot be executed successfully.

get_gwc_endpoint(public=True)

Returns the GeoServer endpoint for GWC services (with trailing slash).

Parameters:

public (bool) -- return with the public endpoint if True.

get_layer(layer_id, store_id=None, debug=False)

Retrieve a layer object.

Parameters:
  • layer_id (string) -- Identifier of the layer to retrieve. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • store_id (string, optional) -- Return only resources belonging to a certain store.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.get_layer('layer_name')

response = engine.get_layer('workspace_name:layer_name')

get_layer_extent(store_id, feature_name, native=False, buffer_factor=1.000001)

Get the legend extent for the given layer.

Parameters:
  • datastore_name -- Name of a GeoServer data store (assumption: the datastore belongs to the workspace).

  • feature_name -- Name of the feature type. Will also be used to name the layer.

  • native (bool) -- True if the native projection extent should be used. Defaults to False.

  • buffer_factor (float) -- Apply a buffer around the bounding box.

get_layer_group(layer_group_id, debug=False)

Retrieve a layer group object.

Parameters:
  • layer_group_id (string) -- Identifier of the layer group to retrieve. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.get_layer_group('layer_group_name')

response = engine.get_layer_group('workspace_name:layer_group_name')

get_ows_endpoint(workspace, public=True)

Returns the GeoServer endpoint for OWS services (with trailing slash).

Parameters:
  • workspace (str) -- the name of the workspace

  • public (bool) -- return with the public endpoint if True.

get_resource(resource_id, store_id=None, debug=False)

Retrieve a resource object.

Parameters:
  • resource_id (string) -- Identifier of the resource to retrieve. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • store (string, optional) -- Get resource from this store.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.get_resource('example_workspace:resource_name')

response = engine.get_resource('resource_name', store='example_store')

get_store(store_id, debug=False)

Retrieve a store object.

Parameters:
  • store_id (string) -- Identifier of the store to retrieve. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.get_store('store_name')

response = engine.get_store('workspace_name:store_name')

get_style(style_id, debug=False)

Retrieve a style object.

Parameters:
  • style_id (string) -- Identifier of the style to retrieve.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.get_style('style_name')

get_wms_endpoint(public=True)

Returns the GeoServer endpoint for WMS services (with trailing slash).

Parameters:

public (bool) -- return with the public endpoint if True.

get_workspace(workspace_id, debug=False)

Retrieve a workspace object.

Parameters:
  • workspace_id (string) -- Identifier of the workspace to retrieve.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.get_workspace('workspace_name')

gwc_reload(ports=None, public=True)

Reload the GeoWebCache configuration from disk.

Parameters:
  • ports (iterable) -- A tuple or list of integers representing the ports on which different instances of GeoServer are running in a clustered GeoServer configuration.

  • public (bool) -- Use the public geoserver endpoint if True, otherwise use the internal endpoint.

Helper function to simplify linking postgis databases to geoservers using the sqlalchemy engine object.

Parameters:
  • store_id (string) -- Identifier for the store to add the resource to. Can be a store name or a workspace name combination (e.g.: "name" or "workspace:name"). Note that the workspace must be an existing workspace. If no workspace is given, the default workspace will be assigned. # noqa: E501

  • sqlalchemy_engine (sqlalchemy_engine) -- An SQLAlchemy engine object.

  • docker (bool, optional) -- Set to True if the database and geoserver are running in a Docker container. Defaults to False. # noqa: E501

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

  • docker_ip_address (str, optional) -- Override the docker network ip address. Defaults to '172.17.0.1'.

Returns:

Response dictionary

Return type:

(dict)

list_layer_groups(with_properties=False, debug=False)

List the names of all layer groups available from the spatial dataset service.

Parameters:
  • with_properties (bool, optional) -- Return list of layer group dictionaries instead of a list of layer group names. # noqa: E501

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.list_layer_groups()

response = engine.list_layer_groups(with_properties=True)

list_layers(with_properties=False, debug=False)

List names of all layers available from the spatial dataset service.

Parameters:
  • with_properties (bool, optional) -- Return list of layer dictionaries instead of a list of layer names.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.list_layers()

response = engine.list_layers(with_properties=True)

list_resources(with_properties=False, store=None, workspace=None, debug=False)

List the names of all resources available from the spatial dataset service.

Parameters:
  • with_properties (bool, optional) -- Return list of resource dictionaries instead of a list of resource names.

  • store (string, optional) -- Return only resources belonging to a certain store.

  • workspace (string, optional) -- Return only resources belonging to a certain workspace.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.list_resource()

response = engine.list_resource(store="example_store")

response = engine.list_resource(with_properties=True, workspace="example_workspace")

list_stores(workspace=None, with_properties=False, debug=False)

List the names of all stores available from the spatial dataset service.

Parameters:
  • workspace (string, optional) -- List long stores belonging to this workspace.

  • with_properties (bool, optional) -- Return list of store dictionaries instead of a list of store names.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.list_stores()

response = engine.list_stores(workspace='example_workspace", with_properties=True)

list_styles(workspace=None, with_properties=False, debug=False)

List the names of all styles available from the spatial dataset service.

Parameters:
  • workspace (string) -- Return only resources belonging to a certain workspace.

  • with_properties (bool, optional) -- Return list of style dictionaries instead of a list of style names.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.list_styles()

response = engine.list_styles(with_properties=True)

list_workspaces(with_properties=False, debug=False)

List the names of all workspaces available from the spatial dataset service.

Parameters:
  • with_properties (bool, optional) -- Return list of workspace dictionaries instead of a list of workspace names.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.list_workspaces()

response = engine.list_workspaces(with_properties=True)

modify_tile_cache(layer_id, operation, zoom_start=10, zoom_end=15, grid_set_id=900913, image_format='image/png', thread_count=1, bounds=None, parameters=None)

Modify all or a portion of the GWC tile cache for given layer. Operations include seed, reseed, and truncate.

Parameters:
  • layer_id (string) -- Identifier of the layer. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

  • operation (str) -- operation type either 'seed', 'reseed', 'truncate', or 'masstruncate'.

  • zoom_start (int, optional) -- beginning of zoom range on which to perform tile cache operation. Minimum is 0. Defaults to 10.

  • zoom_end (int, optional) -- end of zoom range on which to perform tile cache operation. It is not usually recommended to seed past zoom 20. Maximum is 30. Defaults to 15.

  • grid_set_id (int, optional) -- ID of the grid set on which to perform the tile cache operation. Either 4326 for Geographic or 900913 for Web Mercator. Defaults to 900913.

  • image_format (str, optional) -- format of tiles on which to perform tile cache operation. Defaults to 'image/png'.

  • thread_count (int, optional) -- number of threads to used to perform tile cache operation. Defaults to 1.

  • bounds (list, optional) -- list with ordinates of bounding box of area on which to perform tile cache operation (e.g.: [minx, miny, maxx, maxy]).

  • parameters (dict, optional) -- Key value pairs of parameters to use to filter tile cache operation.

Raises:
  • requests.RequestException -- if modify tile cache operation is not submitted successfully.

  • ValueError -- if invalid value is provided for an argument.

query_tile_cache_tasks(layer_id)

Get the status of running tile cache tasks for a layer.

Parameters:

layer_id (string) -- Identifier of the layer. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

Returns:

list of dictionaries with status with keys: 'tiles_processed', 'total_to_process', 'num_remaining', 'task_id', 'task_status'

Return type:

list

Raises:

requests.RequestException -- if query tile cache operation cannot be submitted successfully.

reload(ports=None, public=True)

Reload the configuration from disk.

Parameters:
  • ports (iterable) -- A tuple or list of integers representing the ports on which different instances of GeoServer are running in a clustered GeoServer configuration.

  • public (bool) -- Use the public geoserver endpoint if True, otherwise use the internal endpoint.

terminate_tile_cache_tasks(layer_id, kill='all')

Terminate running tile cache processes for given layer.

Parameters:
  • layer_id (string) -- Identifier of the layer. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

  • kill (str) -- specify which type of task to terminate. Either 'running', 'pending', or 'all'.

Raises:
  • requests.RequestException -- if terminate tile cache operation cannot be submitted successfully.

  • ValueError -- if invalid value is provided for an argument.

property type

GeoServer Spatial Dataset Type

update_layer(layer_id, debug=False, **kwargs)

Update an existing layer.

Parameters:
  • layer_id (string) -- Identifier of the layer to update. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

  • **kwargs (kwargs, optional) -- Key value pairs representing the attributes and values to change.

Returns:

Response dictionary

Return type:

(dict)

Examples

updated_layer = engine.update_layer(layer_id='workspace:layer_name', default_style='style1', styles=['style1', 'style2']) # noqa: E501

update_layer_group(layer_group_id, debug=False, **kwargs)

Update an existing layer. If modifying the layers, ensure the number of layers and the number of styles are the same.

Parameters:
  • layer_group_id (string) -- Identifier of the layer group to update.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

  • **kwargs (kwargs, optional) -- Key value pairs representing the attributes and values to change

Returns:

Response dictionary

Return type:

(dict)

Examples

updated_layer_group = engine.update_layer_group(layer_group_id='layer_group_name', layers=['layer1', 'layer2'], styles=['style1', 'style2']) # noqa: E501

update_layer_styles(layer_id, default_style, other_styles=None, debug=False)

Update/add styles to existing layer.

Parameters:
  • layer_id (string) -- Identifier of the layer whose style will be update or added. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name").

  • default_style (str) -- Name of default style. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name")

  • other_styles (list<str>) -- Additional styles to add to layer. List elements can be names or workspace-name combinations (e.g.: "name" or "workspace:name")

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

update_resource(resource_id, store=None, debug=False, **kwargs)

Update an existing resource.

Parameters:
  • resource_id (string) -- Identifier of the resource to update. Can be a name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • store (string, optional) -- Update a resource in this store.

  • debug (bool, optional) -- Pretty print the response dictionary to the console for debugging. Defaults to False.

  • **kwargs (kwargs, optional) -- Key value pairs representing the attributes and values to change.

Returns:

Response dictionary

Return type:

(dict)

Examples

response = engine.update_resource(resource_id='workspace:resource_name', enabled=False, title='New Title')

validate()

Validate the GeoServer spatial dataset engine. Will throw and error if not valid.