« Return to Thread: shp2geoserver: batch import for shapefiles

Re: shp2geoserver: batch import for shapefiles

by stoyan :: Rate this Message:

Reply to Author | View in Thread

Hi, here is a simple script to help you load shapefiles on GeoServer: shp2geoserver.py

Problem: GeoServer has a nice GUI to help you load shapefiles, but it gets tedious doing the same steps over and over when you have hundreds of files.

Solution:
-copy your shapefile to the GeoServer data_dir directory
-edit shp2geoserver.py
        +change the data_dir variable if required
        +check that infoxmltemplate and datastoretemplate match your desired output
        +under main call shp2geoserver with your parameters
The script would:
-add the new shapefile as a datastore element to data_dir\catalog.xml
-create info.xml under the data_dir\featureTypes\datastoreid dir

Pre-requisites:
-python 2.5 or later (it's using ElementTree for xml manipulation)
-gdal for python (get it from: http://trac.osgeo.org/gdal/wiki/GdalOgrInPython)

BTW, did you know that you can use http://arcmap2sld.geoinform.fh-mainz.de/ArcMap2SLDConverter_Eng.htm to get an SLD file from an ESRI .mxd? Soon, you won’t have to though as ESRI 9.3 supports SLD.

Cheers,
Stoyan.

 « Return to Thread: shp2geoserver: batch import for shapefiles