[Geoserver-users] Can CQL Expressions be applied to raster bands?

Hello,

I am wondering if CQL expression can be applied to a multibanded raster. I have a raster that has 10+* bands and I want to have the visualiz presentation change with input from the user. I successfully loaded the data into geoserver and each band is present in the raster.

Currently this is error I am receiving in geoserver

Caused by: org.geoserver.platform.ServiceException: java.lang.IllegalArgumentException: Band number -1 is not valid.
at org.geoserver.wms.map.RenderedImageMapOutputFormat.directRasterRender(RenderedImageMapOutputFormat.java:990)
at org.geoserver.wms.map.RenderedImageMapOutputFormat.produceMap(RenderedImageMapOutputFormat.java:340)
… 111 more
Caused by: java.lang.IllegalArgumentException: Band number -1 is not valid.
at org.geotools.renderer.lite.gridcoverage2d.BandSelectionNode.visit(BandSelectionNode.java:210)
at org.geotools.renderer.lite.gridcoverage2d.ChannelSelectionNode.visit(ChannelSelectionNode.java:152)
at org.geotools.renderer.lite.gridcoverage2d.RasterSymbolizerHelper.visit(RasterSymbolizerHelper.java:210)
at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.symbolize(GridCoverageRenderer.java:464)
at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.renderImage(GridCoverageRenderer.java:912)
at org.geotools.renderer.lite.gridcoverage2d.GridCoverageRenderer.renderImage(GridCoverageRenderer.java:750)
at org.geoserver.wms.map.RenderedImageMapOutputFormat.directRasterRender(RenderedImageMapOutputFormat.java:883)
… 112 more
Caused by: java.lang.NumberFormatException: For input string: “${env(‘bandnum’,2)}”
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:481)
at java.lang.Integer.parseInt(Integer.java:527)
at org.geotools.renderer.lite.gridcoverage2d.BandSelectionNode.visit(BandSelectionNode.java:207)

Seems that CQL expressions are not supported for this yet? Is there another way I can go about it. Visualization works fine if I specify a new SLD with the SourceChannelName set to band value (0-10)

${env('bandnum',2)}
···

David Haynes, Ph.D.
Research Associate Terra Populus
Minnesota Population Center
612-626-3933
www.terrapop.org

On Mon, Oct 12, 2015 at 4:27 PM, David Haynes II <dahaynes@anonymised.com> wrote:

Seems that CQL expressions are not supported for this yet? Is there
another way I can go about it. Visualization works fine if I specify a new
SLD with the SourceChannelName set to band value (0-10)

Hi, no, band combining expressions are not yet supported in any form.
Using cql directly in SLD is rather elegant, I admit, it would require
quite a bit of work and API breakage in GeoTools though.

A rendering transformation based on the Jiffle language
<https://github.com/mbedward/jiffle&gt; would be less invasive and higher
performing,
and we have the beginning of that solution written in this pull request
https://github.com/geotools/geotools/pull/534
but yeah, also this would require resourcing to make it happen

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.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.

-------------------------------------------------------

Hi

I am trying to do some simple sld styling but can’t get it to do exactly what I want

I want a polygon with a white background and small blue dots

Can’t find anything similar in the sld cookbook

Anyone have any tips on how to achieve this ?

Mark

On Tue, Oct 13, 2015 at 2:28 PM, Ismail, Mark <mark.ismail@anonymised.com>
wrote:

Hi

I am trying to do some simple sld styling but can’t get it to do exactly
what I want

I want a polygon with a white background and small blue dots

Can’t find anything similar in the sld cookbook

Anyone have any tips on how to achieve this ?

I don't have any SLD handy but try as follows:
* One rule, two polygon symbolizers
* First polygon symbolizer, solid white fill
* Second polygon symbolizer, graphic fill with the circle symbol, blue, and
add "graphic-margin" to space the dots as much as you need

http://docs.geoserver.org/stable/user/styling/sld-extensions/margins.html

If the points need to be scattered instead of regularly distributed have a
look at this one:
http://docs.geoserver.org/stable/user/styling/sld-extensions/randomized.html

