I am trying to overlay a nominal variable (2 categories - rainfed vs irrigated) in a choropleth map over a numeric variable.

enter image description here

In order to highlight the difference in pattern among the two categories, I have outlined one category with a different color (irrigated areas in "red"), while the uncoloured ones are rainfed areas.

However, the map feels cluttered and the outline mixes with darker shades of the numeric variable.

I am trying to avoid using two different color shading schemes to represent the two categories as I feel that would hide the overall distribution of the underlying variable.

Is there a better way to represent this bivariate classification using the ggplots2 package in R (which I am currently using it for making the attached map)?

These maps are eventually going to be printed on paper.

  • Consider calculating euclidean distance on the irrigation area borders. More details here: gis.stackexchange.com/q/53163/8104
    – Aaron
    Commented Feb 24, 2014 at 13:39
  • @Aaron, thanks for the link, Directional shading might work for this, and I could use the buffer tool to draw those areas in R. My only concern though, would be the comparatively small size of the polygons which may get fudged by the broader outlines. I will try this out. Commented Feb 25, 2014 at 6:49
  • @varungoel123 I posted a R solution using the raster and rasterVis packages that might interest you. Commented Jan 15, 2019 at 21:51

2 Answers 2


Instead of outlines to indicate the irrigated areas you should use something like a transparent fill pattern (e.g. lines, hachures). An example would look similar to this:


or just google "map fill patterns" to get an overview of the options. Using outlines only for the irrigated areas would give the impression that irrigation is not a continous phenomenon.

  • That is a great suggestion. Is there a way to do this in ggplot2 or some other package in R? I have around 60-70 maps where the demarkation of rainfed vs irrigated areas remain constant. With ggplot2, I was able to automate the map production, something that I have not been able to achieve using ArcMap or Qgis Commented Feb 25, 2014 at 7:24
  • I am not familiar with ggplot2 or R. However this fill pattern is a fairly Standard thing and should not be too difficult to achieve. I know how to do that in Qgis or ArcMap. In both programs you can save that style once you defined it and reuse it. Automation should well be possible with both. A python script or arcpy could do the job for you.
    – Chris P
    Commented Feb 25, 2014 at 7:50
  • 1
    Unfortunately ggplot is not good at fill patterns (but see here for an alternative)
    – cengel
    Commented Feb 26, 2014 at 17:41
  • QGis in version 2.0.1 offers automated map production as well
    – Zbynek
    Commented Feb 27, 2014 at 8:29

I recently had to do a similar map. The solution I came up with uses the rasterVis package, rather than ggplot2 (which is an awesome package, by the way).

In my case, I had a map of trends over time (which is a numerical variable too) and also a map showing the significance of the trend (obtained from a statistical test).

In my case, I wanted to plot the significance map on top of the numerical map, something similar to a "stippling" pattern, to show where the confidence level was higher.

This is roughly the code that I used to create the map.


# Scratch raster objects
r1 <- raster(volcano)

over <- ifelse(volcano >=160 & volcano <=180, 1, NA) # This is the "mask" raster
r2 <- raster(over)

# And this is the key step:
# To convert the "mask" raster to spatial points
r.mask <- rasterToPoints(r2, spatial=TRUE)

# Plot
levelplot(r1, margin=F) +
layer(sp.points(r.mask, pch=20, cex=0.3, alpha=0.8))

In your case, you could change the code by:

1) creating a "binary" raster, where for example 0 is rainfed and 1 is irrigated, and plot it just like I've done or;

2) creating two different masks, one for rainfed and one for irrigated, and plot both of them as different objects (for example circles for rainfed and crosses for rainfed).

I think the second alternative would make the map look too visually "polluted", but you can always control the parameters of the points by consulting the sp package documentation - specifically ?sp.points.

Hope it helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.