[mapserver-users] Heatmap / choropleth from points attributes

Milo van der Linden milo at dogodigi.net
Sat Feb 26 11:15:28 EST 2011


Very nice example Tamas!

In my opinion there is only one extra step needed; a no-color
transparent section in the final image. Do you think this would also
be possible?

2011/2/23 Tamas Szekeres <szekerest at gmail.com>:
> Daniel,
>
> Not sure if that fully satisfy with your requirements but I've already done
> a similar task with the following steps:
>
> 1. Create a point data source (with attributes) from your points for example
> by using ogr_vrt, something like:
>
> <OGRVRTDataSource>
>     <OGRVRTLayer name="mypoints">
>         <SrcDataSource>ponts.csv</SrcDataSource>
>     <GeometryType>wkbPoint25D</GeometryType>
>     <GeometryField encoding="PointFromColumns" useSpatialSubquery="TRUE"
> x="lon83" y="lat83" z="attribute"/>
>     </OGRVRTLayer>
> </OGRVRTDataSource>
>
> 2. Use gdal_grid to create an interpolated grayscale image from the point
> data dource.
>
> 3. To colorize the raster create (or compute) a LUT for each color band by
> containing the following information:
>
> <LUT>[src value 1]:[dest value 1],[src value 2]:[dest value 2],...</LUT>
>
> A template of this vrt should look like this:
>
> <VRTDataset rasterXSize="{RASTERXSIZE}" rasterYSize="{RASTERYSIZE}">
>   <VRTRasterBand dataType="Byte" band="1">
>     <ColorInterp>Red</ColorInterp>
>     <ComplexSource>
>       <LUT>{LUT_RED}</LUT>
>       <SourceFilename>{SOURCEFILE}</SourceFilename>
>       <SourceBand>1</SourceBand>
>       <SrcRect xOff="{SRCXOFFSET}" yOff="{SRCYOFFSET}" xSize="{SRCXSIZE}"
> ySize="{SRCYSIZE}"/>
>       <DstRect xOff="0" yOff="0" xSize="{RASTERXSIZE}"
> ySize="{RASTERYSIZE}"/>
>     </ComplexSource>
>   </VRTRasterBand>
>   <VRTRasterBand dataType="Byte" band="2">
>     <ColorInterp>Green</ColorInterp>
>     <ComplexSource>
>       <LUT>{LUT_GREEN}</LUT>
>       <SourceFilename>{SOURCEFILE}</SourceFilename>
>       <SourceBand>1</SourceBand>
>       <SrcRect xOff="{SRCXOFFSET}" yOff="{SRCYOFFSET}" xSize="{SRCXSIZE}"
> ySize="{SRCYSIZE}"/>
>       <DstRect xOff="0" yOff="0" xSize="{RASTERXSIZE}"
> ySize="{RASTERYSIZE}"/>
>     </ComplexSource>
>   </VRTRasterBand>
>   <VRTRasterBand dataType="Byte" band="3">
>     <ColorInterp>Blue</ColorInterp>
>     <ComplexSource>
>       <LUT>{LUT_BLUE}</LUT>
>       <SourceFilename>{SOURCEFILE}</SourceFilename>
>       <SourceBand>1</SourceBand>
>       <SrcRect xOff="{SRCXOFFSET}" yOff="{SRCYOFFSET}" xSize="{SRCXSIZE}"
> ySize="{SRCYSIZE}"/>
>       <DstRect xOff="0" yOff="0" xSize="{RASTERXSIZE}"
> ySize="{RASTERYSIZE}"/>
>     </ComplexSource>
>   </VRTRasterBand>
>   <VRTRasterBand dataType="Byte" band="3">
>     <ColorInterp>Alpha</ColorInterp>
>     <ComplexSource>
>       <LUT>{LUT_ALPHA}</LUT>
>       <SourceFilename>{SOURCEFILE}</SourceFilename>
>       <SourceBand>1</SourceBand>
>       <SrcRect xOff="{SRCXOFFSET}" yOff="{SRCYOFFSET}" xSize="{SRCXSIZE}"
> ySize="{SRCYSIZE}"/>
>       <DstRect xOff="0" yOff="0" xSize="{RASTERXSIZE}"
> ySize="{RASTERYSIZE}"/>
>      </ComplexSource>
>   </VRTRasterBand>
> </VRTDataset>
>
> 4. Use the gdal vrt driver (and gdal_translate) to create the final image
> (see an example attached).
>
>
> Best regards,
>
> Tamas
>
>
>
> 2011/2/23 Daniel Cole <daniel at southernsolutionsms.com>
>>
>> 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
>> _______________________________________________
>> 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
>
>


More information about the mapserver-users mailing list