Is it possible to upload layers to a layer group at once to geoserver? I have about 1000 data and I want to upload them to one layer group. However, as I understand, I have to select them one by one for uploading. Is there any button such as select all?

2 Answers 2


The GeoServer Importer Extension is what you are looking for ! :)

GeoServer Importer Extension

There are two primary advantages to using the Importer over the standard GeoServer data-loading workflow:

1. Supports batch operations (loading and publishing multiple spatial files or database tables in one operation)

2. Creates unique styles for each layer, rather than linking to the same (existing) styles.

EDIT: A solution using python has been provided here

  • Importer extension is used to import multiple files to geoserver. This is not my case. I have already 1000 layers in geoserver that are uploaded before. Now, I want to create a layer group from them and I am asking that is there a way to create a layer group by selecting all the layers at once?
    – Irem
    Dec 27, 2022 at 11:29
  • 1
    Sorry I read your question too quickly ! I edited my answer
    – wanderzen
    Dec 27, 2022 at 11:46

You can use a combination of geoserver-rest (https://geoserver-rest.readthedocs.io/en/latest/), and geoservers own REST interface to achieve this.

Since i had no luck using create_layergroup() from geoserver-rest, i made this rather hacky solution:

import requests

from geo.Geoserver import Geoserver
geo = Geoserver('http://ip:8080/geoserver_USA', username='xxxx', password='xxxx')

noaa_workspaces = ["NOAA_enc_overview","NOAA_enc_harbour","NOAA_enc_approach","NOAA_coastal","NOAA_general"]

for service in noaa_workspaces:
    #file = open(service + "_layers", "w+")
    layers = geo.get_layers(workspace=service)
    layer_list = []
    for x in range(len(layers["layers"]["layer"])):
    for layer in layer_list:
        #print("<layer>%s:%s</layer>" % (service,layer))
        xml += "<layer>%s:%s</layer>" % (service,layer)
        #open(service, "a")
        #file.write("<layer>%s:%s</layer>" % (service,layer))   
    xml_final =  "<layerGroup><name>%s</name><layers>%s</layers></layerGroup>" % (service,xml)

    headers =  {'Content-type' : 'text/xml'}
   # requests.post('http://httpbin.org/post', data=xml, headers=headers).text

    print("send request for : ", service)
    print(requests.post('http://user:pass@ip:8080/geoserver_USA/rest/layergroups',data=xml_final, headers=headers).text)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.