crime_hotspots_uk.locations package

Submodules

crime_hotspots_uk.locations.constituincy module

class crime_hotspots_uk.locations.constituincy.Constituincy(names, title)[source]

Bases: crime_hotspots_uk.locations.generic.Locations

This class is used to hold a dataframe of constituincy boundaries and any relevant data. Any data pertaining to a perticular constituincy including demographics or political representation should be implemented here.

__init__(names, title)[source]

Initialise the class and import data

Parameters
  • names – A list of strings containing names of constituincies to search for

  • title (string) – A string representing what area the constiuincies represent. For instance London Mayoral Constituincies

The init function will get all constituincies with names starting with any of the items in names.

crime_hotspots_uk.locations.generic module

class crime_hotspots_uk.locations.generic.Locations(name)[source]

Bases: object

A template class that provide a generic structure for how location should be loaded in. The implementations of the functions should be overwritten or extended by each implementation but all implementations must follow this format.

This class is handler to a python dataframe that contains rows of shapely geometries that define individual areas.

__init__(name)[source]

This function is called when the class is initialised. It will set variables that will describe the data and then call the import function.

Parameters

name (string) – What the name of collection of locations is called. For instance Leeds constituincies. This should be human readable and provide a concise explanation of what the boundaries represent.

export(file_name='DEADBEEF')[source]

Export the current dataframe of locations to a .csv file. If no filename is passed the file will be exported to a cache directory depending on the name and type of the dataframe it comes from

Parameters

file_name (string) – What to save the file as

get_area(location_name)[source]

Returns a list of lists containing lon/lat coordinate pairs defining the boundaries of an area (it is a list of lists as some areas have islands and as such have to be defined by multiple boundaries) that has the name passed to this function

Parameters

location_name (string) – Name of the location to get the data for instance Leeds Central for the leed central constituincy.

exception crime_hotspots_uk.locations.generic.import_not_overwritten(message='Import function has not been overwritten')[source]

Bases: Exception

Exception raised when the generic import function is called. This normally means we haven’t yet finished implementing this particular location type

__init__(message='Import function has not been overwritten')[source]

Initialize self. See help(type(self)) for accurate signature.

exception crime_hotspots_uk.locations.generic.location_not_found(name, collection_name)[source]

Bases: Exception

Exception raised when the class is asked to find a location that is not in its datafreame

Parameters
  • name (string) – Name of the location it was trying to find (For instance Leeds North West)

  • collection_name (string) – Name of the class it was searching in (for instance Leeds)

__init__(name, collection_name)[source]

Initialize self. See help(type(self)) for accurate signature.

crime_hotspots_uk.locations.police module

Module contents