flexigis_utils.py¶
Helper functions for FlexiGIS data abstraction.
- flexigis_utils.compute_area(dataset, width)[source]¶
Compute area for each line feature and return a dataframe object.
- Parameters
dataset (DataFrame) – OSM planet data
width (dict) – unique highway category as key and the width in meters as the value
- Returns
dataframe containing an “area” attribute
- Return type
DataFrame
- flexigis_utils.data_to_file(dataset, name='name')[source]¶
Write a dataframe to a csv/shape file.
- Parameters
dataset (DataFrame) – OSM planet data
name (str) – file name of the output csv file (eg. table_name)
- flexigis_utils.dbconn_from_args()[source]¶
Parse database credentials as environmental variables.
Get database connection from command-line arguments or environment ariables. Reuse environment variables from libpq/psql (see http://www.postgresql.org/docs/9.1/static/libpq-envars.html)
- flexigis_utils.get_csv_categories(destination, name='category_name')[source]¶
Get csv files from a folder (temp folder).
- Parameters
destination (str) – Path to categorised buildings csv files.
name (str) – The name of building type based on landuse category.
- Returns
dataframe of buildings in a landuse category
- Return type
pandas.DataFrame
- flexigis_utils.get_data_from_buildings(data_building, mask_data)[source]¶
Extract building for a landuse category.
- Parameters
data_building (GeoDataFrame) – building data.
mask_data (GeoDataFrame) – building/landuse intersects.
- Returns
dataframe of buildings in a landuse category
- Return type
pandas.DataFrame
- flexigis_utils.get_features(mask_landuse, res_intersects, select='category')[source]¶
Get features polygons.
- Parameters
mask_landuse (GeoDataFrame) – categories of building based on landuse
res_intersects (GeoDataFrame) – intersect between building and landuse
- Returns
GeoDataFrame of building/landuse intersects.
- Return type
pandas.GeoDataFrame
- flexigis_utils.get_intersects(data_building, data_landuse)[source]¶
Get intersects for between building category and landuse.
- Parameters
data_building (GeoDataFrame) – building data
data_landuse (GeoDataFrame) – landuse data
- Returns
GeoDataFrame of intersects between landuse and building.
- Return type
pandas.GeoDataFrame
- flexigis_utils.get_polygons(data, select='feature')[source]¶
Get building classification.
- Parameters
data (DataFrame) – OSM planet data
select (str) – building data feature (eg. apartment, farmhouse)
- Returns
GeoDataFrame of building category type
- Return type
pandas.GeoDataFrame
- flexigis_utils.mask_landuse_data(data_landuse, res_intersects)[source]¶
Mask intersections with landuse data.
- Parameters
data_landuse (GeoDataFrame) – landuse data
res_intersects (GeoDataFrame) – intersect between building and landuse
- Returns
GeoDataFrame of building/landuse intersects.
- Return type
pandas.GeoDataFrame
- flexigis_utils.shape_legend(node, ax, handles, labels, reverse=False, **kwargs)[source]¶
Plot legend manipulation. This code is copied from the oemof example script see link here: https://github.com/oemof/oemof-examples/tree/master/oemof_examples/oemof.solph/v0.3.x/plotting_examples
Contains helper functions for FlexiGIS data abstraction.