[Geoserver-users] WMS Dynamic Color Model

Hello,

I’m working on a project that has gridded weather data, stored in a postgis database. The database isn’t really doing anything special with it, just entering one record (including a geometry column) for each cell in the grid. For hi-resolution weather information, this means that it can produce a large number of records.

Until now, we have been using WFS to filter and retrieve the regions that we want and draw the results in our OpenLayers based web interface. We have javascript code that sets the color for each small polygon based on the value of another attribute of each feature. For one example, this could be percentage likelihood of precipitation or other weather. The end result basically looks like a heat map with higher percent regions having a more intense color than the lower percentage areas.

As I mentioned though the dataset and be quite large. Unless you are filtering down to a pretty small area, then the query and rendering just takes too long. So the last couple days I’ve been experimenting with retrieving the data as a WMS layer instead of a WFS/vector layer. The results are promising. The data is properly filtered and returns much faster. (I beleive this is because its just returning a fixed 256x256 image that does not need to grow in size like the raw WFS/GML would). The only problem is I can’t figure out how to color it properly. By default, it was using the red point style and it all returned red. I tried other raster based styles, but since my data was not truly returned as raster, it failed (at least I assume that is why it failed).

I then came across the vector-to-raster based heatmap style that could be applied via WPS. I installed the extension and tried the gs:heatmap as explained here:

http://docs.geoserver.org/stable/en/user/styling/sld-extensions/rendering-transform.html

I made a couple adjustments to fit my schema and gridval values (between 50 and 100) and assigned some random colors. It does not throw any exceptions, but I also do not see any colors showing up on my map. I have attached the style definition that I’m currently trying to use.

As you have probably guessed, a lot of these concepts are still pretty new to me. I’d appreciate any tips that any of you might have to help me figure this out.

Thanks!

Jeremy

heatmap-style.xml (3.18 KB)

OK, I seem to be getting color now. I was basing my weights on the 50-100, but I just discovered in the docs that heatmap wants 0-1. So I made some changed the color map, though I’m not sure that then maps properly to my values. I do however get a heatmap to show up - which illustrated to me the fact that I probably don’t want a heatmap (it radiates outside of my filter region, among other problems). Is there another method that would provide a 1-to-1 mapping of feature geometry to color, without changing where things are drawn?

···

On Wed, Feb 19, 2014 at 3:55 PM, Jeremy Lindsey <lindsey@anonymised.com> wrote:

Hello,

I’m working on a project that has gridded weather data, stored in a postgis database. The database isn’t really doing anything special with it, just entering one record (including a geometry column) for each cell in the grid. For hi-resolution weather information, this means that it can produce a large number of records.

Until now, we have been using WFS to filter and retrieve the regions that we want and draw the results in our OpenLayers based web interface. We have javascript code that sets the color for each small polygon based on the value of another attribute of each feature. For one example, this could be percentage likelihood of precipitation or other weather. The end result basically looks like a heat map with higher percent regions having a more intense color than the lower percentage areas.

As I mentioned though the dataset and be quite large. Unless you are filtering down to a pretty small area, then the query and rendering just takes too long. So the last couple days I’ve been experimenting with retrieving the data as a WMS layer instead of a WFS/vector layer. The results are promising. The data is properly filtered and returns much faster. (I beleive this is because its just returning a fixed 256x256 image that does not need to grow in size like the raw WFS/GML would). The only problem is I can’t figure out how to color it properly. By default, it was using the red point style and it all returned red. I tried other raster based styles, but since my data was not truly returned as raster, it failed (at least I assume that is why it failed).

I then came across the vector-to-raster based heatmap style that could be applied via WPS. I installed the extension and tried the gs:heatmap as explained here:

http://docs.geoserver.org/stable/en/user/styling/sld-extensions/rendering-transform.html

I made a couple adjustments to fit my schema and gridval values (between 50 and 100) and assigned some random colors. It does not throw any exceptions, but I also do not see any colors showing up on my map. I have attached the style definition that I’m currently trying to use.

As you have probably guessed, a lot of these concepts are still pretty new to me. I’d appreciate any tips that any of you might have to help me figure this out.

Thanks!

Jeremy

To be more specific. I’m looking for a way to use a color map for vector data with WMS. Any ideas?

···

On Thu, Feb 20, 2014 at 3:44 PM, Jeremy Lindsey <lindsey@anonymised.com> wrote:

OK, I seem to be getting color now. I was basing my weights on the 50-100, but I just discovered in the docs that heatmap wants 0-1. So I made some changed the color map, though I’m not sure that then maps properly to my values. I do however get a heatmap to show up - which illustrated to me the fact that I probably don’t want a heatmap (it radiates outside of my filter region, among other problems). Is there another method that would provide a 1-to-1 mapping of feature geometry to color, without changing where things are drawn?

On Wed, Feb 19, 2014 at 3:55 PM, Jeremy Lindsey <lindsey@anonymised.com> wrote:

Hello,

I’m working on a project that has gridded weather data, stored in a postgis database. The database isn’t really doing anything special with it, just entering one record (including a geometry column) for each cell in the grid. For hi-resolution weather information, this means that it can produce a large number of records.

