You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 34 Next »

 

May 18, 2020 - This tutorial is still being actively edited. Please wait for this message to disappear before completing or printing, if you'd like to view it in its final form.


TABLE OF CONTENTS

This guide was created by the staff of the GIS/Data Center at Rice University and is to be used for individual educational purposes only. The steps outlined in this guide require access to ArcGIS Pro software and data that is available both online and at Fondren Library.The following text styles are used throughout the guide:Explanatory text appears in a regular font.
  1. Instruction text is numbered.
  2. Required actions are underlined.
  3. Objects of the actions are in bold.
Folder and file names are in italics.Names of Programs, Windows, Panes, Views, or Buttons are Capitalized.'Names of windows or entry fields are in single quotation marks.'"Text to be typed appears in double quotation marks."

The following step-by-step instructions and screenshots are based on the Windows 10 operating system with the Windows Classic desktop theme and ArcGIS Pro 2.1.3 software. If your personal system configuration varies, you may experience minor differences from the instructions and screenshots.

PART I: Install the R-ArcGIS bridge

Download R and RStudio

First of all, you need to download and set up R and RStudio (RStudio is a free integrated development environment for R).

R link (recommend to download R 3.2.2 or later): https://cran.mtu.edu/bin/windows/base/

R Studio link: https://rstudio.com/products/rstudio/download/

For both, accept all defaults in the installation wizard.

Prepare data on Houston crime statistics

