fn_map_gpsmart_output: Map the output of GP-SMART for an input crime and shortlisted...

View source: R/fn_map_gpsmart_output.R

fn_map_gpsmart_outputR Documentation

Map the output of GP-SMART for an input crime and shortlisted suspects

Description

Creates an interactive map showing shortlisted suspects' activity locations (nodes) within the user's set search radius of an input crime. Use htmltools::save_html() to save the output map as an html file.

Usage

fn_map_gpsmart_output(gpsmart_output, coordinate_system = 2193)

Arguments

gpsmart_output

A list with four elements, returned by running the function fn_gpsmart() with return_node_predictions set to TRUE:

suspects_ranked

A data frame with n rows = n suspects with nodes within the search_radius of the input crime, ranked by their maximum predicted crime probability.

node_predictions

A data frame with n rows = n suspect nodes within search_radius, including all node attributes and predicted crime probability per node.

input_crime

A data frame with 1 row and 16 columns created by fn_prepare_input_crime(), entered as input for fn_gpsmart().

search_radius

The search radius (in kilometres), entered as input for fn_gpsmart().

coordinate_system

CRS number for the coordinate system for the X and Y coordinates of the input crime and suspect node data. The default is New Zealand Transverse Mercator (2193).

Details

  • The function will return an error if there are no node predictions in gpsmart_output to map.

  • Requires an internet connection.

Value

An interactive map object that can be opened in the RStudio Viewer or an internet browser and saved as an html file for sharing. The map displays:

  • the location of the input crime (IC);

  • the activity nodes of all shortlisted suspects with nodes within the search_radius when running fn_gpsmart(), coloured by their predicted probability (as a percentile);

  • the search radius.

The user can:

  • pan and zoom to specific locations;

  • search (enter text or use drop-down menu) to filter nodes to a particular suspect(s) based on their identifier;

  • use a slider to limit the displayed nodes to those of the top x ranked suspects;

  • use tick boxes to limit the displayed nodes according to node_type and other node attributes used in fn_gpsmart() to calculate the predicted probability;

  • hover over a node to show the rank of the suspect;

  • click on a node to show a popup box with the suspect's rank and identifier, the node_type, and the node's values on the GP-SMART variables;

  • search for an address or place name.

Author(s)

Sophie Curtis-Ham

See Also

  • fn_gpsmart() creates the input object for this function.

Examples

## Not run: 
data(example_input_crime_raw)
data(example_input_suspects_raw)
gpsmart_output <- fn_gpsmart(
  input_crime = fn_prepare_input_crime(example_input_crime_raw),
  input_suspects = fn_prepare_suspect_data(example_input_suspects_raw),
  search_radius = 10,
  return_node_predictions = TRUE
)
fn_map_gpsmart_output(
  gpsmart_output,
  coordinate_system = 2193
)

## End(Not run)


Sophie-c-h/gpsmartr documentation built on April 13, 2022, 5:51 p.m.