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 a directory of raster imagery that will be updated continually. From this imagery, I am making Image Pyramids using the Geotool's PyramidBuilder utility. I need to setup a cron job to automatically add raster datastores and layers to Geoserver without using the UI.

After looking at the REST section of the Geoserver manual I was able to add my workspace, "testWS", but trying the create an ImagePyramid datastore did not work.

Since I have access to the datastore, I expanded on the shapefile example and tried to

curl -u admin:geoserver -XPUT -H 'Content-type: text/plain' \ 
   -d '/opt/geoserver_data_dir/2.0.2/data/test_pyramid.pyr' \
    "http://localhost:8080/geoserver/rest/workspaces/testWS/datastores/test_pyramid.pyr/external.imagepyramid?configure=all"

Where test_pyramid.pyr is the base of my ImagePyramid at this location.

This gave me an error of "No such datastore: test_pyramid"

Is there a better way to add a new datastore and layer to Geoserver without manually adding each one via the UI? I need help in crafting the proper REST statement that will add an extisting ImagePyramid as a datastore and layer.

Is there some Java code that could do this? I looked at the Geoserver python extensions but they did not have this either.

share|improve this question
    
This post from Jan mail-archive.com/geoserver-users@lists.sourceforge.net/… describes almost the exact same problem. No resolution there. –  DaveParillo Feb 24 '11 at 0:28
1  
The geoserver docs at docs.geoserver.org/stable/en/user/restconfig/… imply that the only datastores you can configure using this method are a file in the case of a Shapefile, a database in the case of PostGIS, or a server in the case of a remote Web Feature Service, but the docs may simply be incomplete. –  DaveParillo Feb 24 '11 at 0:51
    
can you add what is actually in the file you are POSTing to the server? –  iant Feb 24 '11 at 16:47
    
But you have to construct an XML file that contains that information. –  iant Feb 25 '11 at 1:24
    
what I am trying to post is the path to the datastore I want Geoserver to create. This path is an external set of raster files (imagepyramid) in a single directory. All I wanted is for Geoserver to create the datastore and layer for an imagepyramid at this location (on the same filesystem as geoserver.) –  rbrister Feb 25 '11 at 1:25

2 Answers 2

You can create a workspace, datastore and layer (coveragestore) for a GeoTiff with curl and xml from outside the UI like so:

  1. Create the workspace.

    curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' \
         -d '<workspace><name>wsgeotiff</name></workspace>' \
         http://localhost:8080/geoserver/rest/workspaces
    
  2. Then create the datastore.

    curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' \
         -d '<coverageStore>
             <name>wsgeotiff_imageGeoTiffWGS84_1298678792699</name
             <enabled>true</enabled>
             <type>GeoTIFF</type>
             <url>/home/gis/image_wgs84.tif</url>
             </coverageStore>' \
         "http://localhost:8080/geoserver/rest/workspaces/wsgeotiff/coveragestores?configure=all"
    
  3. Then create the Layer.

     curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' \
          -d '<coverage>
              <name>imageGeoTiffWGS84</name>
              <title>imageGeoTiffWGS84</title>
              <nativeCRS>GEOGCS[&quot;WGS 84&quot;,DATUM[&quot;World Geodetic System 1984&quot;,SPHEROID[&quot;WGS 84&quot;,6378137.0, 298.257223563, AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;, 0.0, AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNIT[&quot;degree&quot;, 0.017453292519943295],AXIS[&quot;Geodetic longitude&quot;, EAST],AXIS[&quot;Geodetic latitude&quot;, NORTH],AUTHORITY[&quot;EPSG&quot;,&quot;4326&quot;]]</nativeCRS>
              <srs>EPSG:4326</srs>
              <latLonBoundingBox><minx>-179.958</minx><maxx>-105.002</maxx><miny>-65.007</miny><maxy>65.007</maxy><crs>EPSG:4326</crs></latLonBoundingBox>
              </coverage>' \
          "http://localhost:8080/geoserver/rest/workspaces/wsgeotiff/coveragestores/wsgeotiff_imageGeoTiffWGS84_1298678792699/coverages"
    

When all this is done you have a datastore pointing to the external image 'image_wgs84.tif' and a WMS layer to display the coverage in.

What I don't know is whether this technique will translate directly into a technique for creating an image pyramid type datastore or not.

Good luck.

share|improve this answer
    
I have the same exact problem as the question above. Thanks for putting it nicely, most solutions out there are confusing. I have one question here though. In your answer the Bounding Boxes of the raster need to be given as input. Now I understand that if I am putting the above solution in a script, i could use gdalinfo to find the bounding box. But thats just added work (parsing etc.). My question is can we make geoserver calculate the bounding boxes automatically? We know it can do so , because when we add a raster from UI it calculates Bounding Box! –  Shaunak Sep 30 '11 at 7:19
1  
On my GeoServer 2.2 you don't need to specify the Bounding Box (and SRS etc) explicitly. It detects them automatically from the file upon layer creation (tested for GeoTIFF and ImageMosaic). You can additionally set ?recalculate=nativebbox to have the native bounding box recalculated when the projection or projection policy is changed. See docs.geoserver.org/stable/en/user/rest/api/… –  xandriksson Jul 30 '13 at 7:29

You'll need a coverage store and coverages.

A coverage store is a source of spatial data that is raster based.

The data stores you tried to use are only for vector data.

Have you checked How to use curl to upload Coverage through the Geoserver rest?

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.