geoserver_pyadm package

Submodules

geoserver_pyadm.coveragestore module

geoserver_pyadm.coveragestore.create_coverage(workspace_name, store_name, coverage_name)[source]

Create a coverage within a coverage store. It is more like publishing a layer? Anyway, it is useful for image mosaic stores, which allows multiple coverages in one store.

Parameters:
  • workspace_name – workspace name

  • store_name – coverage store name

  • coverage_name – the name of the new coverage

geoserver_pyadm.coveragestore.create_coverage_store(workspace_name, store_name, file_path, format='GeoTIFF')[source]

Create a coverage store from a raster file on the geoserver.

Parameters:
  • workspace_name – the name of workspace

  • store_name – the name of the coverage store which you would like to create

  • file_path – the file_path on the geoserver, relative to the “data_dir” You can find the “Data directory”/ “data_dir” in the “server status” page.

  • format – raster format, such as GeoTIFF, WorldImage, NetCDF

geoserver_pyadm.coveragestore.delete_coverage_store(workspace_name, store_name)[source]
geoserver_pyadm.coveragestore.get_available_coverage_names(workspace_name, store_name)[source]
return a list of names of available coverages within a coverage store.

This is something like unpublished layers. You can use create_coverage() to publish the layers.

Parameters:
  • workspace_name – workspace name

  • store_name – coverage store name

geoserver_pyadm.coveragestore.get_coverage_store_info(workspace_name, store_name)[source]

return the coverage store configuration in json format

Parameters:
  • workspace_name – workspace name

  • store_name – coverage store name

geoserver_pyadm.coveragestore.get_coverage_stores(workspace_name)[source]

return a list of names of coverage store within a workspace

Parameters:

workspace_name – workspace name

geoserver_pyadm.datastore module

geoserver_pyadm.datastore.create_datastore(workspace_name, store_name, file_path, is_dir=False)[source]
Create a datastore from a folder or .shp on the server.

The folder or .shp must have already been on the server.

Parameters:
  • workspace_name – the name of destine workspace in which you would like to create the data store

  • store_name – the name of data store which you would like to create

  • file_path – the file_path on the geoserver, relative to the “data_dir” (can be a path or a .shp file). You can find the “Data directory”/ “data_dir” in the “server status” page.

  • is_dir – flag to indicate if the store is a shapefile directory

geoserver_pyadm.datastore.create_geopackage_store(workspace_name, store_name, file_path)[source]
Create a datastore from a geopackage file.

The geopackage file must have already been on the server.

Parameters:
  • workspace_name – the name of destine workspace in which you would like to create the data store

  • store_name – the name of data store which you would like to create

  • file_path – the file_path on the geoserver, relative to the “data_dir” (can be a path or a .shp file). You can find the “Data directory”/ “data_dir” in the “server status” page.

geoserver_pyadm.datastore.delete_datastore(workspace_name, store_name)[source]

Delete a data store by name.

Parameters:
  • workspace_name – the name of workspace in which the data store is

  • store_name – the name of data store which you would like to delete

geoserver_pyadm.datastore.get_datastores(workspace)[source]

Get all datastores in a workspace

Parameters:

workspace – the name of the workspace in which you are interested

geoserver_pyadm.geoserver module

Geoserver Python API

geoserver_pyadm.imagemosaic module

geoserver_pyadm.imagemosaic.add_raster_to_image_mosaic_store(workspace_name, store_name, filepath)[source]
Add a new raster file into the image mosaic store. The raster file must be in the server.

Geoserver calls this process “harvesting”.

Parameters:
  • workspace_name – workspace name

  • store_name – image mosaic store name

  • filepath – the location of the new raster file in the server

geoserver_pyadm.imagemosaic.delete_raster_from_coverage(workspace_name, store_name, coverage_name, id)[source]

Delete a raster from a coverage within an image mosaic store

Parameters:
  • workspace_name – workspace name

  • store_name – image mosaic store name

  • coverage_name – the coverage name

  • id – the raster id which can be retrieved by calling get_rasters_in_coverage()

geoserver_pyadm.imagemosaic.enable_time_dimension(workspace_name, store_name, coverage_name)[source]

Enable time dimension for a coverage within a image mosaic store.

