[mapserver-users] Heatmap / choropleth from points attributes

pcreso at pcreso.com pcreso at pcreso.com
Wed Feb 23 13:41:13 EST 2011


Hi Daniel,

Points to voronoi for mapping is surely a chloropleth more than a heatmap? Colouring polygons by value? A heat map is generally done by rendering a surface generated from point data.

>From the original question I'm not sure if simply plotting coloured points on the map is required, or some sort of aggregation of the point data by polygon.

I _think_ the intent is to take sets of points, each within a polygon (field), generate a surface within each polygon based on the point values, then render each surface to form a heatmap (the rendered map thus comprising a set of polygons, each of which is represented by its own heat map) ???


For a more elegant GIS based approach, I'd use GMT to render a static map for a web page, which was the intent behind original question. Mapserver is more for dynamic/interactive web mapping.

See: http://gmt.soest.hawaii.edu/gmt/doc/gmt/pdf/GMT_Docs.pdf

For different ways of showing the values of points on a map see the examples on pages 120, 121, 138, 141, 144, etc. And there are many others with a tool this powerful (& complex) including generating & plotting surfaces derived from point data (for heat maps)

You write a script to build the map, much as in the p141 example, which shows how GMT can create a complex legend automatically as well, and run the script whenever a new or updated map is required.

The GMT list (IMHO) is a helpful & supportive as any mailing list I've encountered, even this one!!

A script which iterates through each field (set of points) generating each constrained surface and inserting it to a grid, then rendering the entire grid for your map output would do this pretty easily.

See the GMT docs for the commands surface for one way to generate each field of points as a grid, grdmath for how to merge these into one grid, & grdimage for how to generate the map from these gridded data. Or you could just render each field separately with grid points outside the field polygon set to NAN & rendered transparent.

Or throw all the points into a surface, render this as a single heat map & overlay the fields as transparent polygons (optionally labelled) with perhaps the regions between polygons masked if appropriate?

Lots of ways of generating such maps :-)

If you'd like some help going down this path, contact me off list.

Cheers,

  Brent Wood




--- On Thu, 2/24/11, Puneet Kishor <punk.kish at gmail.com> wrote:

From: Puneet Kishor <punk.kish at gmail.com>
Subject: Re: [mapserver-users] Heatmap / choropleth from points attributes
To: "Milo van der Linden" <milo at dogodigi.net>
Cc: mapserver-users at lists.osgeo.org
Date: Thursday, February 24, 2011, 6:23 AM

On Wed, Feb 23, 2011 at 04:28:31PM +0100, Milo van der Linden wrote:
> Turning points into polygons (or voronois) is the "thinking like a GIS
> professional" approach. This is valid, but not as good as it can get.
> Basically, using imaging techniques would be a better approach.

Very well put.

> 
> Perhaps you can take this: http://www.sethoscope.net/heatmap/ as a starting
> point? The author has created a nice python script to generate a heatmap.

And here is a Perl-based approach
[http://blog.imtrevor.com/2009/07/16/generating-heat-maps-using-perl/]


> 
> 2011/2/23 Josh Jordan <outerspaceman81 at yahoo.com>
> 
> > First, you have to turn your points into shapes, theres some algorithm that
> > will turn points into polygons with borders midway between each point.
> >  Then, you have to add classes to the mapfile.  Add one class per color.
> >  You have to calculate the bounds and color for each class like this:
> >
> > CLASS
> >     EXPRESSION(([POPULATION] gt 90457) AND ([POPULATION] le 108397))
> >     STYLE
> >       COLOR 10 20 50
> >     END
> > END
> >
> > If your CSV data isnt joined to the mapserver data, you have to calculate
> > what shapes are in each bucket like this-
> >
> > CLASS
> >     EXPRESSION(([NAME] = "Shape1") OR ([NAME] = "Shape2"))
> >     STYLE
> >       COLOR 10 20 50
> >     END
> > END
> >
> > --- On *Tue, 2/22/11, Daniel Cole <daniel at southernsolutionsms.com>* wrote:
> >
> >
> > From: Daniel Cole <daniel at southernsolutionsms.com>
> > Subject: [mapserver-users] Heatmap / choropleth from points attributes
> > To: mapserver-users at lists.osgeo.org
> > Date: Tuesday, February 22, 2011, 10:06 PM
> >
> > I am a new mapserver user and have spent countless hours over the last
> > month reading, trying code, etc. before posting here for help.  I am trying
> > to generate an image (non-interactive) on a webpage based off of attribute
> > data in a points file.  For example, 20 different points equally distributed
> > in a field contain data about the moister level of the soil.  I want to make
> > the lowest levels blue and the highest levels yellow, or something like that
> > with some gradients in between.  If possible I want it to have interpolated
> > data between them to show the gradual change, but that isn't a must.   I
> > also want to wrap it in a polygon that trims the edges.
> >
> > I found some python code that I thought might do the trick , but it seems
> > lots of heat maps are based off of how many points exist in a certain area,
> > and thats now what I am doing.
> >
> > My points contain numbers in the attributes, 5, 25, 92, 71, etc.   I feel
> > like I am missing some easy way to do this right in front of me with gdal or
> > something.  If someone has any direction or even demo code that would be
> > greatly appreciated.
> >
> > Thanks,
> >
> > Daniel
> >
> > -----Inline Attachment Follows-----
> >
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org<http://mc/compose?to=mapserver-users@lists.osgeo.org>
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >
> >
> >
> > _______________________________________________
> > mapserver-users mailing list
> > mapserver-users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/mapserver-users
> >
> >

> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users

_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20110223/7c5b35a6/attachment.html


More information about the mapserver-users mailing list