I've working Workspace and PostGIS store in GeoServer. I would like to use python and gsconfig to create new resource/new layer from existing PostGIS table, with:

computing bbox,
adding abstract,
adding keywords,
setting style,
other attributes.

Is it doable with gsconfig? Could you provide any examples?
The same goes with removing resources (layers).

  • sorry i am posting this is an answer, but were you able to find a solution to it? I am looking for something same , where I want to create a GIS db store and upload tables containing spatial data – user28769 Apr 2 '14 at 18:04

Bit late to the party, but I'll answer anyway

1. Connect to GeoServer

cat = Catalog('http://localhost:8080/geoserver/rest')

2. Create a Workspace

ws = cat.create_workspace('newWorkspaceName','newWorkspaceUri')

3. Create PostGIS store

ds = cat.create_datastore(newDatastoreName,newWorkspaceName)

ds.connection_parameters.update(host='localhost', port='5432', database='postgis', user='postgres', passwd='password', dbtype='postgis', schema='postgis')


4. Add Layer

ft = cat.publish_featuretype('newLayerName', ds, 'EPSG:4326', srs='EPSG:4326')


We use it within the GeoNode project. Here is the code we use to create a layer: https://github.com/GeoNode/geonode/blob/master/geonode/layers/utils.py#L274

  • Ok, your code is fine, however, I do not find answer in it. As far as I understand, you always upload shapefile using _create_db_featurestore and You are doing: cat.add_data_to_store(ds, name, data, overwrite=overwrite, charset=charset) return ds, cat.get_resource(name, store=ds) and after add_data_to_store you have a 'resource'. In my case, I already have working store and data upload in different process. However, I do not know how to create resource/layer out of existing table in PostGIS. – user1632928 Jan 26 '14 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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