Tag Archives: OpenLayers

Nested proportional symbols in OpenLayers

For the visualising data from the SoilSCAPE in-situ network of soil moisture sensors I wanted to use proportional symbols, to provide a visual comparison of the soil moisture from different nodes. The data is received in real time, so I wanted the maps to automatically update and show the current soil moisture. Additionally, as there were three sensors attached to each node I wanted to use three circles, nested within each other, with a different colour for each circle, to show the current moisture for all three sensors, which made it slightly more tricky.

This is the final map for Tonzi Ranch.

To produce the maps three main components were used: OpenLayers, imagemagick, and a Python script running as a cron job.

Maps – OpenLayers

All the maps on the SoilSCAPE site use OpenLayers, which allows you to display a text file using:


    var gsat = new OpenLayers.Layer.Google(
        "Google Satellite",
        {type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22});

   // Read soil moisture sensor information (location, icon, description etc., from text file)
   var layer = new OpenLayers.Layer.Vector("Soil moisture sensors", {
        strategies: [new OpenLayers.Strategy.BBOX({resFactor: 1.1})],
        protocol: new OpenLayers.Protocol.HTTP({
    url: './all/all-points_sm.txt',
    format: new OpenLayers.Format.Text()
        })
    });

    // Add controls to map
    map = new OpenLayers.Map( 'map');

    // Add layers to map
    map.addLayers([gsat, layer]);
    map.addControl(new OpenLayers.Control.Zoom());
    map.addControl(new OpenLayers.Control.LayerSwitcher());
    map.zoomToExtent(mapBounds.transform(proj, map.getProjectionObject()));

The format for the text file is:

point	title	description	icon	iconSize	iconOffset
36.0021,-98.63108333	Node#101	Descriptions	icon.png	27	-2.5,-2.5

Real time updates – Python

The measurements from the sensors are sent to our lab via SMS and added to a MySQL database. The open layers text file is generated at regular intervals using a Python script to pull data from the database running as a cronjob. This approach is used to create maps of sensor status, with the link to the appropriate colour symbol saved in the open layers file based on the last received measurement. A description is also saved in the file with a link to a plot of measurements (also generated using a Python script running as a cronjob).

Symbols – imagemagick

To create the nested symbols imagemagick is used to create a different symbol for each node, by adjusting the size of three symbols and stacking them together. A Python script is used for this which can be downloaded from SoilSCAPE Utilities on Bitbucket. The script is run using:

python createPropSymbol.py outDIR outSymbolName.png Val1 Val2 Val3

To embed the maps within our Drupal site, an iframe is used.

More information about the SoilSCAPE project is available on the project website. Data can also be downloaded using the links at the bottom of each map. For more details on the wireless sensor aspect of the project see some of Agnelo Silva’s publications. The project is funded by NASA ESTO.