1

As the title says I converted/imported a KML file into my PostGIS database using the ogr2ogr command. Now I am trying to publish each table as a seperate layer onto a GeoServer. I know about cURL, but as far as I can see I would have to have a new command for each table in the db. I have 124 tables I need to publish so doing that one by one would be labor intensive. Is there anyway straight-forward way to streamline this process?

2

You will want to use this example to build up a script: http://docs.geoserver.org/stable/en/user/rest/examples/curl.html#adding-a-postgis-table

Using Python, you could list all the tables in your postgis database, then craft a HTML call (using urllib) to publish each one.

Issues you might have include styling, to name just one. And you might want to set up a metadata table to read from (could be a CSV or spreadsheet) in order to set up the specifics for each table.

When you have a table with your specifics for your 124 tables, then use the python script to set it all up on GeoServer. Perhaps you write your script to do the following (assuming you have your datastore set up):

  1. delete your workspace and all layers, if they exist
  2. create your workspace
  3. populate the workspace with all your tables, using parameters from your metadata spreadsheet

That way, if it works, you're good. And if it doesn't, or you want an additional 20 tables, you can simply re-run the script. And, if it doesn't work, you can fix the problem and re-run the script!

Good luck =)

Edit: note that there is an excellent python library to hit the GeoServer API with: https://github.com/boundlessgeo/gsconfig

  • Thanks for the help! What type of datastore should I put them in? – SketchyTurtle Feb 11 '15 at 14:06
  • Sorry, the word is just store. It's the PostGIS connection. A store defines a dataset or group of datasets. – Alex Leith Feb 11 '15 at 21:40
  • 1
    Also, rather than crafting URLs, use this library for Python: github.com/boundlessgeo/gsconfig – Alex Leith Jan 14 '16 at 0:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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