Tutorial #1 - Crime analysis. How to conduct statistic analysis and visualize data on a map¶
Lampyre lets you easily process big volumes of data and conveniently shapes statistic info for easy studying and further analysis. It provides you with a set of tools for building graphs of different connection types and with a feature of overlapping all aggregated results over a map or a timeline. All this considerably saves time when you have a lot of analytical tasks, no matter your area of expertise.
Now we will make a statistic analysis of criminal activity in Los Angeles since 2010 and of real estate data costs in the same city. We will also correlate the results and show you what we can get from it.
We'll be working with location info and see how such data may be visualized and filtered on and by a map.
In Lampyre you can work with any structured data by uploading it into the system or by obtaining it with the help of different requests.
In our case we'll be working with offline data, which was obtained from open sources.
As it will be uploaded into the system manually, we launch Lampyre in the standalone mode. To do this we tick this checkbox in the system start up window.
In order to start working you have to create an investigation or to open a previously created one. You can do this with start "List of requests" window.
Also you can use the “File” main menu. All the tools for creating a new or opening an existing investigation are there in the context menu.
Alternatively you can click this button in the quick access toolbar in the upper part of the main window or use hot keys (Ctrl+Shift+N).
Now that our investigation is created we can start uploading. Our data is a csv table file which is ready to be imported.
We go to the "Windows" main menu and then choose “Import”. In the pop up window we select our file.
It can be imported either into repository or just into our investigation. If you import into repository the data will be available to work with in all your investigations.
In this pop up window, apart from the file or multiple files to import, you can also set some import parameters.
Our file was successfully imported. By double clicking it in the Import window we open it in a table mode:
In the "Windows" main menu we choose "Content" which opens the "Content" window with statistics on this table data.
Let's filter our data by time, and work only with crimes commited in 2018 to get more relevant results. In the Date_Occurred column header we click the filter sign:
Then we go to the "Text filters" tab, we set the filter to "Ends with 2018" and click ok. So this way we'll be working only with data of year 2018.
Let's save the filtered data as a new table by pressing Ctrl+N hot key combination on your keyboard.
Now we switch to the "Explorer" window (for example by choosing it in the "Windows" main menu) and rename this new table into Crimes2018. We can rename it 3 different ways:
We click the new table, then press F2 and edit its name.
Or we right-click it and choose Rename in the context menu.
Or we click the table once, to select it, and then click it one more time to make it editable.
Now we'll be working with this new table. In the "Content" window, we see different statistics. We can easily see the figures for the crimes involving, For example, vehicles and 26-year old women.
To make it more comfortable - From the "Content" window or from the table itself we drag the Crime Code Description column into the "Wizard" section, which is in the upper part of the "Content" window:
Then we combine columns Victim Age and Victim Sex in the "Wizard", into a so called tuple condition: by dragging them there the same way. Note that the tuple condition requires dropping the 2nd column right after the 1st one.
These figures are the statistics for this tuple condition:
Now we'll pick some crime type: in the Crime Code Description we right-click the BURGLARY FROM VEHICLE and choose refine in the context menu. The table is filtered by this crime type, and of course the statistics is changed.
Now let's expand the full list by clicking "More" to the right of our tuple filter condition. You can click it multiple times until you see everything that is there.
We see that there were 207 crimes of this type against 26-year-old women. We click 26; F in the list and choose "Show" in the context window.
Instantly we've got the corresponding data selected in the table.
If your data has coordinates, you can analyse it with the help of a map. Lampyre visualizes the geo-location.
We create a map by right-clicking our investigation name in the "Explorer" window and by choosing "New GIS Map" in the context menu:
For our convenience let’s place our table under the map. We choose our table in the tabs here and drag it down. A pop-up menu appears which let’s you choose where to place your tab.
We choose the area that we need and drop the tab.
Now when we're working with the map we'll use the cross-module feature and work with the same data in different visualization modes. In this case by clicking on table rows we see the same data visualized on the map.
If we select all the rows in our table, on the map we'll see a polygon area inside which all the incidents of the selected rows occurred. So we press Ctrl+A on our keyboard and get an area where 26-year-old women were robbed off their bicycles in 2018.
The cross-module feature also works the other way around - when you select an area on your map, the appropriate data in your table will be selected as well. We click the rectangle button in map window menu to activate this selection tool:
And with it we select some area on our map by holding the mouse button. When we release the button we see that the data in our table has changed:
Also with the help of the "Wizard", which we previously used in the "Content" window, we can find, for example, the crimes with the biggest number of weapon types used.
Similar to the way we did with our "tuple" condition, we’ll do the same with columns Crime Code Description and Weapon Description but create a so called "group" condition.
For this we drag the Crime Code Description to the "Wizard" and then we drag there the Weapon Description column, but we drop it into the square area next to the Crime Code Description, not after it.
As a result for each Crime Code Description value we get the number of unique Weapon Description values.
In a similar way, let’s take a look at the events of our current interest both in the table and on the map. We right-click the created group condition and choose "Show" in the context menu.
As you see the data in the table changed right away. Next, holding the left mouse button we can select some values in the table. As we do this we see that the area, corresponding to these selected values, is selected on the map.
With the help of this statistics it’s easy to find out which area has the highest criminal activity but it would be more efficient to see the position of these areas on the map.
To complete this task let’s import a .kml file with shapes which set the borders of the districts of the city under our analysis. In the map window menu we click this sign and upload the file:
We got the districts layered on our map. Now we select the shapes of our district layer to create an aggregation layer by the quantity of crimes: hold the Alt button and click once on the selected area on the map, or click the needed layer - LA - in the "Explorer" window.
This is what we get:
Now let's change the opacity of the imported layer. We open the "Properties" window, then we double click the LA layer in the "Explorer" window. We can change the "Background colour" and "Opacity".
Now for the selected districts we'll make an aggregation layer by the quantity of crimes. For this in the map menu we click this button , then from the crimes2018 drop-down list we choose "Quantity".
After this, in the "Explorer" window we untick "Shapes" and tick the aggregation layer:
This is what we get:
In our case colour palette indicates in what city district there were more crimes. Blue means less crimes, red - more. The most criminal district in 2018 is the one highlighted in red.
Now let’s get back to our cross-module feature again: when selecting a certain district on the map, the incidents of this district are selected in the table.
Now let’s add to our investigation some data on the real estate prices in different districts of the city.
To make our work easier we’ll change the colour of the previously created aggregation layer into red. In the "Explorer" window we tick this layer.
Then we open the "Properties" window and change the "Color" parameter into red. We’ll pick the colour from the "Custom" palette.
Here is our result.
In the "Explorer" window the system also indicated the change of colour:
We open the "Import" window and upload 3 new files of the same structure and kind into our investigation. We select all files at once and choose to unite them. Also we ask the system to upload only unique rows of your tables, deleting the repeated ones.
We wait till the files are processed by the system.
We click our uploaded data result in the "Import" window and open this data in a table.
Now let’s create an aggregation layer by the average price value. We open the appropriate pop-up window by clicking the layer creation button in the map menu. We choose the real estate file and create an aggregation layer by price value.
We see that one more layer appeared in the "Explorer" window.
And we see the corresponding result on the map.
As in our case we have 2 layers on the map - by average price and by number of crimes - their colours overlap. So to see what we have clearly, we change the colour of the new layer. Let’s also downsize the boarder thickness and opacity of all our layers.
In the "Explorer" window we select the aggregation by price layer, then in the "Properties" window we change its colour into blue. We choose colour from the "Custom" palette.
Now in the Explorer window, holding the Ctrl key, we select both aggregation layers:
We open the "Properties" window and change the "Border thickness" from 5 to 1:
This is what we get as a result:
We see that the brighter our blue is the more expensive the estate is. The brighter the red - the higher the level of crime.
This way we fulfilled our goal and as a result we see that the average real estate property prices are cheaper in the district with the highest crime level and vice versa as the red and blue areas do not intersect.
We can study in more details the statistical data on property, which is being sold in the district of the highest crime level.
We click the area highlighted in bright red and open the table with the real estate prices.
Now let’s see what crimes are committed in the districts with the most expensive estate. Click the bright blue district and open the table with crime data.
Thus we conducted data analysis and visualized the correlation between different data types with the help of a map and without creating any objects or links.
You can try this technique with any other data to fulfil your own analytical tasks.