Dot Density Map of Cattle in Nebraska

By R.
County cattle population density, 1 dot = 100 head of cattle (source: USDA)

I'm writing a Python command-line program to generate dot-density shapefiles from OGR-compatible datasources. I used to generate dot-density maps in one shot using a custom Python script and Cairo to render data and base layers. But my workflow now is to generate the dots as a shapefile and render that using vfr.

This map was generated while writing that script and wasn't really my express purpose, but I had the data lying around and thought it might be interesting.

Dot density maps like this one are not wholly accurate representations of specific spatial locations but rather are aimed at representing relative densities. In this example, the cattle population of each county is represented using one dot for every one hundred head of cattle. The dots are placed within the county polygons randomly, but the result is useful for comparisons among counties and for identifying spatial patterns -- though one has to keep in mind the resolution and boundary effects.

Here's the lua file used with vfr to style the features for base and data layers:

-- default style
vfr_style = {
    stroke = {
        r = 127,
        g = 127,
        b = 127
    },
    fill = {
        r = 255,
        g = 255,
        b = 255
    },
    size = 1
}

-- per-feature styling callback
function vfrFeatureStyle(ftr)
    fstyle = {
        stroke = {
            r = 0,
            g = 0,
            b = 0
        },
        fill = {
            r = 255,
            g = 255,
            b = 255 
        },
        size = 1,
        label_place = 0,
        label_field = "name",
        label_fill = { r=255, g=0, b=0 }
    }

    if(ftr._vfr_layer == "necocatdots") then
        ltbrn = {r=219, g=142, b=107}
        fstyle.fill = ltbrn
        fstyle.stroke = ltbrn
        fstyle.size = 1
    else
        fstyle.stroke = {r=128, g=128, b=128}
        fstyle.fill = {r=255, g=255, b=255}
        fstyle.label_fill = {r=16, g=16, b=16}
        fstyle.label_place = 1
        fstyle.label_field = "COUNTY_NAM"
        fstyle.label_fontdesc = "Roboto Bold 12"
    end

    return fstyle
end