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 PostGIS table that contains the GDP of countries together with their polygon boundaries. I am using GeoServer to display this data via OpenLayers.

When styling the data, I want to avoid having to hardcode numeric range / colour pairs in my SLD file.

Is it possible to create an SLD style file that dynamically determines the minimum and maximum value of GDP that are present in a PostGIS column, for example through CQL, and then uses that information to colour the map?

share|improve this question
    
you might want to read through this question: gis.stackexchange.com/questions/34302/… –  tomfumb Jul 8 '13 at 23:21
    
Have you figured this out? –  Plux Jan 9 at 12:58

2 Answers 2

Following Dynamic SLD styling - unique colours for linestrings I would suggest adding a "color value" column to your postGIS table is the easiest solution. The column should always be updated with respect to the current range of GDP values. Then, you might access it in your SLD with a PropertyValue in the CssParameter tag.

share|improve this answer
    
Thanks for your answer. My concern is that it just doesn't seem very clean to hardcode this, mixing raw data and formatting instructions in the same table. Also, it may be desirable to modify colour scale at runtime. –  user18285 Jul 8 '13 at 20:51

I don't know much about PostGIS, but would it be possible to make a view out of your table which generates a column that contains either a colour value or perhaps some sort of calculated percentile that you could then use to style. This would then technically keep your Raw data away from data used to style it. For example, I'm sure you could (don't ask me how, I'm an Oracle man) add a new column in your view called something like GDPPercentile, which would be 100 for whatever row had the highest value, 0 for whatever had the lowest value, and the values in between for everything else. From that you could use GeoServer SLDs Comparison Operators to assign colours to various percentile ranges, using <PropertyIsGreaterThanOrEqualTo> and <PropertyIsLessThan> ranges.

I hope that makes sense (it does in my head, but articulating it was a whole different story). Like I said, I don't know anything about the capabilities of PostGIS, so it might not be possible.

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.