Mapping Crime Data in QGIS 3 - Two ways to map hotspots

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi there in this tutorial I'm going to take a look at how we can map and analyze crime data although you can also apply this technique to any point data set where you might want to examine hot or cold spots and identify patterns in the frequency of occurrence so I'm getting my data from database dot uk' which as you can probably guess is the UK police data download site and but obviously you can use your own crime data set or any other point data set that you you have available and what's worth it so I'm going to go here and click on their downloads link and I'm going to select do you know 2019 because it seems that not every study has their July data up at the time of me making this and we can select any one enforces I'm just going to select Greater Manchester Police for simplicity we could also choose whether we want the data about crimes outcomes stop and search I'm just going to download crime data and then click generate file so this should download data showing the occurrence of all crimes reported in June 2019 to Greater Manchester Constabulary so we can see this produces a folder which in turn contains a CSV file so that's a comma separated file that you can open in in Excel or any other spreadsheet software in fact we'll take a quick look just so we can see what the data looks like and we can see we have a crime ID the month where it's reported but importantly for mapping purposes we also have longitude and latitude which will allow us to map the occurrence a descriptive term for the location these are references to the UK's Office for National Statistics statistical areas if we wanted to map the murder and aerial angle and we also have the crime type and it does have some information even though I didn't take the outcomes box on the latest outcome since when I was to pinpoint the location of the crime and also look at different types of crime and compare patterns between different crime types so I'm actually going to copy this file from the zip file and I'm going to put it into my data folder so you gonna make a new folder called Chrome just to keep things nice and tidy and paste my CSV file in there now to get started on the mapping I'm going to fire up QGIS soak us as you may all know is a free and open source jazz package if you don't know anything about you Jess then please check out some of my earlier tutorials that cover all the basics of downloading setting up and getting started with with QGIS so I've dragged in and OpenStreetMap from the X Y Zed tiles largest to give us some context a bit of a base map and I can now go into my data folder which I've favorited and actually because this is a CSV file we could just drag it straight in doesn't always work as well as we'd hope sometimes it picks up columns is the wrong type of data so I'm actually going to use the data source manager here pick two limited text and go to my data crime and add the CSV file this way and if we look at geometry definition we can see that we've got put coordinates picked up now we need a latitude and cos in this case because it is latitude and longitude as we saw when we opened up the CSV file we're going to select wgs84 which is essentially latitude and longitude coordinates and we can then click that and we can see it now adds these points onto the map now one issue that I have with this is latitude longitude great plots the points filed but later on when we want to produce hotspots from this and we have to set some parameters linked to the point spaces and actually he uses whatever units are lower in I don't know about you but I found it pretty hard to think in degrees when I'm setting distances I'd much rather have it in meters yards whatever you work in so what I'm actually going to do next is to resize this as a ruler but convert it into a different coordinate system that works in meters so I'm going to right click on my point layer here go to export say features us I say well move it in the queue jsg and package format because it's quite a nice neat format and I'm going to change my solaris in my case to British National Grid because I'm working in the the UK and you can obviously identify the appropriate coordinate system for whatever area you're looking at if you're working in a different part of the world file name so I'm going to go see data back to micro file and I'm going to call this Chrome OS GB or don't serve a Great Britain which is the projection that I'm using for my my dataset not make a click ok and we now have appears to be an identical data set but is now in British National Grid rather than latitude and longitude coordinates so I'm going to remove the original layer and just for consistency I'm actually going to go down to the bottom corner here and change the projection it's being displayed in and also make that British National Grid as well we can see that the shape of the map changes slightly as a distorts the grid into British National Grid rather than the projection it was using previously ok so now we've got a mass of points covering the Greater Manchester area but that doesn't particularly tell us anything it's pretty confusing fortunately one of the great features of QJ s is that it allows us to create hotspot Maps without really having to do much work at all so he right-click on that Prime there go into properties symbology so you drop down here and change it to heat map I'm just going to click apply straight away I need to delete we've got a heat map for our data now it's not particularly useful partly because what we're seeing is pretty broad and also because the map is covering everything underneath it and we can talk about in a couple of hours we could change expand the layer rendering menu down here drag our layer opacity down to make it slightly see-through and we can start to pick up some details underneath and what I actually like to do so firstly I'm gonna change the color lamp that I'm using let's try magma so you know this helps highlight really highlight the hotspots we can see now much more easily at the centre of Manchester kind of stands out as a hotspot compared to the surrounding towns with smaller hotspots focused on some of suburban areas order much tail very pretty much any kind of boot up over the sensor appears to be a bit of a hot spot but how many masala growing up still isn't particularly great so what we can do is actually hit color up and make color one transparent and what this should do is actually mean the phony most values that are shown darker at the moment will become transparent there we go so we can now differentiate between no values and essentially no crime because he actually even living there it covers there are some gaps particularly within the the rural areas where there's not many people about now little things that we can play with is the radius so when we're creating hot spots its toilet to us how it kind of calculates those hot spots how smooth or detailed our hot spot map is now what I prefer to do by default it's doing it by screen units of of millimeters actually I'm going to click OK on that for a second just so we can zoom in and out of it and see how this looks so if I were to zoom more towards the center of Manchester we can see that it actually changes to set the points that are within our current view and we can see the almost kind of single points at this level individual crimes are showing up and we still have a hot spot around the center of the city and that's great if we just want to navigate round and explore and if we want to think things out but use figures to go in reports we might not want that display to change as we zoom in and out we might want to keep kind of consistent hotspots no matter what we do in terms of our display on the screen so if we want to do that we can go back into properties change our radius units to map units and this is why I changed our projection earlier from latitude longitude because I map units and our meters so rather than having to think in degrees which as I said it's pretty difficult for most people we can now think in meters so I'm going to set a radius and we can play around with this to see how it looks so I'm going to start off with a radius of 100 meters so we can see I've actually fallen and it was using already so this picks up quite fine detailed hotspots and if i zoom in and out now you can see because I've set it to map units actually that doesn't change as i zoom my display in and out so actually remember we're working maybe a hundred meters is a little bit too fine so let's try changing that to 250 meters okay so that's not seems to work a little bit better it certainly highlights the hotspot in Manchester City Center and we can just about make out some smaller hotspots in surrounding areas if we were to reduce that even more let's say 500 meters and it starts to look a little bit more like you did earlier on and actually some of these hotspots in the suburbs once again become a little bit clearer also if you're feeling that it looks a bit grainy on the screen we can change the rendering quality down here it will take a little bit longer to draw but sorry I dragged it to fastest so now it's gone very pixelated if I drag it up to best it will take longer to draw but should look much much smoother on the screen so I'm going to move it back down to the middle for now just to get that balance between speed and quality so in a nutshell that's how we can create some basic hotspot maps but everything just showing us in crimes it may be that what none of the things we want to do is actually to look at how hotspots differ between different types of crime so if we want to do that then we can go to source the source tab in our layer properties and go to this query builder option down here and what this actually allows us to do is to select subsets of our point layer so we could do a selection query export it as a new dataset but then with lots of different datasets it can be useful depending on what we want to do but if we're just doing this for display purposes one thing we could do is just create a quick query here so in my case I'm going to do crime type equals and we can get it to list by clicking your sample all over here the different options that we have different values we have within our crime type field so I'm going to start off by saying antisocial behavior the top one so if I click OK now and then to apply here we can see actually in this case we have a little change possibly because antisocial behavior makes up quite a high number of the the crime values that we're we're looking at so let's try something else that might look a bit more different say if I delete antisocial behavior reset that first say delete that ok I guess it redraws so try again crime type equals let's go for vehicle crime hopefully so as soon as I clicked ok there it did jump slightly so what we're highlighting now are the areas that have vehicle problem what you might notice if you were looking closely if you now have a bit more gap right around the city centre and that's because actually most people don't park right in the city centre it's probably pedestrianised but we now have a series of hot spots a little bit further out which probably identifying the main parking areas just on the outskirts of the city centre people parking over itself to get the train or the metro into the city centre and some of the other areas on the the outskirts of Manchester one of the slight issues that we have with displaying our hotspot this way is we don't actually have a scale so QGIS is kind of automatically generating or looking at where the data we have identifying the greatest density and the lowest density for uploads but it doesn't actually give us values which makes it quite difficult to compare different maps and datasets and it may well be that there's a lot fewer reports of vehicle crime than there were of anti-social behavior but because UJS is automatically scaling than those it's quite difficult for us to pick up so we may have to look at using some other tools if we want to be able to get that legend and we can do that using the processing toolbox and if we open up and processing tool box and start typing hot spots or heat map we'll see that one of tools we have is this heat map kernel density estimation now there are various ways of calculating hot spots and kernel density estimation is it's one of the most commonly used so we can plot this tool the settings are quite similar to the ones we were using in our layer settings to just display hotspots on the fly so we can select our point layer if we have a selection we can use selected features only once again we can set our radius so you can see that set to meters so I'm going to change that up to 250 the same as our display on the school we can set now pixel size which is obviously going to influence the quality of all the detail in the the output layer I'm actually going to reduce that slightly to let's say 5 meters just to speed things up a little bit if we won't we can actually set some some more advanced parameters but I'm not going to worry about those for the moment I'm just going to stick with the defaults which normally give us quite sir a nice heat map and obviously we can set the output so go into my crime folder again and you can see this is going to produce actually a raster layer so at this stage we're kind of converting from our original point layer into a raster hotspot layer and we're still set at the moment to vehicle current so I'm actually going to call my output layer vehicle crime and click run and we can see that if I turn off our region where we now have this new layer produced and this now does give us values for the density so we can see that in this case the maximum density and our radius was 250 meters is 9.2 9.3 vehicle crimes per 250 meter radius so if I want to compare this we can now go back into properties get back to source query builder so let's clear that query turn that back on we should see we now have slightly larger hotspots showing underneath and I can run this kernel density estimation tool again I'll use the same settings the same output resolution and call this one old crime and we can see it's now taking a little bit longer because there's a lot more points to look at when we're considering all crimes rather than just vehicle crimes so we'll give that a few seconds and there we go we now have our heat map for all crimes so if I just change the color scheme for our vehicle crime heat up just so we can distinguish between the two and we can now see the difference between the two layers if we wanted to we could once again add some transparency so we can kind of see one through the other and we can see okay this is along a bit backwards to not answer flip colorramp around here invert so that red indicates hotspots rather than blue and we can now see how actually all crime we have a hotspot around here but for vehicle crimes specifically it's spread a bit further out around the edge of the of the city centre and with that we can now program the settings you can select different types of crime try different mode uses and that should give you everything you need to really compare and identify the hotspots with different types of crime or as I said earlier and the other type of pull data where you want to to identify clusters one final little display trick that I quite like and you might notice and routes and Balaji options so I changed it to single band pseudo color to allow me to pick a color ramp and the memory option that can work quite well for displaying heat map later is actually hillshade so we'd normally use Hill shown for displaying elevation to pick up the the shape of the landscape but because we essentially have high and low points we can kind of represent these in pseudo 3d using the hill shade option now with local crime it's quite known all the maximum value is quite low so we may need to exaggerate that slightly to pick up the peaks for our real crime data you may have noticed our maximum density is much higher at two hundred and sixty six point seven compared to nine in a bit for vehicle crime data so if we tailor to represent that as a hill shade we should see immediately the peaks appear much much higher particularly around the center of of Manchester there and if we were to cut a bit of transparency to that we can now visualize underneath and pick up the peaks in our data favored lane on the the centre of Manchester and little bit of playing around and I said experimenting with the most appropriate radius setting for your particular data we can get some really quite nice visual displays picking out high-end low points or areas of high and low density within our within our data so maybe that's been useful if you did enjoy that please remember to Like and subscribe to the channel and check out some of our other videos thank you
Info
Channel: AMDGS
Views: 7,315
Rating: undefined out of 5
Keywords: crime, crime mapping, crime mapping using gis, crime mapping and hotspot analysis, qgis 3.8, GIS, how to map crime data, crime analysis, crime analysis GIS
Id: GbD2MGp_-9o
Channel Id: undefined
Length: 23min 34sec (1414 seconds)
Published: Fri Sep 06 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.