brokenspoke_analyzer.core.analysis module#

Define functions used to perform an analysis.

brokenspoke_analyzer.core.analysis.change_speed_limit(output, city, state_abbrev, speed)#

Change the speed limit.

Return type:

None

brokenspoke_analyzer.core.analysis.create_synthetic_population(area, length, width, population=100)#

Create a grid representing the synthetic population.

Parameters:
  • area (GeoDataFrame) – area to grid

  • length (int) – length of a cell of the grid in meters

  • width (int) – width of a cell of the grid in meters

  • population (int) – population to inject in each cell

Returns:

a GeoDataFrame representing the synthetic population.

Return type:

GeoDataFrame

brokenspoke_analyzer.core.analysis.derive_state_info(state)#

Derive state information.

Returns the state abbreviation, the state fips, and whether the job information can be retrieved from the US census.

Return type:

Tuple[str, str, bool]

Examples:
>>> assert ("TX", "48", True) == derive_state_info("texas")
>>> assert ("ZZ", "0", False) == derive_state_info("spain")
brokenspoke_analyzer.core.analysis.osmnx_query(country, city, state)#

Prepare the osmnx.

Returns: the OSMNX query and its slugified version.

Return type:

Tuple[str, str]

brokenspoke_analyzer.core.analysis.prepare_city_file(output_dir, region_file_path, boundary_file_path, pfb_osm_file)#

Prepare the city OSM file.

Use osmium to extract the content limited by the polygon file from the region file.

Return type:

None

brokenspoke_analyzer.core.analysis.retrieve_city_boundaries(output, country, city, state=None)#

Retrieve the city boundaries and save them as Shapefile and GeoJSON.

Return type:

str

Returns:

the slugified query used to retrieve the city boundaries.

brokenspoke_analyzer.core.analysis.retrieve_region_file(region, output_dir)#

Retrieve the region file from Geofabrik or BBike.

Return type:

Path

brokenspoke_analyzer.core.analysis.simulate_census_blocks(output, synthetic_population)#

Simulate census blocks.

Return type:

None

brokenspoke_analyzer.core.analysis.state_info(state)#

Given a state, returns the corresponding abbreviation and FIPS code.

The District of Columbia is also recognized as a state.

Return type:

tuple[str, str]

Examples:
>>> assert ("TX", "48") = state_info("texas")
>>> assert ("DC", "11") = state_info("district of columbia")