Thanks again for helping me getting to the right xml links.
However, I took another route and got the bounding boxes (and a few other 
things) by using OWSLib.

For those with the same needs, I have included the Python function below in the 
hope it’ll be useful to some else too.

Cheers
Ole


def get_ows_metadata(server_url, layer_name):
    """Uses OWSLib to get the metadata for a given layer

    Input
        server_url: e.g. http://localhost:8001/geoserver-geonode-dev/ows
        layer_name: must follow the convention workspace:name

    Output
        metadata: Dictionary of metadata fields common to both
                  raster and vector layers
    """

    wcs = WebCoverageService(server_url, version='1.0.0')
    wfs = WebFeatureService(server_url, version='1.0.0')

    metadata = {}
    if layer_name in wcs.contents:
        layer = wcs.contents[layer_name]
        metadata['layer_type'] = 'raster'
    elif layer_name in wfs.contents:
        layer = wfs.contents[layer_name]
        metadata['layer_type'] = 'vector'
    else:
        msg = ('Layer %s was not found in WxS contents on server %s.\n'
               'WCS contents: %s\n'
               'WFS contents: %s\n' % (layer_name, server_url,
                                       wcs.contents, wfs.contents))
        raise Exception(msg)

    # Metadata common to both raster and vector data
    metadata['bounding_box'] = layer.boundingBoxWGS84
    metadata['title'] = layer.title
    metadata['id'] = layer.id

    return metadata





From: [email protected] [mailto:[email protected]] On Behalf Of Chris 
Holmes
Sent: Thursday, 23 June 2011 1:27 AM
To: Ole Nielsen
Cc: Chris Holmes; [email protected]
Subject: Re: [Geoserver-users] How to get metadata such as the native bounding 
box for raster data through REST?

Oh weird, if I go from chrome I get the .xml link, if I go from firefox I get 
the html page you sent.  Which yeah, give a big error, so something is wrong.
On Wed, Jun 22, 2011 at 3:49 AM, Ole Nielsen 
<[email protected]<mailto:[email protected]>> wrote:
Thanks for the link and the explanation. This was exactly what I was after.

This link works beautifully and provides the information we need.
 
http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coverages/Lembang_Earthquake_Scenario.xml

However trying the recipe and going to this one
http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/
returns this page
Coverage Store "Lembang_Earthquake_Scenario"

 *   
Lembang_Earthquake_Scenario<http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coveragestores/Lembang_Earthquake_Scenario.html>
But clicking on the above fails. This is what I tried earlier too. However, 
replacing the .html in the link with .xml does provide the information you 
mention.
Is that the correct procedure and intended?

Anyway, with the template above I should be able to generate the calls we need.

Many thanks
Ole

From: Chris Holmes [mailto:[email protected]<mailto:[email protected]>]
Sent: Wednesday, 22 June 2011 10:41 AM
To: Ole Nielsen
Cc: 
[email protected]<mailto:[email protected]>
Subject: Re: [Geoserver-users] How to get metadata such as the native bounding 
box for raster data through REST?

You want coverages instead of coveragetypes.  The base inspiration for the 
names is the WFS vs WCS specs, WFS calls layer categories featureTypes, WCS 
calls them coverages.

So  
http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coverages/Lembang_Earthquake_Scenario.xml
works for me.

I think the GS rest is a bit confusing, as it'll generate some stuff that can 
throw you off a bit - I got a bit turned around navigating when putting in the 
wrong stuff.  But what you can generally do is go a level or two up and see the 
links it has under it.  So if you go to:

http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/

Then it'll point you at its list of coverages:

http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coverages.xml

 Which then finally has the proper link with 'coverages'.

It'd probably be better if we didn't generate anything at all if you put in the 
wrong word for 'coverages'.  It looks like basically it matches anything and 
tries to generate the same stuff it would if you put it in correctly.  Not sure 
if that was by design, or just neglected to turn off one of the paths.

C

On Tue, Jun 21, 2011 at 10:23 PM, Ole Nielsen 
<[email protected]<mailto:[email protected]>> wrote:
Dear all

I am sure this is a simple problem, but I can't work out how to get the 
bounding box of a raster layer through REST.
I tried to mimic the approach used for vector data (see example below), but so 
far my attempts have only resulted in minimal data.