Until now, we have been using WFS to filter and retrieve the regions that we want and draw the results in our OpenLayers based web interface. We have javascript code that sets the color for each small polygon based on the value of another attribute of each feature. For one example, this could be percentage likelihood of precipitation or other weather. The end result basically looks like a heat map with higher percent regions having a more intense color than the lower percentage areas.

As I mentioned though the dataset and be quite large. Unless you are filtering down to a pretty small area, then the query and rendering just takes too long. So the last couple days I’ve been experimenting with retrieving the data as a WMS layer instead of a WFS/vector layer. The results are promising. The data is properly filtered and returns much faster. (I beleive this is because its just returning a fixed 256x256 image that does not need to grow in size like the raw WFS/GML would). The only problem is I can’t figure out how to color it properly. By default, it was using the red point style and it all returned red. I tried other raster based styles, but since my data was not truly returned as raster, it failed (at least I assume that is why it failed).

I then came across the vector-to-raster based heatmap style that could be applied via WPS. I installed the extension and tried the gs:heatmap as explained here:

http://docs.geoserver.org/stable/en/user/styling/sld-extensions/rendering-transform.html

I made a couple adjustments to fit my schema and gridval values (between 50 and 100) and assigned some random colors. It does not throw any exceptions, but I also do not see any colors showing up on my map. I have attached the style definition that I’m currently trying to use.

As you have probably guessed, a lot of these concepts are still pretty new to me. I’d appreciate any tips that any of you might have to help me figure this out.

Thanks!

Jeremy

Ciao Jeremy,
please, find my answer inline below…

···

Regards,
Simone Giannecchini

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Simone Giannecchini
@simogeo
Founder/Director

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

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Wed, Feb 19, 2014 at 9:55 PM, Jeremy Lindsey <lindsey@anonymised.com> wrote:

Hello,

I’m working on a project that has gridded weather data, stored in a postgis database. The database isn’t really doing anything special with it, just entering one record (including a geometry column) for each cell in the grid. For hi-resolution weather information, this means that it can produce a large number of records.

Until now, we have been using WFS to filter and retrieve the regions that we want and draw the results in our OpenLayers based web interface. We have javascript code that sets the color for each small polygon based on the value of another attribute of each feature. For one example, this could be percentage likelihood of precipitation or other weather. The end result basically looks like a heat map with higher percent regions having a more intense color than the lower percentage areas.

As I mentioned though the dataset and be quite large. Unless you are filtering down to a pretty small area, then the query and rendering just takes too long. So the last couple days I’ve been experimenting with retrieving the data as a WMS layer instead of a WFS/vector layer. The results are promising. The data is properly filtered and returns much faster. (I beleive this is because its just returning a fixed 256x256 image that does not need to grow in size like the raw WFS/GML would). The only problem is I can’t figure out how to color it properly. By default, it was using the red point style and it all returned red. I tried other raster based styles, but since my data was not truly returned as raster, it failed (at least I assume that is why it failed).

If I got this right, you should use vector styles not raster styles. Your data is vector data not raster data.
One question the geometry is a polygon or a point? I guess it should be a polygon.
Check this page for reference:

http://docs.geoserver.org/stable/en/user/styling/sld-cookbook/polygons.html

It contains a lot of info on Polygon styles.

It might be of interest to use the CSS extension for styling:
http://docs.geoserver.org/latest/en/user/extensions/css/cookbook.html

I then came across the vector-to-raster based heatmap style that could be applied via WPS. I installed the extension and tried the gs:heatmap as explained here:

http://docs.geoserver.org/stable/en/user/styling/sld-extensions/rendering-transform.html

I made a couple adjustments to fit my schema and gridval values (between 50 and 100) and assigned some random colors. It does not throw any exceptions, but I also do not see any colors showing up on my map. I have attached the style definition that I’m currently trying to use.

Thinking, it might be that the output values are too close to 0 and they come out as white. Try to replace your RasterSymbolizer with this one:

geom 1.0

If the values are ok (which means the transformation is applied correctly) they should come out as grayscale (the rastersymbolizer by default applies a linear ramp).

Let us know how it goes.

As you have probably guessed, a lot of these concepts are still pretty new to me. I’d appreciate any tips that any of you might have to help me figure this out.

Thanks!

Jeremy


Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk


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

Thank you so much, Simone. The polygon styling link is very helpful. I copied their sample and edited it a bit for my needs and it actually gave me different colors. This is great and I could probably just use this to get what I need. If I had a magic wand though, I might go one step further and figure out how to get a true gradient for my range of values. I suppose I could always have 100 different ranges that get colored in my rules, but its a bit tedious - and I worry that it might evaluate a bit more slowly. That concern may not be valid though.

Anyway - thanks a lot for the tip!. Let me know if you see any other options for enhancement.

  • Jeremy
···

On Tue, Feb 25, 2014 at 6:21 AM, Simone Giannecchini <simone.giannecchini@anonymised.com> wrote:

Ciao Jeremy,
please, find my answer inline below…

Regards,
Simone Giannecchini

