Contour and Density Layers with ggmap
I am busy working on a project which uses data from the World Wide Lightning Location Network (WWLLN). Specifically, I am trying to reproduce some of the results from
Orville, Richard E, Gary R. Huffines, John Nielsen-Gammon, Renyi Zhang, Brandon Ely, Scott Steiger, Stephen Phillips, Steve Allen, and William Read. 2001. "Enhancement of Cloud-to-Ground Lightning over Houston, Texas". Geophysical Research Letters 28 (13): 2597–2600.
This is what the data look like:
I have already pre-processed the data quite extensively and use the geosphere package to add a column giving the distances from the centre of Houston to each lightning discharge. The ndays attribute indicates the number of days included in the data.
I want to plot the density of lightning on a map of the area around Houston. The first step is to get the map data.
My initial attempt at creating the map used the following:
And this gave a rather pleasing result. But I was a little uneasy about those contours near the edges: there was no physical reason why they should be running more or less parallel to the boundaries of the plot.
It turns out that my suspicions were well founded. After some fiddling around I found that if I changed the extent argument then I got to see the bigger picture.
You will also note here a different syntax for feeding the data into ggplot. The resulting plot shows that in my initial plot the data were being truncated at the boundaries of the plot.
Now at least I have more realistic densities and contours. But, of course, I didn’t want all of that extra space around the map. Not a problem because we can crop the map once the contour and density layers have been added.
And this gives the final plot, which I think is very pleasing indeed!