# How to implement multivariate hex bins?

I have two point datasets that I am analyzing and I wanted to implement a multivariate hexbin approach for displaying this data.

I have managed to cobble together an approach using QGIS SVG symbols but the primary problems is that this approach doesn't produce a map that can be viewed at multiple scales. For example, this view is at a 2:1 scale:

The spacing between the points looks good and it's possible to see the variation in size and color. However. if I zoom in, the relationship between the size of the points and the distance between the points becomes such that the image is much harder to interpret:

I have a two questions.

First, is there any way to implement a scale-based rendering for points in QGIS? I could see developing an approach where I had multiple layers of the same data with the point sizes varying and having certain layers display at certain scales, but I'm not sure how best to implement this.

Second, is there any way to implement a bivariate point in ArcGIS. I've had no luck using the multiple attributes options, but I might be missing something.

• Have you considered an R solution? Hexbin, perhaps?
– Aaron
Feb 18, 2013 at 15:43
• Aaron, I haven't tried this in R yet. I took a look at hexbin and didn't see any easy way to implement a bivariate mapping. But the other reason why I didn't go the R route is that ultimately I'm designing maps with this data and it seemed easier to stick to QGIS/ArcGIS. Feb 18, 2013 at 15:53
• Are the hexagons point symbols or polygons? Feb 18, 2013 at 17:32
• @underdark: I think scuerda is using symbols, judging from their sentence "I have managed to cobble together an approach using QGIS SVG symbols".
– Jake
Feb 18, 2013 at 19:47
• @Jake I'm mostly wondering about the grey borders in the screenshot Feb 18, 2013 at 20:39

There is an ESRI blog post on using hex bins here: Using a binning technique for point-based multiscale web maps

From the article, to create a hexagonal grid in ArcGIS you can use this Geoprocessing Sample: Create Hexagons

In ArcMap, if you have two variables you are looking to symbolize, you can use the "Graduated colors" option:

Set the first variable to your color ramp and the second to the point size option under Advanced -> Size. You can also set up an expression here to set an upper limit on the size of the symbol if needed, e.g.:

``````abs(([WINDSPEED]+100)/2)-abs(([WINDSPEED]-100)/2)
``````

Will take the lower of either `[WINDSPEED]` or 100.

To achieve fixed-scale rendering, set a reference scale on the data frame and ensure that the "Scale symbols when a reference scale is set" option is checked on the Display tab of your point layer.

• Fantastic. Worked like a charm. Feb 18, 2013 at 21:05

Ideally, this would be done by setting the size unit for the SVG point symbol to Map units (instead of millimetres). However, I haven't been able to apply a color ramp to SVG symbols.

As an alternative, you can use a polygon layer for the hexagons and use a negative buffer to decrease the size of the polygons depending on the data value.

So, to get a multivariate hexplot from scattered point data, you would proceed as follows:

1. Create a hexagonal grid that covers your data using the mmqgis Grid plugin.
2. Calculate the statistics of your point layer for each grid cell using Vector/Data management tools/Join attributes by location, using the grid layer as the Target and the points layer as the Join layer.
3. Use the attribute calculator to create a new field to be used for the buffer distance, using an expression like

``````-<Length> * (1 - <Field name>/<Maximum value of field name>)
``````

where `<Length>` is the buffer length by which you want to decrease the size of the element with the smallest value, `<Field name>` is the name of the field containing the variable of interest, and `<Maximum value of field name>` is the maximum value of the variable of interest. That way, the hexagons with the largest values will keep their size.

4. Use the fTools Variable distance buffer to decrease the size of the hexagons based on the attribute you just calculated. By using a Segments value of 1, the shape of the polygons will not change, only their size.
5. Use a color ramp to visualize the other variable of interest.

• Jake, thanks for this solution. I'll give it a shot a bit later and report back. As for applying a color ramp to SVGs, it's tricky and had to be done manually. What I did was modify the svg file. Within the polygon tag, I inserted the following: fill="param(fill) #ff0000" stroke="param(outline) #00ff00" stroke-width="param(stroke-width) 10" Then, I used ColorBrewer to generate a color scheme which I applied to the classified data manually. Not the easiest approach and I think your proposal will work better. Thanks. Feb 18, 2013 at 15:46