Community of MapPoint and Virtual Earth Users and Developers
This is a discussion on Creating Heat Maps with Virtual Earth and SQL Server 2008 within the Virtual Earth Blogs forums, part of the Blogs category; Introduction In my previous blog I described how to create thematic maps using Virtual Earth , SQL Server 2008 and ...
| |||||||
| Today's Posts | Twitter Feed | Register | Blogs | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| Creating Heat Maps with Virtual Earth and SQL Server 2008 In my previous blog I described how to create thematic maps using Virtual Earth, SQL Server 2008 and the UMN MapServer. While thematic maps are a powerful visualization when you analyze by fixed boundaries it is also often helpful to create heat maps based on geographic density. Heat maps are not only useful in a geographic context, they are also used for many other sorts of density analysis. According to Wikipedia a heat map in general is a graphical representation of data where the values taken by a variable in a two-dimensional map are represented as colours. Aside from geographic analysis heat maps are used for example as:
As Dylan explains, creating the heat-map is a 2 step process. First we have to create an intensity mask as a 256 grayscale image and then we translate each shade of gray into a colour. For more details have a look at Dylan’s blog. The intensity is determined by the density of points and to determine this density we create a grid and count how many points are in each cell of the grid. In order to do so we will pan and zoom the map to the area that we want to analyze. Next we determine some required parameters of the current map view.
Virtual Earth provides the necessary methods. The pixel-coordinates of the upper left corner in the map view are always (0, 0) and of the lower right corner they are (MapWidth, MapHeight). The method to determine the latitude and longitude for a pixel in the MapView is VEMap.PixelToLatLong. The width and height are the dimensions of the HTML DIV-element which hosts our VEMapControl. To determine the zoom-level we use the method VEMap.GetZoomLevel. With these information we will now create an AJAX-call to a Generic WebHandler. First we set up the grid. In my sample I have set the size of a grid-cell to 40 pixels but you can change this value of course. Since we are now using a generic web handler we can’t use the VEMap.LatLongToPixel method to determine the pixel-coordinates. However, the math is very well explained in this MSDN article on the Virtual Earth Tile System. In my sample code it is implemented in the function LatLongToPixel. We express all points as absolute pixels in the Virtual Earth pixel-coordinate system who’s origin - pixel (0,0) - corresponds to Latitude 85.05112878 and Longitude –180 in the WGS84 coordinate system. For more details see the article mentioned above. We start by determining the absolute pixel-coordinates of the upper left corner in the current map view and then set up a database connection to our source data which we want to analyze. While we loop through our data reader we convert each pair of latitude and longitude to a pixel-coordinate and assign it to a grid cell. Once we read all data from our database connection we have a grid and each cell has information about the pixel coordinates and the number of points in it. Now we will loop through the grid cells and create a heat point for each one and add them to an empty bitmap. This is the part where I re-use the code from Dylan Vester. As a result we will have a heat-map-image which matches the current map view in its size: The most simple way to create a Virtual Earth Tile Layer is to use the MapCruncher. We already generated our image and we have discussed 2 that we calculated the latitudes and longitudes of the upper left and lower right corner. To align the image in MapCruncher and project it for Virtual Earth we need at least 3 points. Therefore I extended the sample application and retrieve all 4 points of the bounding box of our map view (see 01_Generate_HeatMap.htm in the attached sample code). Now we load the image into MapCruncher and move the corners 1 by one underneath the crosshair in the left window. In the right window we paste the latitudes and longitudes for each map-correspondence point as determined above in the input-boxes for the Virtual Earth Position. Once we have at least 3 points we can lock the view and render the tiles (see 02_Overlay_HeatMap.htm in the attached sample code). As mentioned above the generation of the heat map uses the current zoom-level as 1 parameter which means that we are not working on a optimum level of detail when we zoom in if we follow the approach mentioned above. In order to be more dynamic it would be ideal to generate the heat map on the fly whenever we pan or zoom the map. A while ago I posted a blog which describes how you could generate dynamic tile layers from images through an ad-hoc tile-cutting service. I have recycled parts of that code in the 03_Dynamic_HeatMap.htm of the attached sample code. In order to reduce the number of AJAX-calls to our web handler we will introduce a threshold and only generate a new heat map if we pan for more pixels than the result is or if we zoom the map. Well, that’s it. you will find the sample code here. Technorati Tags: Virtual Earth,Heatmap,SQL Server 2008 ![]() ![]() Click here to view the article. Last edited by MapAdmin; 12-02-2008 at 08:19 AM.. |
![]() |
| Tags |
| 2008, creating, heat, maps, server, sql, virtual earth |
| ||||
| Posted By | For | Type | Date | |
| cvitacek's virtualearth Bookmarks on Delicious | This thread | Refback | 05-29-2009 12:17 PM | |
| Parts Mustang Skidsteer, Parts List Fpr A Piper Cherokee Pdf, Parts Of A Cell - Kawasakiklx | This thread | Refback | 03-07-2009 03:48 AM | |
| dev.live.com - How popular is dev.live.com? (://URLFAN) | This thread | Refback | 12-20-2008 04:55 PM | |
| The Magazine for MapPoint - MP2K Magazine | This thread | Refback | 12-01-2008 11:06 PM | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Creating Thematic Maps with Virtual Earth and SQL Server 2008 | Johannes Kebeck's Blog | Virtual Earth Blogs | 1 | 11-18-2008 07:26 PM |
| Virtual Earth & SQL Server 2008 - Part 4: Integrating SQL Server 2008 and Virtual Earth (4/6) | Johannes Kebeck's Blog | Virtual Earth Blogs | 0 | 03-03-2008 12:51 PM |
| Virtual Earth & SQL Server 2008 - Part 2: Spatial Data Management in SQL Server 2008 (3/3) | Johannes Kebeck's Blog | Virtual Earth Blogs | 0 | 03-02-2008 01:40 PM |
| Virtual Earth & SQL Server 2008 - Part 2: Spatial Data Management in SQL Server 2008 (2/3) | Johannes Kebeck's Blog | Virtual Earth Blogs | 0 | 03-02-2008 01:40 PM |
| Virtual Earth & SQL Server 2008 - Part 2: Spatial Data Management in SQL Server 2008 (1/3) | Johannes Kebeck's Blog | Virtual Earth Blogs | 0 | 03-02-2008 01:40 PM |
Madeira Holiday
Why not book a Madeira holiday through UlookUbook and enjoy this warm Portuguese island at a bargain price!