Skip to main content

Package of utilities for CTPS Model Data Explorer for TDM23

Project description

modxlib23

modxlib is a package of common functions, data, and classes used in the CTPS Model Data Explorer.

Version Identification

Function: get_version() - Returns version ID string of library.

Trip Table Management

TAZ "shapefile" Management

Summary: The class "tazManager" provides a set of methods to perform attribute queries on an ESRI-format "Shapefile" that represents the TAZes in the model region. The attributes are read from the Shapefile's .DBF file; other components of the Shapefile are ignored.

The Shapefile's .DBF file must contain the following attributes:

  1. id
  2. taz
  3. type - 'I' (internal) or 'E' (external)
  4. town - town name (upper case)
  5. state - state abbreviation, e.g., 'MA'
  6. town_state - town, state
  7. mpo - abbreviation of MPO name:
  8. in_brmpo - 1 (yes) or 0 (no)
  9. subregion - abbreviation of Boston Region MPO subregion or NULL
  10. sector - 'analysis sector' as defined by CTPS's Bill Kuttner. Either 'Northeast', 'North', 'Northwest', 'West', 'Southwest', South', 'Southeast', 'Central' or ''; the empty string ('') indicates that the TAZ is outsize of the 164 municipalities comprising what was once known as the 'CTPS Model Region'.

An object of class tazManager is instantiated by passing in the fully-qualified path to a Shapefile to the class constructor. Hence, it is possible to have more than one instance of this class active simultaneously, should this be needed.

Class tazManager
Methods:

  1. init(path_to_shapefile) - class constructor
  2. mpo_to_tazes(mpo) - Given the name (i.e., abbreviation) of an MPO, return a list of the records for the TAZes in it
  3. brmpo_tazes() - Return the list of the records for the TAZes in the Boston Region MPO
  4. brmpo_town_to_tazes(town) - Given the name of a town in the Boston Region MPO, return a list of the records for the TAZes in it
  5. brmpo_subregion_to_tazes(subregion) - Given the name (i.e., abbreviation) of a Boston Region MPO subregion, return a list of the records for the TAZes in it
  6. sector_to_tazes - Given the name of an 'analysis sector', return the list of the records for the TAZes in the sector.
  7. town_to_tazes(town) - Given the name of a town, return the list of the records for the TAZes in the town. Note: If a town with the same name occurs in more than one state, the list of TAZes in all such states is returned.
  8. town_state_to_tazes(town, state) - Given a town and a state abbreviation (e.g., 'MA'), return the list of records for the TAZes in the town
  9. state_to_tazes(state) - Given a state abbreviation, return the list of records for the TAZes in the state.
  10. taz_ids(TAZ_record_list) - Given a list of TAZ records, return a list of only the TAZ IDs from those records.

Note: For all of the above API calls that return a "list of TAZ records", each returned 'TAZ' is a Python 'dict' containing all of the keys (i.e., 'attributes') listed above. To convert such a list to a list of only the TAZ IDs, call taz_ids on the list of TAZ records.

Utilities for the Transit Mode

Utilities for the Highway Mode

Utilities for Working with "Skims"

Dataframe and Geo-dataframe Utilities

Function: export_gdf_to_geojson(geo_dataframe, geojson_fn)

Summary: Export a GeoPandas gdataframe to a GeoJSON file.

Parameters:

  • geo_dataframe - GeoPandas dataframe
  • geojson_fn - Name of GeoJSON file

Return value: N/A

Function: export_gdf_to_shapefile(geo_dataframe, shapefile_fn)

Summary: Export a GeoPandas gdataframe to an ESRI-format shapefile

Parameters:

  • geo_dataframe - GeoPandas dataframe
  • geojson_fn - Name of shapefile

Note: Attribute (property) names longer than 10 characters will be truncated, due to the limitations of the DBF file used for Shapefile attributes.

Return value: N/A

Function: bbox_of_gdf(gdf)

Summar: Return the bounding box of all the features in a geo-dataframe.

Parameters:

  • gdf - a GeoPandas dataframe

Return value: Bounding box of all the features in the input geodataframe. The bounding box is returned as a dictionary with the keys: { 'minx', 'miny', 'maxx', 'maxy' }

Function: center_of_bbox(bbox)

Summary: Given a geomtric "bounding box", return its center point.

Parameters:

  • bbox - Bounding box in the form of a dictionary with the keys { 'minx', 'miny', 'maxx', 'maxy'}

Return value: Center point of the bounding box as a dictionary with the keys { 'x' , 'y' }.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

modxlib23-0.1.0.tar.gz (23.4 kB view hashes)

Uploaded Source

Built Distribution

modxlib23-0.1.0-py3-none-any.whl (23.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page