Parameters:
  • workspace_name – workspace name

  • store_name – coverage store name

  • coverage_name – the name of the new coverage

geoserver_pyadm.imagemosaic.get_rasters_in_coverage(workspace_name, store_name, coverage_name, return_details=False)[source]

Return all the granules in a coverage within an image mosaic store.

Parameters:
  • workspace_name – workspace name

  • store_name – image mosaic store name

  • coverage_name – the coverage name

  • return_details – if True, return all details about the granules if False, only return id and location.

geoserver_pyadm.imagemosaic.reindex_image_mosaic_store(workspace_name, store_name, path)[source]

Reindex an image mosaic store. Re-populate the store with the files in the given path.

Parameters:
  • workspace_name – workspace name

  • store_name – image mosaic store name

  • path – the path which contains the raster files

geoserver_pyadm.info module

geoserver_pyadm.info.get_global_settings()[source]

Get GeoServer’s global settings.

geoserver_pyadm.info.get_status()[source]

Get GeoServer’s status.

geoserver_pyadm.info.get_version()[source]

Get GeoServer’s version.

geoserver_pyadm.layer module

geoserver_pyadm.layer.delete_layer(layer_name, workspace=None)[source]

Delete a layer/layers by name

Parameters:
  • layer_name – the name of the layer which you would like to delete

  • workspace – (Default value = None) If the workspace name is not given, delete all layers with the given name.

geoserver_pyadm.layer.get_layer(layer_name: str, workspace=None)[source]

Get the definition of the layer

Parameters:
  • layer_name – str: the name of the layer to retrieve

  • workspace – (Default value = None) if the workspace name is not given, return the first layer which matches the given layer name. This is odd!

geoserver_pyadm.layer.get_layer_styles(full_layer_name: str)[source]

Get the styles associated with a layer

Parameters:

full_layer_name – str: the layer name including the workspace_name, such as workspace_name:layer_name

geoserver_pyadm.layer.get_layers(workspace=None)[source]
Get all the layers in geoserver if workspace name is not given.

Return all the layers in a workspace if workspace name is given.

Parameters:

workspace – (Default value = None) If workspace name is not given, the function will return all the layers in the geoserver.

geoserver_pyadm.layer.publish_geopackage_layer(workspace_name, store_name, layer_name, geom_type='polygon')[source]

Publish a geopackage layer in the data store

Parameters:
  • workspace_name – the name of the workspace in which the data store is

  • store_name – the name of the data store in which the layer you would like to publish is

  • layer_name – the name of geopackage layer which you would like to publish.

geoserver_pyadm.layer.publish_layer(workspace_name, store_name, layer_name)[source]

Publish a layer in the data store

Parameters:
  • workspace_name – the name of the workspace in which the data store is

  • store_name – the name of the data store in which the layer you would like to publish is

  • layer_name – the name of layer which you would like to publish. the name could be the shapefiles name without .shp

geoserver_pyadm.layer.publish_raster_layer(workspace_name, store_name, layer_name)[source]
Publish a coverage/raster layer from a coverage store.

It seems ,for some reason, that only one raster is allowed per coverage store.

Parameters:
  • workspace_name – the name of the workspace

  • store_name – the name of the coverage store in which the raster layer reside

  • layer_name – the name of the raster layer

geoserver_pyadm.style module

geoserver_pyadm.style.add_additional_style(full_layer_name: str, full_style_name: str)[source]

Add an additional style to a layer.

Parameters:
  • full_layer_name – str: the layer name including the workspace_name, such as workspace_name:layer_name

  • full_style_name – str: the style name including the workspace_name, such as workspace_name:style_name

geoserver_pyadm.style.add_style(style_name, workspace=None)[source]

Add an empty style globally or into a workspace.

Parameters:
  • style_name – the name of the style which you would like to create

  • workspace – (Default value = None) the name of the workspace. If the workspace name is not given, the new style will be a global one.

geoserver_pyadm.style.delete_style(style_name, workspace=None)[source]

Delete a style by name

Parameters:
  • style_name – the name of the style which you would like to delete

  • workspace – (Default value = None) the name of the workspace. If the workspace name is not given, the style is a global one.

geoserver_pyadm.style.get_styles(workspace=None)[source]