Though you can Google search Houston crime GIS data and find the shapefile (with the link: https://cohgis-mycity.opendata.arcgis.com/datasets/hpd-nibrs-crime), it only contains around 4,000 cases, which is far from complete. As a remedy, we need to download the data from Houston Crime Statistics (with the link: https://www.houstontx.gov/police/cs/Monthly_Crime_Data_by_Street_and_Police_Beat.htm). For example, we can focus on the data of year 2020 till end of May (see the following screenshot).

 

Note that the data is in .xlsx format. We need to save it as .csv file and then geocode the addresses to make it a shapefile. You need to use credits for geocoding in ArcGIS Pro. For convenience, I have already downloaded the data (and cleaned a little in terms of addresses) and geocoded it into a shapefile. You can downloaded the .rar file attaced here houston-crime-sample.rar and proceed. Notice that, for simplicity, I only use the crime cases of the first 10 days of year 2020, that is, dating from January 1, 2020 to January 10, 2020 (I choose 10 days because the step in Part II using Create Space Time Cube by Aggregating Points requires at least 10 time step intervals (in this case, it requires at least 10 days if the time step interval is set as 1 day).

 

Create a new project in ArcGIS Pro
As mentioned above, download the houston-crime-sample.rar file.

Locate the downloaded file on your computer and extract its contents to a folder named houston-crime-sample in a location of your choice.

Open the houston-crime-sample and you will see houston-crime.gdb, the geodatabase which has crime data that you will add to a map.Start ArcGIS Pro.

Under New, click Map.

In the Create a New Project window, for Name, type Houston Crime Analysis. For Location, browse to and choose your houston-crime-sample folder. Uncheck Create a new folder for this project.

Click OK, then the project is created.

In the Catalog pane, on the Project tab, expand Folders and expand the houston-crime-sample folder. Expand the houston-crime.gdb geodatabase, right-click the Houston_Crimes_Sample feature class, and choose Add To Current Map.



As described above, this map shows locations where crimes occurred from January 1, 2020 through January 10, 2020 in the greater Houston area. This is only a small sample for crime analysis, but the general procedure is the same. You can apply this tutorial for larger data sets of crime statistics.

Install the R-ArcGIS bridge: automatical method/manual method
R-ArcGIS bridge is a useful tool for you to reading and writing data to and from ArcGIS Pro and R. Once it is installed, you can also begin running script tools that reference an R script.Here are two methods to install R-ArcGIS bridge, automatical or manual.

Automatical method:
On the ribbon, click the Project tab.Click Options.



In the Options pane, under Application, click Geoprocessing. In the R-ArcGIS Support section, select your desired R home directory. Notice that all versions of R that are installed on your computer will appear in the list. Select R 3.2.2 or a later version. For example shown in the screenshot below, I use R 4.0.1.



If you do not have the ArcGIS R integration package installed, next to Please install the ArcGIS R integration package, click Install package and choose Install package from the Internet. When asked to confirm the installation, click Yes, and when the installation is complete, click Close.If you already have the ArcGIS R integration package installed, next to Installed 'arcgisbinding' package version, click the Check for updates button and choose Check package for updates to ensure that you have the latest version of the package.
In the Options window, click OK. Click the Back button to return to the mapManual method:Sometimes it turns out error messages when installing the ArcGIS R integration pacakge. You can use the manual method describled as following.Go to this website: https://github.com/R-ArcGIS/r-bridge-install (actually you can also refer this tutorial for manual installation). Download the repository r-bridge-install-master.zip by clicking Code and then Download ZIP.Download the latest version of the arcgisbinding package in this website: https://github.com/R-ArcGIS/r-bridge/releases/tag/v1.0.1.239. As of writing, this is arcgisbinding_1.0.1.239.zip (this is the updated version by the end of June, 2020).Copy both zip files onto the directory of your choise. Extract the r-bridge-install-master.zip file. Place the arcgisbinding_1.0.1.239.zip into the same directory as the R Integration Python toolbox.Back to ArcGIS Pro, in the Catalog >Project pane, right-click Toolboxes > Add Toolbox and navigate to the location of the R Integration Python toolbox. Open the toolbox, which should look like the following screenshot:Run the Install R bindings script. You can then test that the bridge is able to see your R installation by running the Print R Version and R Installation Details tools

PART II: Basic statistical analysis

(Optional) Project the shapefile
It is optional because the shapefile I have prepared for you has already been projected. If you download the original data in .xlsx format and geocode addresses by yourself, you need to project the generated shapefile after geocoding addresses.

In the Geoprocessing pane, search Project in the Find Tools box and click Project to open the tool. Change the following parameters:

For Input Dataset or Feature Class, choose Houston_Crimes_Sample (or the name you created by your own for output feature class of geocoding addresses).

For Output Dataset or Feature Class, name it as Houston_Crimes_Sample_Projected as an example.

For Output Coordinate System, click the globe icon and choose Projected coordinate system > World > WGS 1984 World Mercator.

Click OK. It should look like the following:



Click Run in the right-lower corner and it starts projecting and will generate the projected feature class.

Aggregate point data by counts within a defined location
This step helps us understand the data further. Before starting the analysis, you need to aggregate crime counts by space and time. Aggregation reveals the spatial and temporal relationships in your data that may not have been visible previously. Specifically, aggregating allows you to summarize your crime points in space-time bins that combine the crimes that have occurred into counts by space and time increments of your choice.

Open the Geoprocessing pane, search Create Space Time Cube in the Find Tools box and click Create Space Time Cube By Aggregating Points to open the tool. Change the following parameters:

For Input Features, choose San_Francisco_Crimes.

For Output Space Time Cube, browse to your San-Francisco folder and name the output San_Francisco_Crimes_Space_Time_Cube.nc.

For Time Field, choose Dates.

For Time Step Interval, type 1 and choose Months.

For Time Step Alignment, confirm that End time is chosen.

For Aggregation Shape Type, choose Hexagon grid.

For Distance Interval, type 300 and choose Meters.


Analyze crime hot spots: One step forward


PART III: Enhance the dataset with additional attributes

Add additional attributes to the original dataset

Further prepare the dataset


PART IV (KEY SECTION): Conduct statistical analysis using R and ArcGIS Pro

Bridge your data into R

Calculate smoothed crime rates

Continue analysis in ArcGIS Pro

Identify areas with unusually high crime rates


PART V (KEY SECTION): Identify attributes that influence crime

Create a correlation matrix in R to evaluate attribute relationships






  • No labels