Table Of Contents
Table Of Contents

GeoServer Spatial Dataset Engine Reference

Last Updated: January 30, 2015

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.

Args

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

Args

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

Args

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.

Args

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

Examples

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.