This project has moved. For the latest updates, please go here.

Displaying variations in data obtained from postGIS database

Topics: SharpMap v0.9 / v1.x
Oct 17, 2009 at 8:13 AM


I need to display/render the variation in some data (polygon or line data) obtained from a PostGIS database, based on a certain condition (based on a value in a particular column in the database) using different set of colours.

What is the way to do it? How could I do the filtering operations?



Oct 17, 2009 at 11:51 AM

Hi supunmali, see jd

Oct 17, 2009 at 12:52 PM

Thank you very much, I didnt know its theming..  Is that means, if I am using custom theme, I need to get the dataset (from the database) and convert it into FeatureDataTable and need to go thru each row with a foreach loop?  

Thanks again

Oct 17, 2009 at 1:14 PM

Hi Supunmali, you do not need to loop through the table - you just provide a delegate which selects or creates the correct style based on the record and returns it.. The renderer takes care or looping and apply styles by itself.. hth jd

Oct 17, 2009 at 6:11 PM

Thank u so much Johndiss, it works really fine!!!!.


Thought of attaching what I did too.


 public void BuildingsBufferLayer()

	VectorLayer.DataSource = new SharpMap.Data.Providers.PostGIS(ConnStr, "vw_buffer_result", "the_geom", "id");
        SharpMap.Rendering.Thematics.CustomTheme myTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetBuildingStyle);
VectorLayer.Theme = myTheme; } private SharpMap.Styles.VectorStyle GetBuildingStyle(SharpMap.Data.FeatureDataRow row) { SharpMap.Styles.VectorStyle style = new SharpMap.Styles.VectorStyle(); if (row["id"].ToString()== buildingid) { style.Fill = Brushes.RoyalBlue; style.Outline = Pens.DarkBlue; style.EnableOutline = true; } else { style.Fill = Brushes.BurlyWood; style.EnableOutline = false; } return style; }



  VectorLayer.DataSource = new SharpMap.Data.Providers.PostGIS(ConnStr, "vw_buffer_result", "the_geom", "id");
            SharpMap.Rendering.Thematics.CustomTheme myTheme = new SharpMap.Rendering.Thematics.CustomTheme(GetThreatStyle);
            VectorLayer.Theme = myTheme;