MapInfo Pro

 View Only

MapInfo Monday: Analyzing Density Hotspot Coverage

  • 1.  MapInfo Monday: Analyzing Density Hotspot Coverage

    Employee
    Posted 06-03-2024 03:06

    Two weeks back, I got a question from an analyst at the Metropolitan Police Service in London:

    "I would like to know how to work out what percentage of crimes fall within density hotspots in relation to all crime in a borough and what percentage of the borough area is covered by hotspots."

    I said, "Sure, I can give you a hand with that."

    And here we are!

    Happy #MapInfoMonday!

    In this article, I'll give you some tips on analyzing the input points against the hotspots from these points and comparing the hotspot map and input points to administrative or postal boundaries.

    The first step is, of course, having a density hotspot created from the input data points. Read more about this here: MapInfo Monday: Density Maps II

    You can see such a result below where my input data points have been selected using the blue area of interest polygon. That explains why the hotspot result is bound to the same blue polygon.

    Creating Vector Polygons from the density hotspot

    A density hotspot calculates how many "points" are within a given distance from each cell in the resulting hotspot map. The actual value assigned to each cell is also affected by the kernel used. The kernel is used to calculate "an importance" factor for each point found, often based on the distance.

    When you want to "determine" the extent of your hotspot map, you may want to set a threshold. This determines the value where you estimate that there is a higher number of events taking place.

    In the hotspot map above, for example, the blue colors describe values below 10. You can use the Advanced Colour option in MapInfo Pro to visualize the different thresholds.

    Here is a result where I have used the Transparent Clip Limits to hide the low values. In the Min Limit field under the Histogram, you can enter various values to see the effect.

    Here is a threshold or minimum value of 10.

    And minimum value of 40.
    And minimum value of 100.

    Maybe you have a value that you normally use when determining a density hotspot with a high number of events.

    In the example below, I'll use a threshold of 100.

    Using the Contour operation under Raster Operations on the Raster tab, I can convert my density hotspot map to a vector dataset for further analysis.

    I have specified a single interval, from my threshold of 100 to the maximum value. I have also configured Contour to create Regions, not Polylines.

    And, I have specified an output name for the vector dataset.

    You can also use the Resolution Level to control the resolution of the contour vectors. If you want a higher resolution, try changing the value to -1.

    In the map above, you can see the resulting vector dataset as blue polygons.

    Dataset Names

    I think it may be worth listing the datasets and the names I'll be using moving forward.

    • Crimes Table: This is the original point table with crimes or incidents used to create the hotspots
    • Hotspot: The raster table with density hotspots
    • Hotspot Polygons: The vectorized hotspots created as contours above.
    • Hotspot Crimes: This is a subset from the Crimes table of points within the Hotspot Polygons
    • Boundary Table: The table with administrative or postal boundaries

    Adding additional columns to the administrative boundary table

    Next, we need to add some additional columns to our boundary table. I am using some postal sectors, but you can use output areas, boroughs, or other administrative boundaries. The process is the same.

    I'm adding three columns to analyze the crimes:

    ·         Crimes, Integer: A full count of crime incidents inside each boundary.

    ·         Hotspot_Crime, Integer: A count of crime incidents inside the density hotspots inside each boundary.

    ·         Hotspot_Crimes_Pct, Float: The percentage of crimes inside the density hotspots compared to the total number of crimes inside each boundary.

    I'm adding three additional columns to analyze the density hotspot coverage.

    ·         Area_sqm: The area of each boundary in a chosen unit. I'm using square meters.

    ·         Hotspot_Area_sqm: The total area of the density hotspot polygon inside each boundary in a chosen unit. Use the same units as above. 

    ·         Hotspot_Area_Pct: The percentage of the density hotspot area inside the boundary compared to the total area of each boundary.

    Analyzing Crime Points

    Let's start by updating each boundary with the number of crimes inside each boundary.

    Use Update Column to perform this task. First, select the boundary table and the Crimes column.

    Specify to read the value from your table with crime incidents, the point table used to create the hotspot.

    Click on the Join… button to ensure the join has been set correctly to Where object from table Crimes is within object from table Postal_Sectors.

    From the Calculate list, select Count which will count the number of points inside each boundary.

    We can use the same process to calculate the number of hotspot crimes for each administrative/postal boundary.

    First, we do however have to select all the hotspot crimes, which is the crimes that fall inside the hotspot boundary. We can use Select by Location to do this.

    Select your table of crime incidents in the Select objects from list and select your table holding the density hotspot boundary from the Compare to objects in list.

    In the Relation list, select Within.

    Uncheck all the options at the bottom of the dialog.

    When the query has finished the new query now holds the hotspot crime points, we want to count for each boundary.
    Again, use Update Column. Select the boundary table and the column Hotspot_Crimes. Also, make sure the Join is specified as above for all the crime incidents.
    Make sure to select the latest query table holding the result from the Select by Location query above. And again specify Count from the Calculate list.

    Feel free to save the changes to your table along the way.

    Finally, we need to calculate the percentage. As I also have some boundaries where the number of crime incidents is zero, I need to ensure I don't use these. You can manually select the records where the number of crimes or hotspot crimes is 0.

    Or you can run an update statement through the SQL window and include a condition as you can see below.

    I assign the column Hotspot_Crimes_Pct this value: Hotspot_Crimes / Crimes * 100 to calculate the percentage of hotspot crimes compared to the overall number of crimes. But the condition makes sure the calculation is only run for the records where the number of Hotspot_Crimes is larger than 0.

    Analysing Density Hotspot Area

    Now we want to analyse the area of the hotspot boundary compared to the total area of the administrative or postal boundary.

    First, let's update a column with the area of the boundaries.

    Again, we got Update Column. I select the Postal_Sector table and the column to hold the area, Area_sqm.

    I'm calculating the area in square meters but you can use any unit you prefer. Also whether you are using CartesianArea or (Spherical)Area depends on the data you have. If you are using lat/long-based data, use Area(). If you are using data in a projected coordinate system, use CartesianArea().

    Next step is to calculate the overlapping area between the boundaries and the hotspot boundaries.

    Again, we will use Update Column to perform this calculation. Select the table with boundaries and the column to write the calculated area to.

    Now select the table with the hotspot polygons and click on the Join… button to check the join condition. You need to ensure that it is set to where object from table Crime_hotspot_Countoru intersects object from table Postal_Sectors.

    Next select Propertion Sum from the Calculate list and from the Of: list select Expression to bring up the Expression dialog.

    Again, we are using a function to calculate the area of the hotspot polygons intersecting the boundary. As we have set it to calculate the Proportion Sum, the final result will be based on the overlap.

    With these two values calculated, we can calculate the percentage.

    I use the same process as above to calculate the percentage of density hotspot area compared to the total area of the administrative or postal area.

    With all the calculations done, we can now look at the result. In the browser below, I have sorted the result by the Hotspot_Crimes_Pct. The browser lists the postal sectors with the highest percentage of crimes within my specified hotspot boundaries.
    I hope this helps you out



    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------