Python API Reference
Disclamer: The documentation in the code was initially written by people, but was then passed through an AI large language model (specifically ChatGPT-4o) to fill in gaps and correct minor mistakes. The results were also validated by a person, but it is possible that an AI “hallucination” has occurred that was not caught and resulted in an incorrect documentation. Please report an issue you find one.
The Geoserver class
- class geo.Geoserver.DataProvider(data)
Bases:
objectData provider for reading data.
Parameters
- datastr
The data to be read.
- class geo.Geoserver.FileReader(fp)
Bases:
objectFile reader for reading files.
Parameters
- fpfile object
The file object to read from.
- class geo.Geoserver.Geoserver(service_url: str = 'http://localhost:8080/geoserver', username: str = 'admin', password: str = 'geoserver', request_options: Dict[str, Any] = None)
Bases:
objectGeoserver class to interact with GeoServer REST API.
Attributes
- service_urlstr
The URL for the GeoServer instance.
- usernamestr
Login name for session.
- password: str
Password for session.
- request_optionsdict
Additional parameters to be sent with each request.
- add_layer_to_layergroup(layer_name: str, layer_workspace: str, layergroup_name: str, layergroup_workspace: str = None) None
Add the specified layer to an existing layer group and raise an exception if either the layer or layergroup doesn’t exist, or the geoserver is unavailable.
Parameters
- layer_name: str
The name of the layer.
- layer_workspace: str
The workspace the layer is located in.
- layergroup_workspace: str, optional
The workspace the layergroup is located in.
- layergroup_name: str
The name of the layer group.
- layergroup_workspace: str, optional
The workspace the layergroup is located in.
Returns
None
Raises
- GeoserverException
If there is an issue adding the layer to the layergroup.
- create_catagorized_featurestyle(style_name: str, column_name: str, column_distinct_values, workspace: str = None, color_ramp: str = 'tab20', geom_type: str = 'polygon')
Dynamically create categorized style for postgis geometry,
Parameters
- style_namestr
The name of the style.
- column_namestr
The column name to base the style on.
- column_distinct_values
The distinct values in the column.
- workspacestr
The workspace to create the style in.
- color_rampstr
The color ramp to use.
- geom_typestr
The geometry type (point, line, polygon).
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue creating the style.
Notes
The data type must be point, line or polygon Inputs: column_name (based on which column style should be generated), workspace, color_or_ramp (color should be provided in hex code or the color ramp name, geom_type(point, line, polygon), outline_color(hex_color))
- create_classified_featurestyle(style_name: str, column_name: str, column_distinct_values, workspace: str | None = None, color_ramp: str = 'tab20', geom_type: str = 'polygon')
Dynamically creates the classified style for postgis geometries.
Parameters
- style_namestr
The name of the style.
- column_namestr
The column name to base the style on.
- column_distinct_values
The distinct values in the column.
- workspacestr, optional
The workspace to create the style in.
- color_rampstr
The color ramp to use.
- geom_typestr
The geometry type (point, line, polygon).
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue creating the style.
Notes
The data type must be point, line or polygon Inputs: column_name (based on which column style should be generated), workspace, color_or_ramp (color should be provided in hex code or the color ramp name, geom_type(point, line, polygon), outline_color(hex_color))
- create_coveragestore(path, workspace: str | None = None, layer_name: str | None = None, file_type: str = 'GeoTIFF', content_type: str = 'image/tiff')
Creates the coverage store; Data will be uploaded to the server.
Parameters
- pathstr
The path to the file.
- workspacestr, optional
The name of the workspace.
- layer_namestr, optional
The name of the coverage store. If not provided, parsed from the file name.
- file_typestr
The type of the file.
- content_typestr
The content type of the file.
Returns
- dict
The response from the server.
Notes
the path to the file and file_type indicating it is a geotiff, arcgrid or other raster type
- create_coveragestyle(raster_path: str, style_name: str | None = None, workspace: str = None, color_ramp: str = 'RdYlGn_r', cmap_type: str = 'ramp', number_of_classes: int = 5, opacity: float = 1)
Dynamically create style for raster.
Parameters
- raster_pathstr
Path to the raster file.
- style_namestr, optional
The name of the style. If None, the name is parsed from the raster file name.
- workspacestr
The workspace to create the style in.
- color_rampstr
The color ramp to use.
- cmap_typestr
The type of color map.
- number_of_classesint
The number of classes.
- opacityfloat
The opacity of the style.
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue creating the style.
Notes
The name of the style file will be, rasterName:workspace This function will dynamically create the style file for raster. Inputs: name of file, workspace, cmap_type (two options: values, range), ncolors: determines the number of class, min for minimum value of the raster, max for the max value of raster
- create_datastore(name: str, path: str, workspace: str | None = None, overwrite: bool = False)
Create a datastore within the GeoServer.
Parameters
- namestr
Name of datastore to be created. After creating the datastore, you need to publish it by using publish_featurestore function.
- pathstr
Path to shapefile (.shp) file, GeoPackage (.gpkg) file, WFS url (e.g. http://localhost:8080/geoserver/wfs?request=GetCapabilities) or directory containing shapefiles.
- workspacestr, optional
The workspace to create the datastore in. Default is “default”.
- overwritebool
Whether to overwrite the existing datastore.
Returns
- str
A success message indicating that the datastore was created/updated.
Raises
- GeoserverException
If there is an issue creating/updating the datastore.
Notes
If you have PostGIS datastore, please use create_featurestore function
- create_featurestore(store_name: str, workspace: str | None = None, db: str = 'postgres', host: str = 'localhost', port: int = 5432, schema: str = 'public', pg_user: str = 'postgres', pg_password: str = 'admin', overwrite: bool = False, expose_primary_keys: str = 'false', description: str | None = None, evictor_run_periodicity: int | None = 300, max_open_prepared_statements: int | None = 50, encode_functions: str | None = 'false', primary_key_metadata_table: str | None = None, batch_insert_size: int | None = 1, preparedstatements: str | None = 'false', loose_bbox: str | None = 'true', estimated_extends: str | None = 'true', fetch_size: int | None = 1000, validate_connections: str | None = 'true', support_on_the_fly_geometry_simplification: str | None = 'true', connection_timeout: int | None = 20, create_database: str | None = 'false', min_connections: int | None = 1, max_connections: int | None = 10, evictor_tests_per_run: int | None = 3, test_while_idle: str | None = 'true', max_connection_idle_time: int | None = 300)
Create PostGIS store for connecting postgres with geoserver.
Parameters
- store_namestr
The name of the feature store.
- workspacestr, optional
The workspace to create the feature store in.
- dbstr
The database type. Default is “postgres”.
- hoststr
The database host. Default is “localhost”.
- portint
The database port. Default is 5432.
- schemastr
The database schema. Default is “public”.
- pg_userstr
The database user. Default is “postgres”.
- pg_passwordstr
The database password. Default is “admin”.
- overwritebool
Whether to overwrite the existing feature store.
- expose_primary_keysstr
Whether to expose primary keys. Default is “false”.
- descriptionstr, optional
The description of the feature store.
- evictor_run_periodicityint, optional
The periodicity of the evictor run.
- max_open_prepared_statementsint, optional
The maximum number of open prepared statements.
- encode_functionsstr, optional
Whether to encode functions. Default is “false”.
- primary_key_metadata_tablestr, optional
The primary key metadata table.
- batch_insert_sizeint, optional
The batch insert size. Default is 1.
- preparedstatementsstr, optional
Whether to use prepared statements. Default is “false”.
- loose_bboxstr, optional
Whether to use loose bounding boxes. Default is “true”.
- estimated_extendsstr, optional
Whether to use estimated extends. Default is “true”.
- fetch_sizeint, optional
The fetch size. Default is 1000.
- validate_connectionsstr, optional
Whether to validate connections. Default is “true”.
- support_on_the_fly_geometry_simplificationstr, optional
Whether to support on-the-fly geometry simplification. Default is “true”.
- connection_timeoutint, optional
The connection timeout. Default is 20.
- create_databasestr, optional
Whether to create the database. Default is “false”.
- min_connectionsint, optional
The minimum number of connections. Default is 1.
- max_connectionsint, optional
The maximum number of connections. Default is 10.
- evictor_tests_per_runint, optional
The number of evictor tests per run.
- test_while_idlestr, optional
Whether to test while idle. Default is “true”.
- max_connection_idle_timeint, optional
The maximum connection idle time. Default is 300.
Returns
- str
A success message indicating that the feature store was created/updated.
Raises
- GeoserverException
If there is an issue creating/updating the feature store.
Notes
After creating feature store, you need to publish it. See the layer publish guidline here: https://geoserver-rest.readthedocs.io/en/latest/how_to_use.html#creating-and-publishing-featurestores-and-featurestore-layers
- create_gpkg_datastore(path: str, store_name: str | None = None, workspace: str | None = None, file_extension: str = 'gpkg')
Create datastore for a geopackage.
Parameters
- pathstr
Path to the geopackage file.
- store_namestr, optional
Name of store to be created. If None, parses from the filename.
- workspace: str, optional
Name of workspace to be used. Default: “default”.
- file_extensionstr
The file extension of the geopackage. Default is “gpkg”.
Returns
- str
A success message indicating that the geopackage datastore was created.
Raises
- GeoserverException
If there is an issue creating the geopackage datastore.
Notes
The layer name will be assigned according to the layer name in the geopackage. If the layer already exist it will be updated.
- create_layergroup(name: str = 'geoserver-rest-layergroup', mode: str = 'single', title: str = 'geoserver-rest layer group', abstract_text: str = 'A new layergroup created with geoserver-rest python package', layers: List[str] = [], workspace: str | None = None, formats: str = 'html', metadata: List[dict] = [], keywords: List[str] = []) str
Creates the Layergroup.
Parameters
- namestr
The name of the layer group.
- modestr
The mode of the layer group.
- titlestr
The title of the layer group.
- abstract_textstr
The abstract text of the layer group.
- layerslist
The list of layers in the layer group.
- workspacestr, optional
The name of the workspace.
- formatsstr, optional
The format of the layer group.
- metadatalist, optional
The metadata of the layer group.
- keywordslist, optional
The keywords of the layer group.
Returns
- str
The URL of the created layer group.
Notes
title is a human readable text for the layergroup abstract_text is a long text, like a brief info about the layergroup workspace is Optional(Global Layergroups don’t need workspace).A layergroup can exist without a workspace.
- create_outline_featurestyle(style_name: str, color: str = '#3579b1', width: str = '2', geom_type: str = 'polygon', workspace: str | None = None)
Dynamically creates the outline style for postgis geometry
Parameters
- style_namestr
The name of the style.
- colorstr
The color of the outline.
- geom_typestr
The geometry type (point, line, polygon).
- workspacestr, optional
The workspace to create the style in.
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue creating the style.
Notes
The geometry type must be point, line or polygon Inputs: style_name (name of the style file in geoserver), workspace, color (style color)
- create_shp_datastore(path: str, store_name: str | None = None, workspace: str | None = None, file_extension: str = 'shp')
Create datastore for a shapefile.
Parameters
- pathstr
Path to the zipped shapefile (.shp).
- store_namestr, optional
Name of store to be created. If None, parses from the filename stem.
- workspace: str, optional
Name of workspace to be used. Default: “default”.
- file_extensionstr
The file extension of the shapefile. Default is “shp”.
Returns
- str
A success message indicating that the shapefile datastore was created.
Raises
- GeoserverException
If there is an issue creating the shapefile datastore.
Notes
The layer name will be assigned according to the shp name
- create_user(username: str, password: str, enabled: bool = True, service=None) str
Add a new user to the provided user/group service.
Parameters
- usernamestr
The username of the new user.
- password: str
The password of the new user.
- enabled: bool
Whether the new user is enabled.
- servicestr, optional
The user/group service to add the user to.
Returns
- str
A success message indicating that the user was created.
Raises
- GeoserverException
If there is an issue creating the user.
- create_usergroup(group: str, service=None) str
Add a new usergroup to the provided user/group service.
Parameters
- groupstr
The name of the user group.
- servicestr, optional
The user/group service to add the user group to.
Returns
- str
A success message indicating that the user group was created.
Raises
- GeoserverException
If there is an issue creating the user group.
- create_workspace(workspace: str)
Create a new workspace in GeoServer. The GeoServer workspace URL will be the same as the name of the workspace.
Parameters
- workspacestr
The name of the workspace to create.
Returns
- str
The status code and message of the operation.
- delete_coveragestore(coveragestore_name: str, workspace: str | None = None) str
Delete a coveragestore from the geoserver.
Parameters
- coveragestore_namestr
The name of the coveragestore.
- workspacestr, optional
The workspace of the coveragestore.
Returns
- str
A success message indicating that the coveragestore was deleted.
Raises
- GeoserverException
If there is an issue deleting the coveragestore.
- delete_featurestore(featurestore_name: str, workspace: str | None = None) str
Delete a featurestore from the geoserver.
Parameters
- featurestore_namestr
The name of the featurestore.
- workspacestr, optional
The workspace of the featurestore.
Returns
- str
A success message indicating that the featurestore was deleted.
Raises
- GeoserverException
If there is an issue deleting the featurestore.
- delete_layer(layer_name: str, workspace: str | None = None)
Delete a layer.
Parameters
- layer_namestr
The name of the layer to delete.
- workspacestr, optional
The name of the workspace.
Returns
- str
The status code and message of the operation.
- delete_layergroup(layergroup_name: str, workspace: str | None = None) str
Delete a layer group from the geoserver and raise an exception in case the layer group does not exist, or the geoserver is unavailable.
Parameters
- layergroup_name: str
The name of the layer group to be deleted.
- workspace: str, optional
The workspace the layergroup is located in.
Returns
- str
A success message indicating that the layer group was deleted.
Raises
- GeoserverException
If there is an issue deleting the layergroup.
- delete_style(style_name: str, workspace: str | None = None)
Delete a style from the geoserver.
Parameters
- style_namestr
The name of the style.
- workspacestr, optional
The workspace the style is located in.
Returns
- str
A success message indicating that the style was deleted.
Raises
- GeoserverException
If there is an issue deleting the style.
- delete_user(username: str, service=None) str
Deletes user from the provided user/group service.
Parameters
- usernamestr
The username of the user to delete.
- servicestr, optional
The user/group service to delete the user from.
Returns
- str
A success message indicating that the user was deleted.
Raises
- GeoserverException
If there is an issue deleting the user.
- delete_usergroup(group: str, service=None) str
Deletes given usergroup from provided user/group service.
Parameters
- groupstr
The name of the user group to delete.
- servicestr, optional
The user/group service to delete the user group from.
Returns
- str
A success message indicating that the user group was deleted.
Raises
- GeoserverException
If there is an issue deleting the user group.
- delete_workspace(workspace: str)
Delete a workspace.
Parameters
- workspacestr
The name of the workspace to delete.
Returns
- str
The status code and message of the operation.
- edit_featuretype(store_name: str, workspace: str | None, pg_table: str, name: str, title: str, abstract: str | None = None, keywords: List[str] | None = None, recalculate: str | None = None) int
Edit a featuretype in the geoserver.
Parameters
- recalculatestr, optional
Recalculate param. Can be: empty string, nativebbox and nativebbox,latlonbbox.
- store_namestr
The name of the feature store.
- workspacestr, optional
The workspace of the feature store.
- pg_tablestr
The name of the PostgreSQL table.
- namestr
The name of the feature type.
- titlestr
The title of the feature type.
- abstractstr, optional
The abstract of the feature type.
- keywordslist of str, optional
List of keywords associated with the feature type.
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue editing the feature type.
- get_all_usergroups(service=None) dict
Queries all the groups in the given user/group service.
Parameters
- servicestr, optional
The user/group service to query.
Returns
- dict
A dictionary containing all user groups.
Raises
- GeoserverException
If there is an issue getting the user groups.
- get_all_users(service=None) dict
Query all users in the provided user/group service, else default user/group service is queried.
Parameters
- service: str, optional
The user/group service to query.
Returns
- dict
A dictionary containing all users.
Raises
- GeoserverException
If there is an issue getting the users.
- get_coveragestore(coveragestore_name: str, workspace: str | None = None)
Returns the store name if it exists.
Parameters
- coveragestore_namestr
The name of the coverage store.
- workspacestr, optional
The name of the workspace.
Returns
- dict
The coverage store information.
- get_coveragestores(workspace: str = None)
Returns all the coverage stores inside a specific workspace.
Parameters
- workspacestr, optional
The name of the workspace.
Returns
- dict
The list of coverage stores.
- get_datastore(store_name: str, workspace: str | None = None)
Return the data store in a given workspace. If workspace is not provided, it will take the default workspace.
Parameters
- store_namestr
The name of the data store.
- workspacestr, optional
The name of the workspace.
Returns
- dict
The data store information.
- get_datastores(workspace: str | None = None)
List all data stores in a workspace. If workspace is not provided, it will list all the datastores inside the default workspace.
Parameters
- workspacestr, optional
The name of the workspace.
Returns
- dict
The list of data stores.
- get_feature_attribute(feature_type_name: str, workspace: str, store_name: str) List[str]
Get feature attributes from the geoserver.
Parameters
- feature_type_namestr
The name of the feature type.
- workspacestr
The workspace of the feature store.
- store_namestr
The name of the feature store.
Returns
- list of str
A list of feature attributes.
Raises
- GeoserverException
If there is an issue getting the feature attributes.
- get_featurestore(store_name: str, workspace: str) dict
Get a featurestore from the geoserver.
Parameters
- store_namestr
The name of the feature store.
- workspacestr
The workspace of the feature store.
Returns
- dict
A dictionary representation of the feature store.
Raises
- GeoserverException
If there is an issue getting the feature store.
- get_featuretypes(workspace: str = None, store_name: str = None) List[str]
Get feature types from the geoserver.
Parameters
- workspacestr
The workspace to get the feature types from.
- store_namestr
The name of the feature store.
Returns
- list of str
A list of feature types.
Raises
- GeoserverException
If there is an issue getting the feature types.
- get_layer(layer_name: str, workspace: str | None = None)
Returns the layer by layer name.
Parameters
- layer_namestr
The name of the layer.
- workspacestr, optional
The name of the workspace.
Returns
- dict
The layer information.
- get_layergroup(layer_name: str, workspace: str | None = None)
Returns the layer group by layer group name.
Parameters
- layer_namestr
The name of the layer group.
- workspacestr, optional
The name of the workspace.
Returns
- dict
The layer group information.
- get_layergroups(workspace: str | None = None)
Returns all the layer groups from GeoServer. If workspace is None, it will list all the layer groups from GeoServer.
Parameters
- workspacestr, optional
The name of the workspace.
Returns
- dict
The list of layer groups.
Notes
If workspace is None, it will list all the layer groups from geoserver.
- get_layers(workspace: str | None = None)
Get all the layers from GeoServer. If workspace is None, it will list all the layers from GeoServer.
Parameters
- workspacestr, optional
The name of the workspace.
Returns
- dict
The list of layers.
- get_manifest()
Returns the manifest of the GeoServer. The manifest is a JSON of all the loaded JARs on the GeoServer server.
Returns
- dict
The manifest of the GeoServer.
- get_status()
Returns the status of the GeoServer. It shows the status details of all installed and configured modules.
Returns
- dict
The status of the GeoServer.
- get_style(style_name, workspace: str | None = None)
Returns the style by style name.
Parameters
- style_name: str
The name of the style.
- workspace: str, optional
The workspace the style is located in.
Returns
- dict
A dictionary representation of the style.
Raises
- GeoserverException
If there is an issue retrieving the style.
- get_styles(workspace: str | None = None)
Returns all loaded styles from geoserver.
Parameters
- workspace: str, optional
The workspace to filter the styles by.
Returns
- dict
A dictionary containing all the styles.
Raises
- GeoserverException
If there is an issue retrieving the styles.
- get_system_status()
Returns the system status of the GeoServer. It returns a list of system-level information. Major operating systems (Linux, Windows, and MacOS) are supported out of the box.
Returns
- dict
The system status of the GeoServer.
- get_version()
Returns the version of the GeoServer as JSON. It contains only the details of the high level components: GeoServer, GeoTools, and GeoWebCache.
Returns
- dict
The version information of the GeoServer.
- get_workspace(workspace)
Get the name of a workspace if it exists.
Parameters
- workspacestr
The name of the workspace.
Returns
- dict
The workspace information.
- modify_user(username: str, new_name=None, new_password=None, enable=None, service=None) str
Modifies a user in the provided user/group service.
Parameters
- usernamestr
The username of the user to modify.
- new_namestr, optional
The new username.
- new_passwordstr, optional
The new password.
- enablebool, optional
Whether the user is enabled.
- servicestr, optional
The user/group service to modify the user in.
Returns
- str
A success message indicating that the user was modified.
Raises
- GeoserverException
If there is an issue modifying the user.
- publish_featurestore(store_name: str, pg_table: str, workspace: str | None = None, title: str | None = None, advertised: bool | None = True, abstract: str | None = None, keywords: List[str] | None = None, cqlfilter: str | None = None) int
Publish a featurestore to geoserver.
Parameters
- store_namestr
The name of the featurestore.
- pg_tablestr
The name of the PostgreSQL table.
- workspacestr, optional
The workspace to publish the featurestore in. Default is “default”.
- titlestr, optional
The title of the featurestore. If None, the table name is used.
- advertisedbool, optional
Whether to advertise the featurestore. Default is True.
- abstractstr, optional
The abstract of the featurestore.
- keywordslist of str, optional
List of keywords associated with the featurestore.
- cqlfilterstr, optional
The CQL filter for the featurestore.
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue publishing the featurestore.
Notes
Only user for postgis vector data input parameters: specify the name of the table in the postgis database to be published, specify the store,workspace name, and the Geoserver user name, password and URL
- publish_featurestore_sqlview(name: str, store_name: str, sql: str, parameters: Iterable[Dict] | None = None, key_column: str | None = None, geom_name: str = 'geom', geom_type: str = 'Geometry', srid: int | None = 4326, workspace: str | None = None) int
Publishes an SQL query as a layer, optionally with parameters.
Parameters
- namestr
The name of the SQL view.
- store_namestr
The name of the feature store.
- sqlstr
The SQL query.
- parametersiterable of dict, optional
List of parameters for the SQL query.
- key_columnstr, optional
The key column.
- geom_namestr, optional
The name of the geometry column.
- geom_typestr, optional
The type of the geometry column.
- sridint, optional
The spatial reference ID. Default is 4326.
- workspacestr, optional
The workspace to publish the SQL view in. Default is “default”.
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue publishing the SQL view.
Notes
With regards to SQL view parameters, it is advised to read the relevant section from the geoserver docs: https://docs.geoserver.org/main/en/user/data/database/sqlview.html#parameterizing-sql-views
An integer-based parameter must have a default value
You should be VERY careful with the regexp_validator, as it can open you to SQL injection attacks. If you do not supply one for a parameter, it will use the geoserver default ^[wds]+$.
The parameters iterable must contain dictionaries with this structure:
“name”: “<name of parameter (required)>” “regexpValidator”: “<string containing regex validator> (optional)” “defaultValue” : “<default value of parameter if not specified (required only for non-string parameters)>”
}
- publish_style(layer_name: str, style_name: str, workspace: str)
Publish a raster file to geoserver.
Parameters
- layer_namestr
The name of the layer.
- style_namestr
The name of the style.
- workspacestr
The workspace the layer is located in.
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue publishing the style.
Notes
The coverage store will be created automatically as the same name as the raster layer name. input parameters: the parameters connecting geoserver (user,password, url and workspace name), the path to the file and file_type indicating it is a geotiff, arcgrid or other raster type.
- publish_time_dimension_to_coveragestore(store_name: str | None = None, workspace: str | None = None, presentation: str | None = 'LIST', units: str | None = 'ISO8601', default_value: str | None = 'MINIMUM', content_type: str = 'application/xml; charset=UTF-8')
Create time dimension in coverage store to publish time series in GeoServer.
Parameters
- store_namestr, optional
The name of the coverage store.
- workspacestr, optional
The name of the workspace.
- presentationstr, optional
The presentation style.
- unitsstr, optional
The units of the time dimension.
- default_valuestr, optional
The default value of the time dimension.
- content_typestr
The content type of the request.
Returns
- dict
The response from the server.
Notes
More about time support in geoserver WMS you can read here: https://docs.geoserver.org/master/en/user/services/wms/time.html
- reload()
Reloads the GeoServer catalog and configuration from disk.
This operation is used in cases where an external tool has modified the on-disk configuration. This operation will also force GeoServer to drop any internal caches and reconnect to all data stores.
Returns
- str
The status code of the reload operation.
- remove_layer_from_layergroup(layer_name: str, layer_workspace: str, layergroup_name: str, layergroup_workspace: str = None) None
Add remove the specified layer from an existing layer group and raise an exception if either the layer or layergroup doesn’t exist, or the geoserver is unavailable.
Parameters
- layer_name: str
The name of the layer.
- layer_workspace: str
The workspace the layer is located in.
- layergroup_workspace: str, optional
The workspace the layergroup is located in.
- layergroup_name: str
The name of the layer group.
- layergroup_workspace: str, optional
The workspace the layergroup is located in.
Returns
None
Raises
- GeoserverException
If there is an issue removing the layer from the layergroup.
- reset()
Resets all store, raster, and schema caches. This operation is used to force GeoServer to drop all caches and store connections and reconnect to each of them the next time they are needed by a request. This is useful in case the stores themselves cache some information about the data structures they manage that may have changed in the meantime.
Returns
- str
The status code of the reset operation.
- set_default_workspace(workspace: str)
Set the default workspace.
Parameters
- workspacestr
The name of the workspace to set as default.
Returns
- str
The status code of the operation.
- update_layergroup(layergroup_name, title: str | None = None, abstract_text: str | None = None, formats: str = 'html', metadata: List[dict] = [], keywords: List[str] = []) str
Updates a Layergroup.
Parameters
- layergroup_name: str
The name of the layergroup to update.
- titlestr, optional
The new title for the layergroup.
- abstract_textstr, optional
The new abstract text for the layergroup.
- formatsstr, optional
The format of the response. Default is “html”.
- metadatalist of dict, optional
List of metadata entries where each entry is a dictionary with “about” and “content_url” keys.
- keywordslist of str, optional
List of keywords associated with the layergroup.
Returns
- str
A success message indicating that the layergroup was updated.
Raises
- GeoserverException
If there is an issue updating the layergroup.
- update_service(service: str, **kwargs)
Update selected service’s options.
Parameters
- servicestr
Type of service (e.g., wms, wfs)
- kwargsdict
Options to be modified (e.g., maxRenderingTime=600)
Returns
- str
A success message indicating that the options were updated.
Raises
- GeoserverException
If there is an issue updating the service’s options.
- upload_style(path: str, name: str | None = None, workspace: str | None = None, sld_version: str = '1.0.0')
Uploads a style file to geoserver.
Parameters
- pathstr
Path to the style file or XML string.
- namestr, optional
The name of the style. If None, the name is parsed from the file name.
- workspacestr, optional
The workspace to upload the style to.
- sld_versionstr, optional
The version of the SLD. Default is “1.0.0”.
Returns
- int
The status code of the request.
Raises
- GeoserverException
If there is an issue uploading the style.
Notes
The name of the style file will be, sld_name:workspace This function will create the style file in a specified workspace. path can either be the path to the SLD file itself, or a string containing valid XML to be used for the style Inputs: path to the sld_file or the contents of an SLD file itself, workspace,
The Style functions
- geo.Style.catagorize_xml(column_name: str, values: List[float], color_ramp: str = None, geom_type: str = 'polygon')
- geo.Style.classified_xml(style_name: str, column_name: str, values: List[float], color_ramp: str = None, geom_type: str = 'polygon')
- geo.Style.coverage_style_colormapentry(color_ramp: List | Dict | Iterable, min_value: float, max_value: float, number_of_classes: int = None)
Parameters
color_ramp min_value max_value number_of_classes
Returns
Notes
This is the core function for controlling the layers styles The color_ramp can be list or dict or touple or str min, max will be dynamically calculated value from raster number_of_classes will be available in map legend
- geo.Style.coverage_style_xml(color_ramp, style_name, cmap_type, min_value, max_value, number_of_classes, opacity)
- geo.Style.outline_only_xml(color, width, geom_type='polygon')