[GIS] Python Geoserver gsconfig create resource from Postgis store table

geoserverpostgis-2.0python

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).

Best Answer

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')

cat.save(ds)

4. Add Layer

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

cat.save(ft)
Related Question