Cheers
Andrea

--

GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.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.

-------------------------------------------------------

Is this similar to what you are after?:

<?xml version="1.0" encoding="UTF-8"?>

Dots

circle

#0000AA

#000000

1

16

2

You may find it easier to create an external graphic though and just use that as the fill

···

From: Ismail, Mark [mailto:mark.ismail@…6440…]
Sent: 13 October 2015 13:28
To: GeoServer Mailing List List
Subject: [Geoserver-users] Sld styling with dots

Hi

I am trying to do some simple sld styling but can’t get it to do exactly what I want

I want a polygon with a white background and small blue dots

Can’t find anything similar in the sld cookbook

Anyone have any tips on how to achieve this ?

Mark

This e-mail and any attachments are confidential. It may contain privileged information and is intended for the named recipient(s) only. It must not be distributed without consent. If you are not one of the intended recipients, please notify the sender immediately and do not disclose, distribute, or retain this email or any part of it and do not take any action based on it.

Unless expressly stated, opinions in this email are those of the individual sender, and not of Knowsley MBC. Legally binding obligations can only be created for, or be entered into on behalf of, Knowsley MBC by duly authorised officers or representatives.

Knowsley MBC excludes any liability whatsoever for any offence caused, any direct or consequential loss arising from the use, or reliance on, this e-mail or its contents. We believe but do not warrant that this e-mail and any attachments are virus free. You must therefore take full responsibility for virus checking and no responsibility is accepted for loss or damage arising from viruses or changes made to this message after it was sent. Knowsley MBC reserves the right to monitor and/or record all e-mail communications through its network in accordance with relevant legislation.

Thanks

It does exactly want I need

sld validater doesn’t like the vendor option though but it works when submitted

···

Mark Ismail

Principal Application Support Officer
Tel: 0151 443 3021 | Email: mark.ismail@…6440…

Computer Centre | Westmorland Road | Huyton | Merseyside | L36 9GL

Use the IT Service Desk Self Serve Application

From: Kirk, Victor [mailto:VICTOR.KIRK@…7093…]
Sent: 13 October 2015 14:08
To: Ismail, Mark; GeoServer Mailing List List
Subject: RE: Sld styling with dots

Is this similar to what you are after?:

<?xml version="1.0" encoding="UTF-8"?>

Dots

circle

#0000AA

#000000

1

16

2

You may find it easier to create an external graphic though and just use that as the fill

From: Ismail, Mark [mailto:mark.ismail@…6440…]
Sent: 13 October 2015 13:28
To: GeoServer Mailing List List
Subject: [Geoserver-users] Sld styling with dots

Hi

I am trying to do some simple sld styling but can’t get it to do exactly what I want

I want a polygon with a white background and small blue dots

Can’t find anything similar in the sld cookbook

Anyone have any tips on how to achieve this ?

Mark

This e-mail and any attachments are confidential. It may contain privileged information and is intended for the named recipient(s) only. It must not be distributed without consent. If you are not one of the intended recipients, please notify the sender immediately and do not disclose, distribute, or retain this email or any part of it and do not take any action based on it.

Unless expressly stated, opinions in this email are those of the individual sender, and not of Knowsley MBC. Legally binding obligations can only be created for, or be entered into on behalf of, Knowsley MBC by duly authorised officers or representatives.

Knowsley MBC excludes any liability whatsoever for any offence caused, any direct or consequential loss arising from the use, or reliance on, this e-mail or its contents. We believe but do not warrant that this e-mail and any attachments are virus free. You must therefore take full responsibility for virus checking and no responsibility is accepted for loss or damage arising from viruses or changes made to this message after it was sent. Knowsley MBC reserves the right to monitor and/or record all e-mail communications through its network in accordance with relevant legislation.

Hello Andrea,