Get all global styles or all styles in a workspace

Parameters:

workspace – (Default value = None) If the workspace name is not given, all global styles will be returned.

geoserver_pyadm.style.modify_style(style_name, style_data, workspace=None)[source]

Change an existing style.

Parameters:
  • style_name – the name of the style

  • style_data – the new data for the style

  • workspace – (Default value = None) the name of the workspace. If the workspace name is not given, the style is a global one.

geoserver_pyadm.style.set_default_style(full_layer_name: str, full_style_name: str)[source]

set the default style for a layer

Parameters:
  • full_layer_name – str: the layer name including the workspace_name, such as workspace_name:layer_name

  • full_style_name – str: the style name including the workspace_name, such as workspace_name:style_name

geoserver_pyadm.upload module

geoserver_pyadm.upload.upload_geopackage(workspace_name, store_name, file_path, configure='none')[source]

Upload a local geopackage file.

warning: when use configure=”all”, all the shapefiles in the datastore will be published(not only the one you just uploaded)

Parameters:
  • workspace_name – the name of destine workspace in which you would like to upload the shapefile

  • store_name – the name of datastore in which you would like to upload the shapefile

  • file_path – the local path to your geopackge file

  • configure – this parameter takes three possible values first—(Default) Only setup the first feature type available in the data store. none—Do not configure any feature types. all—Configure all feature types.

geoserver_pyadm.upload.upload_geopackage_zip(workspace_name, store_name, file_path, configure='none')[source]
Upload a local .zip file which contains geopackage file.

warning: when use configure=”all”, all the shapefiles in the datastore will be published(not only the one you just uploaded)

Parameters:
  • workspace_name – the name of destine workspace in which you would like to upload the shapefile

  • store_name – the name of datastore in which you would like to upload the shapefile

  • file_path – the local file path to your geopackage(.zip)

  • configure – this parameter takes three possible values “first” —- (Default) Only setup the first feature type available in the data store. “none” —- Do not configure any feature types. “all” —- Configure all feature types.

geoserver_pyadm.upload.upload_image_mosaic(workspace_name, store_name, file_path, configure='none')[source]

Upload a zip file which contains image mosaic configuration files, such as indexer.xml, datastore.properties,etc The zip file may also contains the .nc files. See test/rasters/paleodem.zip for example. A new image mosaic store will be created if everything goes well.

Parameters:
  • workspace_name – workspace name

  • store_name – coverage store name

  • file_path – the location of the local .zip file

  • configure – this parameter takes three possible values “first” —- (Default) Only setup the first feature type available in the data store. “none” —- Do not configure any feature types. “all” —- Configure all feature types.

geoserver_pyadm.upload.upload_raster(workspace_name, store_name, file_path, coverage_name=None, file_fmt='geotiff', configure='all')[source]
Upload a local raster into geoserver.

Only one raster is allowed per coverage store unless using raster mosaic.

Parameters:
  • workspace_name – the name of workspace

  • store_name – the name of data store

  • file_path – the local file path to the raster(.zip)

  • coverage_name – The coverageName parameter specifies the name of the coverage within the coverage store. This parameter is only relevant if the configure parameter is not equal to “none”. If not specified the resulting coverage will receive the same name as its containing coverage store.

  • file_fmt – “geotiff” – GeoTIFF “worldimage” – Georeferenced image (JPEG, PNG, TIFF) “imagemosaic” – Image mosaic

  • configure – this parameter takes three possible values “first” —- (Default) Only setup the first feature type available in the data store. “none” —- Do not configure any feature types. “all” —- Configure all feature types.

geoserver_pyadm.upload.upload_raster_folder(workspace_name, folder_path, file_fmt='geotiff')[source]
Upload all the rasters within a local folder.

The rasters can be .zip, .tiff, .tif, .png, .jpg, .jpeg files. Make sure you have georeferenced your rasters. The store name and layer name will be deduced from file name.

Parameters:
  • workspace_name – the name of destine workspace in which you would like to upload the rasters

  • folder_path – the local path to your rasters

  • file_fmt – “geotiff” – GeoTIFF “worldimage” – Georeferenced image (JPEG, PNG, TIFF) “imagemosaic” – Image mosaic

