Table Of Contents
Table Of Contents

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)

Definition for GeoServer Dataset Engine objects.

add_table_to_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.add_table_to_postgis_store(store_id='workspace:store_name', table='table_name')

create_coverage_resource(store_id, coverage_type, coverage_file=None, coverage_upload=None, coverage_name=None, overwrite=False, query_after_success=True, debug=False)

Use this method to add coverage resources to GeoServer.

This method will result in the creation of three items: a coverage store, a coverage resource, and a layer. If store_id references a store that does not exist, it will be created. Unless coverage_name is specified, the coverage resource and the subsequent layer will be created with the same name as the image file that is uploaded. # noqa: E501

Parameters
  • store_id (string) -- Identifier for the store to add the image to or to be created. Can be a 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

  • coverage_type (string) -- Type of coverage that is being created. Valid values include: 'geotiff', 'worldimage', 'imagemosaic', 'imagepyramid', 'gtopo30', 'arcgrid', 'grassgrid', 'erdasimg', 'aig', 'gif', 'png', 'jpeg', 'tiff', 'dted', 'rpftoc', 'rst', 'nitf', 'envihdr', 'mrsid', 'ehdr', 'ecw', 'netcdf', 'erdasimg', 'jp2mrsid'. # noqa: E501

  • coverage_file (string, optional) -- Path to the coverage image or zip archive. Most files will require a .prj file with the Well Known Text definition of the projection. Zip this file up with the image and send the archive. # noqa: E501

  • coverage_upload (FileUpload list, optional) -- A list of Django FileUpload objects containing a coverage file and .prj file or archive that have been uploaded via multipart/form-data form. # noqa: E501

  • coverage_name (string) -- Name of the coverage resource and subsequent layer that are created. If unspecified, these will match the name of the image file that is uploaded. # 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)

  • query_after_success (bool, optional) -- Query geoserver for resource objects after successful upload. Defaults to True.

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

Note

If the type coverage being uploaded includes multiple files (e.g.: image, world file, projecttion file), they must be uploaded as a zip archive. Otherwise upload the single file. # noqa: E501

Returns

Response dictionary

Return type

(dict)

Examples

coverage_file = '/path/to/geotiff/example.zip'

response = engine.create_coverage_resource(store_id='workspace:store_name', coverage_file=coverage_file, coverage_type='geotiff') # noqa: E501

create_layer_group(layer_group_id, layers, styles, bounds=None, 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.

  • 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. # noqa: #501

  • bounds (iterable) -- A tuple representing the bounding box of the layer group (e.g.: ('-74.02722', '-73.907005', '40.684221', '40.878178', 'EPSG:4326') ) # noqa: #501

  • 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')

bounds = ('-74.02722', '-73.907005', '40.684221', '40.878178', 'EPSG:4326')

response = engine.create_layer_group(layer_group_id='layer_group_name', layers=layers, styles=styles, bounds=bounds) # noqa: E501

create_postgis_feature_resource(store_id, host, port, database, user, password, table=None, 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. # 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

  • 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.

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

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

  • table (string, optional) -- Name of existing table to add as a feature resource to the newly created feature store. A layer will automatically be created for the feature resource as well. Both the layer and the resource 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

# With Table

response = engine.create_postgis_feature_resource(store_id='workspace:store_name', table='table_name', host='localhost', port='5432', database='database_name', user='user', password='pass') # noqa: E501

# Without table

response = engine.create_postgis_resource(store_id='workspace:store_name', host='localhost', port='5432', database='database_name', user='user', password='pass') # noqa: E501

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(feature_type_name, postgis_store_id, sql, geometry_column, geometry_type, geometry_srid=4326, default_style_id=None, key_column=None, parameters=None, debug=False)

Create a new feature type configured as an SQL view.

Parameters
  • feature_type_name (string) -- Name of the feature type and layer to be created.

  • postgis_store_id (string) -- Identifier of existing postgis store with tables that will be queried by the sql view. Can be a store name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • sql (string) -- SQL that will be used to construct the sql view / virtual table.

  • geometry_column (string) -- Name of the geometry column.

  • geometry_type (string) -- Type of the geometry column (e.g. "Point", "LineString", "Polygon").

  • geometry_srid (string, optional) -- EPSG spatial reference id of the geometry column. Defaults to 4326.

  • default_style_id (string, optional) -- Identifier of a style to assign as the default style. Can be a style name or a workspace-name combination (e.g.: "name" or "workspace:name"). # noqa: E501

  • key_column (string, optional) -- The name of the key column.

  • parameters (iterable, optional) -- A list/tuple of tuple-triplets representing parameters in the form (name, default, regex_validation), (e.g.: (('variable', 'pressure', '^[w]+$'), ('simtime', '0:00:00', '^[w:]+$')) # noqa: E501,W605

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

Returns

Response dictionary

Return type

(dict)

Example:

sql = "SELECT name, value, geometry FROM pipes"

response = engine.create_sql_view(
    feature_type_name='my_feature_type',
    postgis_store_id='my_workspace:my_postgis_store',
    sql=sql,
    geometry_column='geometry',
    geometry_type='LineString',
    geometry_srid=32144,
    default_style_id='my_workspace:pipes',
    debug=True
)
create_style(style_id, sld, overwrite=False, debug=False)

Create a new SLD style object.

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

  • sld (string) -- Styled Layer Descriptor string

  • overwrite (bool, optional) -- Overwrite if style already exists. Defaults to False.

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

Returns

Response dictionary

Return type

(dict)

Examples

sld = '/path/to/style.sld'

sld_file = open(sld, 'r')

response = engine.create_style(style_id='fred', sld=sld_file.read(), debug=True)

sld_file.close()

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_layer(layer_id, store_id=None, purge=False, recurse=False, debug=False)

Delete a layer.

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"). # noqa: E501

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

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

  • recurse (bool, optional) -- Delete recursively if True (i.e: delete layer groups it belongs to).

  • 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_layer('workspace:layer_name')

delete_layer_group(layer_group_id, purge=False, recurse=False, debug=False)

Delete a layer group.

Parameters
  • layer_group_id (string) -- Identifier of the layer group 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_layer_group('layer_group_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, recurse=False, debug=False)

Delete a style.

Parameters
  • style_id (string) -- Identifier of the style 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('style_name')

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')

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_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_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_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')

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.41.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)

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_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.