Thanks for the response. I came up with a work around that works pretty smoothly. Perhaps in the future it could be integrated it into an extension of the PostGIS JDBC connection. Since the PostGIS doesn’t set a limit on the number of bands within a raster dataset we have a large collection of rasters, well over 500 in our system. The example I am currently are 16 cereal crops around the world. What I ended up doing was ingesting the multiband raster into a single raster_table, gli.cereals with views o_2_cereals… o_16_cereals. Then I create a view for each CREATE VIEW gli.o_16_barley AS SELECT r.rid, st_band(r.rast, 1) AS rast FROM gli.o_16_cereals r; This is done for all of the datasets. The view are essentially queries on the cereals table so you aren’t duplicating your data, but using the function st_band allows you to extract a single band. Then the metadata table is created barley_mosaic and each view information is placed within the table. something like: ‘insert into gli.barley_mosaic(name, tiletable) values (‘gli.barley_mosaic’, ‘gli.o_16_barley’);’ make the xml and you are set to go.

I plan to implement this for a temporal stack of meris 300m satellite data.

···

On Mon, Oct 12, 2015 at 10:18 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Mon, Oct 12, 2015 at 4:27 PM, David Haynes II <dahaynes@anonymised.com> wrote:

Seems that CQL expressions are not supported for this yet? Is there another way I can go about it. Visualization works fine if I specify a new SLD with the SourceChannelName set to band value (0-10)

Hi, no, band combining expressions are not yet supported in any form.
Using cql directly in SLD is rather elegant, I admit, it would require quite a bit of work and API breakage in GeoTools though.

A rendering transformation based on the Jiffle language would be less invasive and higher performing,
and we have the beginning of that solution written in this pull request https://github.com/geotools/geotools/pull/534
but yeah, also this would require resourcing to make it happen

Cheers
Andrea

==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.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.


David Haynes, Ph.D.
Research Associate Terra Populus
Minnesota Population Center
612-626-3933
www.terrapop.org

Hi David,
thanks for sharing your solution, I’m sure others will benefit from it too

Cheers
Andrea

···

On Thu, Oct 15, 2015 at 4:07 PM, David Haynes II <dahaynes@anonymised.com.> wrote:

Hello Andrea,

Thanks for the response. I came up with a work around that works pretty smoothly. Perhaps in the future it could be integrated it into an extension of the PostGIS JDBC connection. Since the PostGIS doesn’t set a limit on the number of bands within a raster dataset we have a large collection of rasters, well over 500 in our system. The example I am currently are 16 cereal crops around the world. What I ended up doing was ingesting the multiband raster into a single raster_table, gli.cereals with views o_2_cereals… o_16_cereals. Then I create a view for each CREATE VIEW gli.o_16_barley AS SELECT r.rid, st_band(r.rast, 1) AS rast FROM gli.o_16_cereals r; This is done for all of the datasets. The view are essentially queries on the cereals table so you aren’t duplicating your data, but using the function st_band allows you to extract a single band. Then the metadata table is created barley_mosaic and each view information is placed within the table. something like: ‘insert into gli.barley_mosaic(name, tiletable) values (‘gli.barley_mosaic’, ‘gli.o_16_barley’);’ make the xml and you are set to go.

I plan to implement this for a temporal stack of meris 300m satellite data.

On Mon, Oct 12, 2015 at 10:18 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

David Haynes, Ph.D.
Research Associate Terra Populus
Minnesota Population Center
612-626-3933
www.terrapop.org

On Mon, Oct 12, 2015 at 4:27 PM, David Haynes II <dahaynes@anonymised.com> wrote:

Seems that CQL expressions are not supported for this yet? Is there another way I can go about it. Visualization works fine if I specify a new SLD with the SourceChannelName set to band value (0-10)

Hi, no, band combining expressions are not yet supported in any form.
Using cql directly in SLD is rather elegant, I admit, it would require quite a bit of work and API breakage in GeoTools though.

A rendering transformation based on the Jiffle language would be less invasive and higher performing,
and we have the beginning of that solution written in this pull request https://github.com/geotools/geotools/pull/534
but yeah, also this would require resourcing to make it happen

Cheers
Andrea

==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.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.


==
GeoServer Professional Services from the experts! Visit
http://goo.gl/it488V for more information.

Ing. Andrea Aime

@geowolf
Technical Lead

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39 339 8844549

http://www.geo-solutions.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.