[Geoserver-users] shp2geoserver: batch import for shapefiles

Greetings, according to this mailing list there doesn't exist a tool for
batch importing shapefiles into GeoServer, so I thought I'd write one. Could
you please have a look at my algorithm and let me know what steps I am
missing:

def shp2geoserver(shp,datastoreid,sld,srs):
    copy the shapefile to data_dir\data
    add the new shapefile as a datastore element to data_dir\catalog.xml
    create index.xml under the data_dir\featureTypes\datastoreid dir

To run my script I stop GeoServer, run it, start GeoServer. The outcome is:
-the directories/files are populated as per the algorithm
-I can see the newly added datastores under
http://localhost:8080/geoserver/config/data/store.do
-I can't see the newly added features under
http://localhost:8080/geoserver/config/data/typeSelect.do

Could someone please tell me what I am doing wrong? Am I forgetting to
update some config files? Is this at all doable?

Here is some sample data:
added to <datastores> in catalog.xml
<datastore enabled="true" id="ds_south_australia_poly" namespace="topp">
      <connectionParams>
        <parameter name="create spatial index" value="true" />
        <parameter name="namespace" value="topp" />
        <parameter name="url"
value="file:data/Topo_GA/100K/south_australia_poly.shp" />
        <parameter name="charset" value="ISO-8859-1" />
      </connectionParams>
</datastore>

...\data_dir\featureTypes\ds_south_australia_poly\index.html:
<featureType datastore = "ds_south_australia_poly" >
  <name>south_australia_poly</name>
  <SRS>4283</SRS>
  <SRSHandling>0</SRSHandling>
  <title>south_australia_poly_Type</title>
  <abstract>Generated from ds_south_australia_poly</abstract>
  <wmspath>/</wmspath>
  <numDecimals value = "8" />
  <keywords>south_australia_poly ds_south_australia_poly</keywords>
  <latLonBoundingBox dynamic = "false" miny = "-43" maxy = "-25" maxx =
"141" minx = "129" />
  <nativeBBox dynamic = "false" miny = "-43" maxy = "-25" maxx = "141" minx
= "129" />
  <styles default = "south_australia_poly" />
  <cacheinfo enabled = "false" maxage = "" />
  <maxFeatures>0</maxFeatures>
</featureType>

Many thanks,
Stoyan.

PS: I'll gladly publish the script here, once I get it working.
--
View this message in context: http://www.nabble.com/shp2geoserver%3A-batch-import-for-shapefiles-tp18189529p18189529.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Hi, here is a simple script to help you load shapefiles on GeoServer:
http://www.nabble.com/file/p18604421/shp2geoserver.py 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.

--
View this message in context: http://www.nabble.com/shp2geoserver%3A-batch-import-for-shapefiles-tp18189529p18604421.html
Sent from the GeoServer - User mailing list archive at Nabble.com.