geoserver_pyadm.upload.upload_shapefile(workspace_name, store_name, file_path, configure='none')[source]
Upload a local shapefile. A shapefile may contain several files.

You need to specify the path of the .shp file.

warning: when use configure=”all”, all the shapefiles in the datastore will be published(not only the one you just uploaded)

Parameters:
  • workspace_name – the name of destine workspace in which you would like to upload the shapefile

  • store_name – the name of datastore in which you would like to upload the shapefile

  • file_path – the local path to your shapefile, such as xxxxxx.shp

  • configure – this parameter takes three possible values first—(Default) Only setup the first feature type available in the data store. none—Do not configure any feature types. all—Configure all feature types.

geoserver_pyadm.upload.upload_shapefile_folder(workspace_name, store_name, folder_path, configure='none')[source]
Upload all the shapefiles within a local folder. The shapefiles can be .zip files or separate files.

Make sure your .zip is valid. If there is a folder in your .zip file, the upload will fail. For example, if, inside you .zip file, your files looks like shapefile/xxxxxxx.shp, the .zip file cannot be uploaded. Inside your .zip file, it must looks like this xxxxxxxx.shp, xxxxxxxx.dbf, etc.

warning: when use configure=”all”, all the shapefiles in the datastore will be published(not only the one you just uploaded)

Parameters:
  • workspace_name – the name of destine workspace in which you would like to upload the shapefiles

  • store_name – the name of datastore in which you would like to upload the shapefiles

  • folder_path – the local path to your shapefiles

  • configure – this parameter takes three possible values first—(Default) Only setup the first feature type available in the data store. none—Do not configure any feature types. all—Configure all feature types.

geoserver_pyadm.upload.upload_shapefile_zip(workspace_name, store_name, file_path, configure='none')[source]
Upload a local .zip file which contains shapefile.

warning: when use configure=”all”, all the shapefiles in the datastore will be published(not only the one you just uploaded)

Parameters:
  • workspace_name – the name of destine workspace in which you would like to upload the shapefile

  • store_name – the name of datastore in which you would like to upload the shapefile

  • file_path – the local file path to your shapefile(.zip)

  • configure – this parameter takes three possible values “first” —- (Default) Only setup the first feature type available in the data store. “none” —- Do not configure any feature types. “all” —- Configure all feature types.

geoserver_pyadm.upload.upload_style(style_name, file_path, workspace=None)[source]
Upload a local sld file as a new style.

The sytle must not exist yet.

Parameters:
  • style_name – the name of the new style

  • file_path – the local path to the .sld file

  • workspace – (Default value = None) the name of the workspace. If the workspace name is not given, the new style will be a global one.

geoserver_pyadm.upload.upload_zip(workspace_name, store_name, file_path, format='shp', configure='none')[source]
Upload a local .zip file which contains shapefile.

warning: when use configure=”all”, all the shapefiles in the datastore will be published(not only the one you just uploaded)

Parameters:
  • workspace_name – the name of destine workspace in which you would like to upload the shapefile

  • store_name – the name of datastore in which you would like to upload the shapefile

  • file_path – the local file path to your shapefile(.zip)

  • format – support ‘shp’ and ‘gpkg’

  • configure – this parameter takes three possible values “first” —- (Default) Only setup the first feature type available in the data store. “none” —- Do not configure any feature types. “all” —- Configure all feature types.

geoserver_pyadm.workspace module

geoserver_pyadm.workspace.create_workspace(workspace_name, quiet_on_exist=True)[source]

create a workspace by name

Parameters:
  • workspace_name – the name of the workspace which you would like to create

  • quiet_on_exist – flag to indicate if raise exception when the workspace already exists.

geoserver_pyadm.workspace.delete_workspace(workspace_name, quiet_on_not_exist=True)[source]

delete a workspace by name

Parameters:
  • workspace_name – the name of the workspace which you would like to delete

  • quiet_on_not_exist – flag to indicate if raise exception when trying to delete an non-exist workspace

geoserver_pyadm.workspace.get_all_workspaces()[source]

Get the names of all workspaces

geoserver_pyadm.workspace.get_workspace(name)[source]

Get the definition of a workspace

Parameters:

name – the name of the workspace in which you are interested

Module contents