Safety App: Crime Prediction Using GIS
Safety App: Crime Prediction Using GIS
Safety App: Crime Prediction Using GIS
Proposed Architecture
Data from numerous open sources like news, open
Data, or through user input or web scraping knowl-
edge from the web site are going to be keep within
the information Server. At that time feature choice Figure 1: System Architecture
are going to be done on knowledge accessible within
the information. Once feature selection is finished, The safe route will be obtained by the difference
knowledge cleansing are going to be performed on of the Dijkstra formula, within which the nodes
knowledge to get rid of vociferous knowledge and within the network square measure assigned as a
chemical agent. Knowledge having great circle and mean weight that was obtained from the number of
latitude are going to be premeditated on the QGIS crimes for a particular purpose or geographical area.
server. Finally, the Prediction algorithmic rule can The values which will be generated from the math-
work on the given knowledge that is plotted within ematician formula mirror the chance of getting or
the MAP.[10] The output are going to be a map not an occurrence like “theft/crime.” etc. Or we can
accessible for the user on android Application and use a additional advanced formula for locating the
additionally for Agencies it’ll be accessible within shortest path are Highway/Route Hierarchies, A*
Path Finding formula.[15] The design approach is VII. Testing the application: User will upload the
to retrieving data from various sources that are re- images and rate the parameter on scale from 1 to 5.
lated to crime events, taking into account attributes Firebase provides developers with several advan-
that define the time and location when an event oc- tages, and file transfer with storage is one in all
curs. These data are analyzed and integrated with them. Uploading pictures from your android ap-
crime data from official sources (government insti- plication needs you to figure with Activities and In-
tutions). The integration process is automatically tents.
performed by using descriptions and spatiotemporal The user of the application uploads images of a par-
attributes of data.[6] The categorization and clas- ticular area as should below in figure(2).
sifying are carried out analyzing the spatiotempo- 2. Web Scraping: Web scraping is a process of au-
ral attributes and the description of words that ap- tomating the extraction of data in an efficient and
pear in the data available through various sources fast way. With the help of web scraping, you can
and/or official database records. Thus all the cat- extract data from any website, no matter how large
egorizedand classified knowledge ar used as input is the data, on your computer. Scraping from dif-
parameters forthe safe routing algorithmic program. ferent news websites related to crime will be done.
the ultimate result’s a saferoute that doesn’t cross Important data from the news will be added to the
or contain points with highcrime rates. database.
Following are the steps that actually takes place
when the program runs:
Techniques I.Import libraries
II.Set the URL you want to web scrape from
1. CrowdSourcing: The survey results clearly III.Connect to the URL
pointed to us that Lighting, Walk Path, Visibility, IV.Parse HTML and save to BeautifulSoup object
Security and Transport were the important 5 pa- V.To download the whole data set, we do a for loop
rameters. the particular area is rated based on the through all <a> tags
above 5 considered parameters and each one of the VI.Pause the code for a sec(To prevent ourselves
parameters can be rated in the index of 1-5, based from getting banned)
on what scale the parameter that is being considered Web scraping is a process of automating the ex-
is true. traction of data in an efficient and fast way. With
Thus, finally on the basis of rating, it will tell us the help of web scraping, you can extract data from
that the area on the right side has a much higher any website, no matter how large is the data, on
safety index than the area on its left thus making it your computer. Moreover, websites may have data
safer and less crime-prone. that you cannot copy and paste. Web scraping can
Steps for Uploading images and data in FIREBASE help us extract any kind of data that you want.[4]
database Following are the steps of performing web scrap-
I. Set Firebase Permissions: To allow your app ping :
access to Firebase Storage, you need to set up per- A. Open the website on which you want to perform
missions in the Firebase console. From your console, web scrapping and based on what kind of data you
click on Storage, and then click on Rules. want to extract start inspecting the particular el-
II. Create the Application: Open up Android Stu- ements from the console and try to figure out the
dio, and create a new project tags and attributes that are of relevance to your web
III. Set Up the MainActivity Layout: The appli- scrapping process.[4]
cation will need one activity layout. Two buttons B. Then Start by importing the python libraries
will be needed—one to select an image from your import requests
device, and the other to upload the selected image. import urllib.request
IV. Get MainActivity Up: Navigate to your Main- import time
Activity, and start by declaring fields. These fields from bs4 import BeautifulSoup
will be used to initialize your views (the buttons and The most important library here is the Beautiful-
ImageView), as well as the URI indicating where the Soup.
image will be picked from. Add this to your main Beautiful Soup is a Python library for pulling data
activity, above the onCreate method. out of HTML and XML files. It works with your
V. Uploading the File to Firebase: folder gets cre- favorite parser to provide idiomatic ways of navi-
ated automatically when the image is uploaded. Lis- gating, searching, and modifying the parse tree. It
teners are also added, with toast messages. These commonly saves programmers hours or days of work.
messages get displayed depending on the state of the To parse the html with BeautifulSoup so that we
upload. can work with a nicer, nested BeautifulSoup data
VI. Set Permission in the App: Finally, you need structure.
to request permission that your application will We use the method .findAll to locate all of our
make use of. Without this, users of your application required tags. We should include time.sleep(1) line
will not be able to browse their device gallery and of code so that we can pause our code for a second so
connect to the internet with your application. Do- that we are not spamming the website with requests.
ing this is easy—simply paste the following in your This helps us avoid getting flagged as a spammer.
AndroidManifest file From the news article from TimesofIndia paper
Figure 2: Web Scrapping Output
Implementation
This mobile application will be using Django as
backend, its flexible, stable and customizable. The
Backend API will have a simple model for Location,
Figure 7: Safety Index Analysis
Rating and Prediction object, which will have its
respective serializer class created using Django Rest
framework. The Backend API will also have respec-
Finally, we have come to a conclusion based on
tive API functions in views.py which will server re-
the research and the analysis we conducted is that
quests at end point. The Frontend Mobile Applica-
cities like Andheri, juhu and kurla are comparatively
tion is created using React Native. It works with
not very safe for the users.
Expo SDK and apps so testing the application is
convenient on mobile devices as well as simulator.
The Application fetches data from the server and
renders it to the view. In Short, this application
Result Analysis
will only be developed for Android, React Native is The Graph in figure (7) shows the plotting of Crime
powerful framework for building both iOS and An- committed at different time intervals in Mumbai
droid apps. city. Thus, from the graph analysis it is seen that
between 12AM to 12PM most of the crimes are com-
mitted.