As part of their dissertation, an undergraduate student collected aerosol particle concentration data by strapping small sensors to mopeds that raced around the streets of Kigali.
The student was having trouble visualising the data. They wanted a map of particle concentration to get an overview of any hot spots of high particle concentrations.
However, the raw data they collected comes in tabular CSV format with lots of periferal information (instrument type, speed of vehicle etc..) - there are multiple devices measuring at different and overlapping times and locations.
TIMESTAMP
DATE
DEVICE_NAME
lat
long
alt
mph
pmsmallugm3
1.47E+12
07/09/2016 08:53
Dylos3
-1.94731
30.1025
1439.08
30.743
16.2
1.47E+12
07/09/2016 08:53
Dylos3
-1.94731
30.1025
1439.08
28.891
16.2
Example of raw data. I've removed other unecessary info from this example so it displays cleaner.
I wrote a script to grid the data as an average concentration by latitude and longitude and plot the output. The method I’ve used is by no means the best and I’d happily go back and improve the functionality. However for the task at hand it did the job. If you see any mistakes or have any ideas on how to improve the script I would be interested to hear what you think.
1. Clean data
First the data was read in and the unecessary data was discarded.
2. Calculate grid
Second, the grids were calculated. By defining the gridspacing, the resolution of the map can be changed. A smaller grid will contain less averaged data and so be less accurate. The data will also appear more sparse. A larger grid size may not be able to dispay the finer scale variation. The idea is to play with the gridspacing to balance these disadvantages. I would do this by eye, but if you know of a more objective way of deciding this value I would love to know.
3. Plot map
After the data has been manipulated it’s possible to make the plot.
4. Putting it all together
The functions are wrapped in a main function and a line to save the gridded data is squeezed in. The grid spacing chosen is 0.002 degrees in both directions, which at this latitude corresponds to ~ 315m2.
Output
The resulting map looks like this. The road network of the city is clearly visible and areas of hot and cold colours are also apparent.