Giter VIP home page Giter VIP logo

rcrimemap's Introduction

rCrimemap: The Next Generation of CrimeMap

![showcase](http://woobe.bitbucket.org/images/github/rCrimemap_showcase.png)
  • Note that rCrimemap is still raw and experimental. Check out my blog "Blend It Like a Bayesian!" for latest updates.
  • See my LondonR presentation for the history and motivation behind the development of 'CrimeMap' and rCrimemap.
  • This is essentially a self-learning project. I am only doing this for fun!

Introduction

(based on my useR! conference abstract)

The maturality and extensive graphical abilities of R and its packages make R an excellent choice for professional data visualisation. Previous work has shown that it is possible to combine the functionality in packages ggmap, ggplot2, shiny and shinyapps for crime data visualization in the form of a web application named 'CrimeMap' (Chow, 2013). The web application is user-friendly and highly customizable. It allows users to create and customize spatial visualization in a few clicks without prior knowledge in R (see screenshot below). Moreover, shiny automatcially adjusts the layout of 'CrimeMap' for best viewing experience on desktop computers, tablets and smartphones.

![ball](http://woobe.bitbucket.org/images/github/milestone_2013_11.jpg)

Following the release of rCharts (Vaidyanathan, 2013) and rMaps (Vaidyanathan, 2014), Chow built upon the original 'CrimeMap' and created a new package rCrimemap (Chow, 2014). Leveraging the power of JavaScript mapping libraries such as 'leaflet' via rMaps, rCrimemap allows users to create an interactive crime map in R with intuitive map controls using only one line of code. Both zooming and navigation are similar to what ones would expect from using a typical digital map (see screenshots below).

The availability of these packages means R developers can now easily overlay both graphcial and numerical results from complex statistical analysis with maps to create professional and insightful spatial visualization. This is particularly useful for effective communication and decision making.

Prerequisites

You will need the following packages and RStudio IDE version 0.98.501 (or newer).

require(devtools)
install.packages(c("base64enc", "ggmap", "rjson", "plyr", "dplyr"))
install_github('ramnathv/rCharts@dev')
install_github('ramnathv/rMaps')

Install rCrimemap

install_github('woobe/rCrimemap')

Credits

Changes

Version Release Date Comments
0.0.1 11/03/2014 Prototype for LondonR Demo. Raw and experimental.
0.0.2 14/03/2014 Using plyr::ddply instead of dplyr::summarise for one step (dplyr::group_by is unstable for multiple columns at the moment). As a result, it is slower but stable.
0.0.3 18/03/2014 Added function 'rcmap_quick()' for quicker map generation using reformatted JSON data of ALL crimes. Support period from 2010-12 to 2011-12 (I will continue to convert the rest and make them available in next version).
0.0.3 24/03/2014 Not a package update. All reformatted crime data (2010-12 to 2014-01) in JSON format has been uploaded to Bitbucket. Use rcmap_quick() function to take advantages of these datasets.

Using 'rcmap_quick()' to create self-contained interactive crime map!

Create an interactive crime map of ALL CRIMES using the function rcmap_quick().

m_quick <- rcmap_quick(period = "2014-01", map_size = c(1900, 1060), 
                       provider = "Nokia.normalDay", zoom = 7)
                       
[rCrimemap]: Downloading '2014-01-json.rda' from author's Bitbucket account ...
[rCrimemap]: Creating Leaflet with Heat Map ...
## Display the map in RStudio
m_quick
## Create a self-contained crime map
m_quick$save('mymap.html', cdn = TRUE)

Rendered Self-Contained HTML Examples:

  1. rCrimemap (2014-01, 1900 x 1060) Link
  2. rCrimemap (2014-01, 940 x 620) Link

Using 'rcmap()'

Note: This was my first attempt. The wrapper uses 'plyr' instead of 'dplyr' so it can be really slow. Try rcmap_quick() first :)

You can create interactive crime map using the function rcmap(). The function has the following arguments:

rcmap(location = "Ball Brothers EC3R 7PP", ## LondonR venue since 2013
      period = "2010-12",                  ## reformatted data from 2010-12 to 2014-01
      type = "All",                        ## type of crimes
      map_size = c(1000, 500),             ## resolution of map in pixel
      provider = "Nokia.normalDay",        ## base map provider
      zoom = 10)                           ## zoom level

LondonR Demo 1

library(rCrimemap)
m1 <- rcmap("Ball Brothers EC3R 7PP", "2011-08", "All", c(1000,1000),"Nokia.normalDay")
m1

Text Output:

[rCrimemap]: Downloading '2011-08.rda' from author's Bitbucket account ...
[rCrimemap]: Converting raw data into JSON format for Leaflet ...
[rCrimemap]: Creating Leaflet with Heat Map ...

[rCrimemap]: Summary of Crime Data Used and Leaflet Map ...

Point of Interest           : Ball Brothers EC3R 7PP 
Nearest Police Force(s)     : City of London Police Metropolitan Police Service 
Period of Crime Records     : 2011-08 
Type of Crime Records       : All 
Total No. of Crime Records  : 109653 
Map Resolution              : 1000 x 1000

Interactive Map Output in RStudioIDE:

Note: use the export to browser button (top left of map) to view the map in a browser.

Zooming:

Enjoy!

All feedback and suggestions are welcome!

rcrimemap's People

Contributors

woobe avatar

Watchers

James Cloos avatar Flavio Barros avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.