GeoServer – How to Create Layer Group in GeoServer with GSConfig

geoservergeoserver-rest-apipython

How can I create layer groups using python gsconfig ?

Best Answer

1. Connect to Catalog

 cat = Catalog("http://localhost:8080/geoserver/rest","admin", "geoserver")

2. Get some layers and styles

lyrs = [list of layers]

stls = [list of styles]

3. Create the group layer

lg = cat.create_layergroup(groupname)

4. Add the layers and styles to the group layer

lg.layers = lyrs

lg.styles = stls

5. Save the group layer

cat.save(lg)

To specify a workspace I think you need to create a resource and then use that to create the group layer in step 3.

myResource = cat.get_resources(workspace='workspaceName') lg = 

cat.create_layergroup(myResource,groupname
Related Question