QGIS D3 Date and Time Heatmap
This plugin consists of a D3 circular histogram heatmap using date, time, and custom categories in the data. It also has an experimental word cloud generator, but requires adding additional python libraries and uninstalling and reinstalling the pillow python library.
This creates a D3 circular histogram heatmap using date, time, and custom categories in the data. An optional legend can be included.
The plugin works by counting the number of date/time/category events using two axis and displays the results as a circular heatmap. It allows you to analyze the temporal distribution of data and how much of it exists across time, based on two frequencies.
This tab is for choosing the vector layer that will be used for generating the heatmap chart. Additionally, date and time fields are selected. A field representing a category can be specified and the axis of the resulting chart is configured.
dateutil.parser.parse
parser. The format of the string must match one of the supported formats used by dateutil
.Note that it is not necessary to have both date and time information. In this case, select either the radial box representing date and time in the same column or separate date and time columns.
The chart title, legend title, and the mouse over prefix can be configured on this tab.
Chart and legend settings for the heat map can be configured on this tab.
Chart Settings
Legend Settings
The legend will be displayed to the right of the chart and these are its settings.
These are settings for fine control over the heatmap color ramp and No Data Color
These examples make use of the 2006 Chicago crime data. In 2006 there were 367,968 crime incidents. That is a lot of crime during a year in just one city. Although this author is not trained in crime, some basic conclusions can be obtained by looking at the crime incidents based on the Month of the Year, Time of the Day, and Day of the Week. Here are the examples.
By looking at this graph one can make some observations. The least amount of crime occurs during the months of January, February and March. This is probably due to the cold. If that is the case, why does December have a high crime rate? That is probably because of the holiday season.
In this graph it appears that crime increases from 6pm to 11pm. The worst crime occurs from midnight to 1am. More difficult jobs must be taking place on the weekend where there is an increase of activity from 1am to 3am. During the day from Noon to 1pm there is also an increase of crime.
Here one can see a similar pattern. Crime is less during January, February, and March. Crime increases starting from about 6pm to 11pm and then from Midnight to 1am plans are executed. This graph also shows the increased crime from Noon to 1pm.
In this example the input data has been filtered by setting a QGIS filter for only certain types of crime. For this Example, right-mouse click on the Chicago crime layer in QGIS and select Filter then use the following filter:
"Primary Ty" IN ('THEFT','ROBBERY','OTHER OFFENSE','NARCOTICS',
'MOTOR VEHICLE THEFT','DECEPTIVE PRACTICE','CRIMINAL TRESPASS',
'BURGLARY','BATTERY','ASSAULT')
Set the following to:
This shows the resulting chart that is created.
These are experimental algorithms that generate word cloud images. They will not be available by default because the python worldcloud library needs to be installed. This is done by opening the OSGeo4W Shell and then running the command pip install wordcloud. You can then launch QGIS and the alogirhtms Word cloud from attribute and Word cloud from file will be added to the menu. If you get an error message when you run these algorithms that says “ImportError: The _imagingft C module is not installed”, you will need to run the command pip uninstall pillow and then pip install pillow. There seems to be some problem with the pillow library in QGIS. This requires system administrator privileges. On Windows find the OSGeo4W Shell in the Start menu. Right-mouse click on OSGeo4W Shell, click on More and then click on Open file location. Find the OSGeo4W Shell in the file browser window and right-mouse click on it and select Run as administrator. This will put you in administrator mode when you uninstall and reinstall pillow.
This algorithm generates a word cloud from one of the string attributes of a vector or table layer. It takes all of the attribute’s string values and generates a word cloud from them. The parameters are fairly self explanatory.
This is an example of the algorithm, run on the Natural Earth airport shapefile with the airport name field used as the selected attribute. The output file can be a PNG, TIFF, or SVG format.
This is the resulting output.
This algorithm generates a word cloud from all the words in a .txt file. This shows the processing algorithm configured to run on US Constitution.
This shows the resulting word cloud output generated from the US Constitution.