Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have py script which is creating shapefiles using shapefile.py. Once the shapefile is created I have to add them manually to the geoserver. Is there a way to add it dynamically to the geoserver? through postgis or something?

UPDATE

Ok so seems my project manager has changed his plan, he wants me to add the shapefiles to the PostGIS Database which will update the newly added shapefiles to the geoserver where there will be a connection to the PostGIS Database. Is it possible to update the newly added shapefiles to reflect in the Geoserver?

share|improve this question

3 Answers 3

You can use the REST API of GeoServer.

The REST extension provides a RESTful interface through which clients can configure a GeoServer instance through simple HTTP calls. With it clients can programatically configure the data served by GeoServer.

This example explains how to upload a shapefile in GeoServer using cURL.

share|improve this answer

with python there are some scripts about shp to geoserver... you can check out them for your needs. They will help you to make this work(from here):

Copied a shapefile (and associated files) to the data directory
Appended info block to catalog.xml
Created named FeatureType directory and associated info.xml

1.shp2geoserver.py

2.shapefilebatch-cleaned.py

i hope it helps you...

share|improve this answer
    
hi @Aragon, i know it has been a long time but should I simply import shp2geoserver.py in my py script and provide the (shp,featureid,sld,srs)? How do I use the shapefilebatch-cleaned.py? –  Sam007 Nov 8 '12 at 1:53

You could of course add your shapefile to postGIS using, for example, ogr2ogr ( http://www.gdal.org/ogr/drv_pg.html ).

If you append your data to an existing table the data should be included in the geoserver layer you've made for the table. If you are creating a new table (possibly what you are doing, since schemas will vary from shapefile to shapefile, you could use the beforementioned REST api to add the new table as a layer (provided that you have the datastore set up). See http://docs.geoserver.org/stable/en/user/restconfig/rest-config-examples/rest-config-examples-curl.html#adding-a-postgis-table

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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