[Geoserver-users] Find layers that ends in "RGB"

Dear GeoServer users,

I am working with the rest api and I need to get a list of coverages from GeoServer via cURL but just those which are RGB products (layer name ending in “RGB”)

I read in here that almost everything you can do in the GUI can be done using cURL.

Please, could anybody point me to the right way to find out a solution?

Thank you very much,

Alberto

Hi Alberto,
if I understand your question correctly, you’re looking for a way to retrieve via the REST API all the layers whose name matches a certain pattern… but I’m afraid that is currently not possible.

Happy to be proven wrong anyways :slight_smile:

···

On Fri, Apr 15, 2016 at 6:43 PM, Alberto Callejas Delgado <alberto.callejas@anonymised.com> wrote:

Dear GeoServer users,

I am working with the rest api and I need to get a list of coverages from GeoServer via cURL but just those which are RGB products (layer name ending in “RGB”)

I read in here that almost everything you can do in the GUI can be done using cURL.

Please, could anybody point me to the right way to find out a solution?

Thank you very much,

Alberto


Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z


Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Best regards,
Stefano Costa

==
GeoServer Professional Services from the experts! Visit
[http://goo.gl/it488V](http://goo.gl/it488V) for more information.
==
Dott. Stefano Costa
Senior Software Engineer

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
Italy
phone: +39 0584 962313
fax:     +39 0584 1660272

[http://www.geo-solutions.it](http://www.geo-solutions.it)
[http://twitter.com/geosolutions_it](http://twitter.com/geosolutions_it)

-------------------------------------------------------
AVVERTENZE AI SENSI DEL D.Lgs. 196/2003
Le informazioni contenute in questo messaggio di posta elettronica e/o
nel/i file/s allegato/i sono da considerarsi strettamente riservate.
Il loro utilizzo è consentito esclusivamente al destinatario del
messaggio, per le finalità indicate nel messaggio stesso. Qualora
riceviate questo messaggio senza esserne il destinatario, Vi preghiamo
cortesemente di darcene notizia via e-mail e di procedere alla
distruzione del messaggio stesso, cancellandolo dal Vostro sistema.
Conservare il messaggio stesso, divulgarlo anche in parte,
distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità
diverse, costituisce comportamento contrario ai principi dettati dal
D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely
for the attention and use of the named addressee(s) and may be
confidential or proprietary in nature or covered by the provisions of
privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New
Data Protection Code).Any use not in accord with its purpose, any
disclosure, reproduction, copying, distribution, or either
dissemination, either whole or partial, is strictly forbidden except
previous formal approval of the named addressee(s). If you are not the
intended recipient, please contact immediately the sender by
telephone, fax or e-mail and delete the information in this message
that has been received in error. The sender does not give any warranty
or accept liability as the content, accuracy or completeness of sent
messages and accepts no responsibility  for changes made after they
were sent or for other risks which arise as a result of e-mail
transmission, viruses, etc.

Alberto,

the canonical way to discover resources via OGC web services is with a GetCapabilities request. In the case of WCS, you can discover the names of all enabled coverages. Use curl or any other HTTP client to retrieve the capabilities document, then parse it as XML with your language or tool of choice to extract the coverage names.

For example, for the release configuration of GeoServer, with curl output piped into the xpath tool (from the libxml-xpath-perl package on Debian; what is your platform?):

curl -s "http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities&quot; | xpath -q -e '//wcs:CoverageId/text()'

Output:

nurc__Arc_Sample
nurc__Img_Sample
nurc__mosaic
sf__sfdem

Filter this output to obtain a list of coverages whose names end in "RGB". You can do exactly the same thing in Java, Python, or any other general purpose language with HTTP and XML parsing support.

Kind regards,
Ben.

On 16/04/16 04:43, Alberto Callejas Delgado wrote:

Dear GeoServer users,

I am working with the rest api and I need to get a list of coverages from
GeoServer via cURL but just those which are RGB products (layer name ending
in "RGB")

I read in here that almost everything you can do in the GUI can be done
using cURL.

Please, could anybody point me to the right way to find out a solution?

Thank you very much,

Alberto

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand

Alberto,

rather than filtering the output, you could also include a predicate in the XPath to select only the CoverageId elements you want:

$ curl -s 'http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities’ | xpath -q -e '//wcs:CoverageId/text()[contains(.,"Sample")]'
nurc__Arc_Sample
nurc__Img_Sample

This example is not strictly what you want if you only want to match a substring at the end of the CoverageId text. xpath appears to support only XPath 1.0 so does not support ends-with() (from XPath 2.0), but you can make your own with this ugly but effective construct:

$ curl -s 'http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities’ | xpath -q -e '//wcs:CoverageId/text()[substring(.,string-length(.)-string-length("Sample")+1)="Sample"]'

nurc__Arc_Sample
nurc__Img_Sample

In your case this would be:

curl -s 'http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities’ | xpath -q -e '//wcs:CoverageId/text()[substring(.,string-length(.)-string-length("RGB")+1)="RGB"]'

Kind regards,
Ben.

On 16/04/16 09:01, Ben Caradoc-Davies wrote:

Alberto,

the canonical way to discover resources via OGC web services is with a
GetCapabilities request. In the case of WCS, you can discover the names
of all enabled coverages. Use curl or any other HTTP client to retrieve
the capabilities document, then parse it as XML with your language or
tool of choice to extract the coverage names.

For example, for the release configuration of GeoServer, with curl
output piped into the xpath tool (from the libxml-xpath-perl package on
Debian; what is your platform?):

curl -s
"http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities&quot;
| xpath -q -e '//wcs:CoverageId/text()'

Output:

nurc__Arc_Sample
nurc__Img_Sample
nurc__mosaic
sf__sfdem

Filter this output to obtain a list of coverages whose names end in
"RGB". You can do exactly the same thing in Java, Python, or any other
general purpose language with HTTP and XML parsing support.

Kind regards,
Ben.

On 16/04/16 04:43, Alberto Callejas Delgado wrote:

Dear GeoServer users,

I am working with the rest api and I need to get a list of coverages from
GeoServer via cURL but just those which are RGB products (layer name ending
in "RGB")

I read in here that almost everything you can do in the GUI can be done
using cURL.

Please, could anybody point me to the right way to find out a solution?

Thank you very much,

Alberto

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/&gt;
New Zealand

Hello Ben,

I really appreciate your help!

Definitely you have pointed the way out to solve my question.

Once I retrieve the. xml capabilities document I can extract the wcs:CoverageId using xml.etree.ElementTree
in Python (my platform is Windows).

It still surprises me the community support in GeoServer, it is just great.

I’ll get hands to work!

Alberto

···

On 16 April 2016 at 01:02, Ben Caradoc-Davies <ben@anonymised.com6881…> wrote:

Alberto,

rather than filtering the output, you could also include a predicate in the XPath to select only the CoverageId elements you want:

$ curl -s ‘http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities’ | xpath -q -e ‘//wcs:CoverageId/text()[contains(.,“Sample”)]’
nurc__Arc_Sample
nurc__Img_Sample

This example is not strictly what you want if you only want to match a substring at the end of the CoverageId text. xpath appears to support only XPath 1.0 so does not support ends-with() (from XPath 2.0), but you can make your own with this ugly but effective construct:

$ curl -s ‘http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities’ | xpath -q -e ‘//wcs:CoverageId/text()[substring(.,string-length(.)-string-length(“Sample”)+1)=“Sample”]’
nurc__Arc_Sample
nurc__Img_Sample

In your case this would be:

curl -s ‘http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities’ | xpath -q -e ‘//wcs:CoverageId/text()[substring(.,string-length(.)-string-length(“RGB”)+1)=“RGB”]’

Kind regards,
Ben.

On 16/04/16 09:01, Ben Caradoc-Davies wrote:

Alberto,

the canonical way to discover resources via OGC web services is with a
GetCapabilities request. In the case of WCS, you can discover the names
of all enabled coverages. Use curl or any other HTTP client to retrieve
the capabilities document, then parse it as XML with your language or
tool of choice to extract the coverage names.

For example, for the release configuration of GeoServer, with curl
output piped into the xpath tool (from the libxml-xpath-perl package on
Debian; what is your platform?):

curl -s
http://localhost:8080/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities
| xpath -q -e ‘//wcs:CoverageId/text()’

Output:

nurc__Arc_Sample
nurc__Img_Sample
nurc__mosaic
sf__sfdem

Filter this output to obtain a list of coverages whose names end in
“RGB”. You can do exactly the same thing in Java, Python, or any other
general purpose language with HTTP and XML parsing support.

Kind regards,
Ben.

On 16/04/16 04:43, Alberto Callejas Delgado wrote:

Dear GeoServer users,

I am working with the rest api and I need to get a list of coverages from
GeoServer via cURL but just those which are RGB products (layer name ending
in “RGB”)

I read in here that almost everything you can do in the GUI can be done
using cURL.

Please, could anybody point me to the right way to find out a solution?

Thank you very much,

Alberto


Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z


Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users


Ben Caradoc-Davies <ben@anonymised.com>
Director
Transient Software Limited <http://transient.nz/>
New Zealand