Our support, Your Success! Visit http://opensdi.geo-solutions.it for more information.

Ing. Simone Giannecchini
@simogeo
Founder/Director

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

http://www.geo-solutions.it
http://twitter.com/geosolutions_it


On Wed, Feb 19, 2014 at 9:55 PM, Jeremy Lindsey <lindsey@anonymised.com> wrote:

Hello,

I’m working on a project that has gridded weather data, stored in a postgis database. The database isn’t really doing anything special with it, just entering one record (including a geometry column) for each cell in the grid. For hi-resolution weather information, this means that it can produce a large number of records.

Until now, we have been using WFS to filter and retrieve the regions that we want and draw the results in our OpenLayers based web interface. We have javascript code that sets the color for each small polygon based on the value of another attribute of each feature. For one example, this could be percentage likelihood of precipitation or other weather. The end result basically looks like a heat map with higher percent regions having a more intense color than the lower percentage areas.

As I mentioned though the dataset and be quite large. Unless you are filtering down to a pretty small area, then the query and rendering just takes too long. So the last couple days I’ve been experimenting with retrieving the data as a WMS layer instead of a WFS/vector layer. The results are promising. The data is properly filtered and returns much faster. (I beleive this is because its just returning a fixed 256x256 image that does not need to grow in size like the raw WFS/GML would). The only problem is I can’t figure out how to color it properly. By default, it was using the red point style and it all returned red. I tried other raster based styles, but since my data was not truly returned as raster, it failed (at least I assume that is why it failed).

If I got this right, you should use vector styles not raster styles. Your data is vector data not raster data.
One question the geometry is a polygon or a point? I guess it should be a polygon.
Check this page for reference:

http://docs.geoserver.org/stable/en/user/styling/sld-cookbook/polygons.html

It contains a lot of info on Polygon styles.

It might be of interest to use the CSS extension for styling:
http://docs.geoserver.org/latest/en/user/extensions/css/cookbook.html

I then came across the vector-to-raster based heatmap style that could be applied via WPS. I installed the extension and tried the gs:heatmap as explained here:

http://docs.geoserver.org/stable/en/user/styling/sld-extensions/rendering-transform.html

I made a couple adjustments to fit my schema and gridval values (between 50 and 100) and assigned some random colors. It does not throw any exceptions, but I also do not see any colors showing up on my map. I have attached the style definition that I’m currently trying to use.

Thinking, it might be that the output values are too close to 0 and they come out as white. Try to replace your RasterSymbolizer with this one:

geom 1.0

If the values are ok (which means the transformation is applied correctly) they should come out as grayscale (the rastersymbolizer by default applies a linear ramp).

Let us know how it goes.

As you have probably guessed, a lot of these concepts are still pretty new to me. I’d appreciate any tips that any of you might have to help me figure this out.

Thanks!

Jeremy


Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk


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

On Tue, Feb 25, 2014 at 3:47 PM, Jeremy Lindsey <lindsey@anonymised.com>wrote:

Thank you so much, Simone. The polygon styling link is very helpful. I
copied their sample and edited it a bit for my needs and it actually gave
me different colors. This is great and I could probably just use this to
get what I need. If I had a magic wand though, I might go one step further
and figure out how to get a true gradient for my range of values. I
suppose I could always have 100 different ranges that get colored in my
rules, but its a bit tedious - and I worry that it might evaluate a bit
more slowly. That concern may not be valid though.

Look for the interpolate function then:
http://docs.geoserver.org/latest/en/user/styling/sld-tipstricks/transformation-func.html#interpolate
It has a gotcha though, the GetLegendGraphics code does not recognize it,
so you won't get a nice legend out of it (assuming
you even need to call onto GetLegendGraphics, that is).

Cheers
Andrea

--
== Our support, Your Success! Visit http://opensdi.geo-solutions.it 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

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

Wow, I really like that Andrea - and such a simple solution too. This one seems to perform a little better for the number of polygons that I have, I’ll just need to play with the color wheel a little to getting the right values.

Thanks to all for your help! It would have taken me a long time to find this stuff without your guidance!

···

On Tue, Feb 25, 2014 at 10:04 AM, Andrea Aime <andrea.aime@anonymised.com> wrote:

On Tue, Feb 25, 2014 at 3:47 PM, Jeremy Lindsey <lindsey@anonymised.com> wrote:

Thank you so much, Simone. The polygon styling link is very helpful. I copied their sample and edited it a bit for my needs and it actually gave me different colors. This is great and I could probably just use this to get what I need. If I had a magic wand though, I might go one step further and figure out how to get a true gradient for my range of values. I suppose I could always have 100 different ranges that get colored in my rules, but its a bit tedious - and I worry that it might evaluate a bit more slowly. That concern may not be valid though.

Look for the interpolate function then: http://docs.geoserver.org/latest/en/user/styling/sld-tipstricks/transformation-func.html#interpolate
It has a gotcha though, the GetLegendGraphics code does not recognize it, so you won’t get a nice legend out of it (assuming
you even need to call onto GetLegendGraphics, that is).

Cheers
Andrea

== Our support, Your Success! Visit http://opensdi.geo-solutions.it 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