Showing posts with label CrimeStat. Show all posts
Showing posts with label CrimeStat. Show all posts

Sunday, March 8, 2015

Spatial Analysis with QGIS - Part I: Point Data

QGIS 2.8 Wien was released, so it is a good time to review QGIS's basic spatial analysis capabilities for vector data--starting with point data. We will also take a look at a few plugins and the SAGA and R processing toolboxes. Most of the functionality in QGIS is from Ftools, formerly a plugin, now part of base QGIS. There is also the MMQGIS plugin to examine vector data.

In addition, I will make a few recommendations for added features, or point you to another free or open source program that can be used in conjunction with QGIS or simply by importing and exporting data.

Nearest Neighbor Index
QGIS can calculate the nearest neighbor index to assess point clustering.  No p-value is given but the simple trick is to remember that large negative z-scores mean the points are clustered while large positive z-scores mean the data is more dispersed.
No p-values are given but remembering critical values/decision points,i.e. +/-1.65, 1.96,
is the easiest way to know if clustering is statistically significant.
Mean Center and Standard Distance
The mean center, an average of x- and y- coordinates, is an easy way to find the central feature and to examine spatial-temporal trends.  In the case below, the mean of all starting points, by year, for US tornadoes, 2000-2013. The data are grouped by UID, in this case a year variable.  It would be great to also be able to calculate a median center.  Data source: NOAA Storm Prediction Center.
  • In some years, the average was pulled slightly west or east.  Interestingly, the mean is pulled east in 2011, when there was a large 'outbreak' of tornadoes across the southeastern US.

The mean of all 'starting' points for US tornadoes, by year, 2000-2013.
Moreover, there are several point pattern analysis tools, including the standard distance--a measure of dispersion--in the SAGA Processing Toolbox.  More specifically the "Geostatistics" tool, contains a lot of useful functions that can be used.  The output can be  saved and displayed in QGIS.  The NOAA dataset already contains the length from start to end, but you could also calculate this by creating a distance matrix in QGIS.


The SAGA Geostatistics Toolbox in QGIS
Ripley's K
Ripley's K helps to determine clustering at different distances.  It can be implemented through the R processing toolbox in QGIS, using R's SpatStat package, or CrimeStat.

Heatmap
You can download the Heatmap plugin or use a built-in live/dynamic heat map when you go to style a layer.  For the latter, make sure to move the rendering slider to 'best' for a nice looking heatmap. Here is an example using the dynamic heat map to look at homicides in Philadelphia. Data source: OpenDataPhilly.   In future posts, we will also look at alternatives to heatmaps, like gridding/quadrat analysis.

QGIS has lot of neat options for styling vector data, including a dynamic heatmap
that changes as you zoom in and out.
 (Note: In ArcGIS kernel density tool (not to be confused with point density) remains separate from the base software and has to be purchased through the Spatial Analyst Extension).

Grouping Analysis
Lastly, grouping analysis can be examined using PostGIS, which allows for a wide variety of spatial queries using SQL, or CrimeStat.

Near future...
We will look at spatial analysis of line and polygon data as well joining points for analysis.

GME and ArcGIS
When using ArcGIS, be sure to check out the free windows-based program Geospatial Modelling Environment, or GME formerly 'Hawth's Tools," http://www.spatialecology.com/gme/.  GME has a long list of helpeful commands: http://www.spatialecology.com/gme/gmecommands.htm.

Tuesday, February 4, 2014

CrimeStat IV Released...Not Just for Crime Analysis...

CrimeStat IV was recently released, but you do not need to be a crime analyst to appreciate it or find it useful. CrimeStat is a lightweight piece of freeware with heavyweight analytical capabilities. 

Last year, I used CrimeStat to show different programs performing basic density analysis.  But, CrimeStat can really do a whole lot more!  CrimeStat IV boosts 60 different routines, so there is plenty of analytic power in this Windows-based program.

An abbreviated list of features:
  • Importing two files with X/Y coordinates
  • Creating a reference grid
  • Using different types of distance measurement
  • Measures of Spatial Distribution (Mean center, standard distance,etc.)
  • Spatial Autocorrelation Indices
  • Distance Analysis (Nearest neighbor, Ripley's K,...)
  • Hot spot analysis 
  • Spatial Modeling/Interpolation
  • Journey-to-crime analysis
  • Spatial Modeling (several types of regression models)
  • Time-series forecasting
First, CrimeStat is not a GIS.  For example, you cannot view, create, or edit spatial data or visualize any maps/GIS-related files within it.  Rather, it is a program that imports, conducts spatial analysis, and exports results for being imported into any GIS.

On the other hand, you can import GIS-related file types such as shapefiles, *.dbf files, and ASCII/delimited files (i.e. *.csv).  Once you have decided on what type of analysis you are going to run, be sure to read how to import your data.  Once past this minor obstacle, you will be free to conduct your analysis...for free!

CrimeStat's tabs make navigation easy.  The program opens to the Data Setup tab--which is a necessary first stop. Click to magnify the screenshot below.
Like many free and open source programs, learning on how to import your data is a crucial first step!  Understanding your projection, as always is also key, especially when moving the results back into a GIS.
The Spatial Description analysis tab shows the basic premise of CrimeStat.  After loading your data, the program makes the necessary computations and 'saves result to'/Saves output to a folder for importing into a GIS.
Since this is version 4.0, CrimeStat's documentation is well organized by type of analysis.  The website contains plenty of exercises and sample data to minimize.  I was a bit disappointed that a Quick Guide is actually more like previous' versions workbooks--and exceeds 200 pages.  I would recommend starting at Chapter 1 and reading each of the first few chapters on it own.  You can then move on to specific analytic chapters--as needed.  Still, all the documentation is in order. Lastly, you will find real world case studies by leading researchers.

In sum, pairing CrimeStat IV with a free GIS, such as QGIS, makes for a powerful and free combination!

Wednesday, April 10, 2013

CrimeStat & GME vs. ArcGIS: Kernel Density

Many spatial analyses begin with using kernel density in GIS.  In ArcGIS, kernel density is part of the Spatial Analyst Extension.  However, several viable alternatives exist.  For today's post, I chose two of the easiest to implement and the ones that I have had the most success with: CrimeStat and Geospatial Modeling Environment (GME), formerly known as Hawth's Tools. Note: For GME you will also have to have R installed and several spatial packages.  They are both free, so enjoy!

When using these different tools, keep in mind that there are different kernel functions. ArcGIS uses a quadratic estimation while CrimeStat and GME have several. Click on the image below to magnify it.   The maps show density analysis of Wifi spots in New York City.

I chose different kernel functions to highlight the intricacies of density analysis.  In addition, ESRI has a video on performing proper density analysis, which you should check out.

Crimestat is a lightweight program that is relatively straightforward.  GME requires more installation steps but uses a point-and-click interface to generate the density map. After installing GME and R, in GME, be sure to search and use r.setpath to link GME to R. In addition, in GME you can copy, paste, and edit code in the same window--an extremely helpful feature!

Notes: I have been rather frustrated with the kernel density implementation in GRASS and Quantum GIS--even after diving into the help pages and discussion boards.