2

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

0

2 Answers 2

6

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

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

1
  • 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. Commented Jan 26, 2014 at 20:19

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.