Skip to main content

Posts

Showing posts with the label KML

Using Google Charts with KML

In my last post , I showed how KML icon images could be utilised for proportional symbol mapping. Instead of loading a custom image, images can be requested from the URL based Google Chart API as shown below ( download KMZ ). These pie charts are generated on-the-fly. The dataset is the same I used for my OpenLayers and Google Chart mashup . The charts are scaled according to total population and the pie shows the age distribution for each country. If you click on a chart, you'll see a larger version in the balloon: Since the pie charts are loaded from an external service, the KMZ file is only 10 kB. There are some performance issues since around 200 pie charts are requested from the Google Chart API. I hope to see chart functionality as an integral part of KML and various geobrowsers in the future. The map is also viewable in Google Maps and Microsoft Live Maps (Virtual Earth). The KML IconScale element is not supported by these geobrowsers, so all pie charts have the s...

Making proportional symbols in KML

I would argue that KML and Google Earth supports reference maps (geographic features) much better than thematic maps (spatial patterns of a theme). Still, there are some workarounds, and this week I want to show three different ways of making proportional symbols in KML: icons, regular polygons and collada models. In this post, I want to focus on how to make proportional circles using the KML Icon element . This is the easiest and most efficient way to make proportional symbols. This map shows the population in each country of the world in 2005 (source: UNdata ). See this blog post for information about symbol placement and how they are mathematically scaled. A KML icon has to be an image. I hope vector support will be added in the next major KML version. A circle can be drawn using one line of SVG , and I think KML should support such basic shapes. Still, KML has powerful ways of styling icon images, and I've used these elements to create proportional symbols. I've made one ...

Generating map tiles with GDAL2Tiles

GDAL2Tiles is a command line tool that allows easy publishing of raster maps on the Internet. The raster image is converted into a directory structure of small tiles which you can copy to your webserver. GDAL2Tiles is included in GDAL/OGR 1.5.0 release. GDAL2Tiles is compatible with the Tile Map Service (TMS) Specification . TMS has been proposed as a standardised way in which map tiles are requested by clients and how servers describe their holdings. TMS is not an "official standard" and is currently managed by the Open Source Geospatial Foundation ( OSGeo ). The specification is based on multi-resolution image pyramids. Tile maps are composed of a set of scale-appropriate cartographic renderings, each divided up into regularly spaced image tiles. If the supplied raster map uses EPSG:4326 projection, GDAL2Tiles also generates necessary metadata for Google Earth ( KML SuperOverlay ). When the user is zooming or panning tile maps, only the tiles not currently in memory are r...

The polygon hole problem in Google Earth

When I’m watching my 3D choropleth maps in Google Earth, strange "holes" appear in polygons representing countries with low values on a statistical indicator (e.g. having a low altitude value). The map below ( KML ) shows the digital divide in the world (number of Internet users): The hole in India: KML has three parameters for controlling the behaviour of polygons; extrude , tessellate and altitudeMode . By setting altitudeMode to clampToGround , my country polygons follow the great circle and get a solid fill. The problem arises when I extrude the polygons by adding an altitude representing a statistical value. Only the vertices of the polygon are extruded to the given altitude, and not the centre of geometry. I miss a clampToAltitude option in KML. A shape should follow earth’s profile, at the requested height above the surface. There are some workaround to this problem: Give all polygons a minimum altitude to support a "flat roof". Has to be a high value for ...

The first thematic map examples

Now that we have world borders , a spatial database , some PHP code and statistics , - it's time to start the fun stuff: making thematic maps! I've started width choropleth maps (shaded polygons), and the first results can be seen by downloading this KML to Google Earth, or by looking at the images below. This screenshot from Google Earth is a visualisation of the world fertility (children per woman) 2000-2005. Darker colour means higher fertility. Afghanistan has the highest fertility in the world (7,5 children per woman). The data are unclassified, the countries are coloured according to their fertility value on a colour range. On this image, the fertility values are also represented by the height of the country polygons. I find it easier to see differences between countries by using this visualisation technique. View Larger Map KML is not the optimal format for choropleth mapping in Google Maps. My KML file was too big, so I had to generate a new showing only African c...

WKT to KML transformation

MySQL supports a few functions to convert geometry values between its internal format and either Well-Known Text (WKT) or Well-Known Binary (WKB) representations. An obvious missing feature is the possibility to retrieve data in the widely used GML format. The WKT format is defined in the OpenGIS Simple Features Implementation Specification for SQL and predates GML. This SQL query retrieves geometry as WKT from a MySQL table: SELECT iso2, name, AsText(geom) AS wkt FROM borders I had to store country boundaries as multi-polygons in my database, since many countries consist of several islands. Some of the polygons are complex (i.e. contains holes) because of enclaves. Since the WKT and KML formats are very different, it is not straightforward to do a conversion of complex polygons. This is an example of how a WKT to KML conversion can be done in PHP: // This function converts a representation of a // MULTIPOLYGON from WKT to KML function wkt2kml($wkt){ // Change coordinate format ...