Here's the REST call which works for vector data
http://www.aifdr.org:8080/geoserver/rest/workspaces/boundaries/datastores/Province_Boundaries/featuretypes/Province_Boundaries.xml

And here are my attempts for raster data which don't work (although they do 
provide some output which I have included below):
http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coveragetypes/Lembang_Earthquake_Scenario.xml
http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coveragestores/Lembang_Earthquake_Scenario.xml


Please help point me to the correct magic.
Cheers and thanks
Ole

PS - the username password on the server above are the GeoServer default, so 
you can test the responses yourself.


---------------- Output -----------------------

http://www.aifdr.org:8080/geoserver/rest/workspaces/boundaries/datastores/Province_Boundaries/featuretypes/Province_Boundaries.xml

<featureType>
<name>Province_Boundaries</name>
<nativeName>Province_Boundaries</nativeName>
−
<namespace>
<name>boundaries</name>
<atom:link rel="alternate" 
href="http://www.aifdr.org:8080/geoserver/rest/namespaces/boundaries.xml"; 
type="application/xml"/>
</namespace>
<title>Province_Boundaries</title>
−
<nativeCRS>
GEOGCS["GCS_WGS_1984",
  DATUM["D_WGS_1984",
    SPHEROID["WGS_1984", 6378137.0, 298.257223563]],
  PRIMEM["Greenwich", 0.0],
  UNIT["degree", 0.017453292519943295],
  AXIS["Longitude", EAST],
  AXIS["Latitude", NORTH]]
</nativeCRS>
<srs>EPSG:4326</srs>
−
<nativeBoundingBox>
<minx>95.05966095200006</minx>
<maxx>141.00538235200008</maxx>
<miny>-10.99740996099996</miny>
<maxy>5.906883970000024</maxy>
<crs>EPSG:4326</crs>
</nativeBoundingBox>
−
<latLonBoundingBox>
<minx>95.05966095200006</minx>
<maxx>141.00538235200008</maxx>
<miny>-10.99740996099996</miny>
<maxy>5.906883970000024</maxy>
<crs>EPSG:4326</crs>
</latLonBoundingBox>
<projectionPolicy>NONE</projectionPolicy>
<enabled>true</enabled>
−
<store class="dataStore">
<name>Province_Boundaries</name>
<atom:link rel="alternate" 
href="http://www.aifdr.org:8080/geoserver/rest/workspaces/boundaries/datastores/Province_Boundaries.xml";
 type="application/xml"/>
</store>
<maxFeatures>0</maxFeatures>
<numDecimals>0</numDecimals>
</featureType>


----------------------------------------------------------------------------------
http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coveragetypes/Lembang_Earthquake_Scenario.xml
<coverageStore>
<name>Lembang_Earthquake_Scenario</name>
<type>GeoTIFF</type>
<enabled>true</enabled>
−
<workspace>
<name>hazard</name>
<atom:link rel="alternate" 
href="http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard.xml"; 
type="application/xml"/>
</workspace>
−
<url>
file:data/Lembang_Earthquake_Scenario/Lembang_Earthquake_Scenario.geotiff
</url>
−
<coverages>
<atom:link rel="alternate" 
href="http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coveragetypes/Lembang_Earthquake_Scenario/coverages.xml";
 type="application/xml"/>
</coverages>
</coverageStore>

----------------------------------------------------------------------------------
http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coveragestores/Lembang_Earthquake_Scenario.xml
<coverages>
−
<coverage>
<name>Lembang_Earthquake_Scenario</name>
<atom:link rel="alternate" 
href="http://www.aifdr.org:8080/geoserver/rest/workspaces/hazard/coveragestores/Lembang_Earthquake_Scenario/coveragestores/Lembang_Earthquake_Scenario/Lembang_Earthquake_Scenario.xml";
 type="application/xml"/>
</coverage>
</coverages>


------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Geoserver-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/geoserver-users


------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Geoserver-users mailing list
[email protected]<mailto:[email protected]>
https://lists.sourceforge.net/lists/listinfo/geoserver-users

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a 
definitive record of customers, application performance, security 
threats, fraudulent activity and more. Splunk takes this data and makes 
sense of it. Business sense. IT sense. Common sense.. 
http://p.sf.net/sfu/splunk-d2d-c1
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to