Autogenerated Documentation for analysis package¶
BindColorMap module¶
Template which binds a colormap to a layer on a folium map. This will eventually be in folium, but is currently not implemented. It’s copied from here: http://nbviewer.jupyter.org/gist/BibMartin/f153aa957ddc5fadc64929abdee9ff2e
choropleth module¶
Functions that help create the mastermaps and other folium maps
-
TXHousing.analysis.choropleth.
categorical_choropleth
(gdf, factor, colors=None, quietly=False, weight=1, alpha=0.6, geometry_column='geometry', name=None, show=False, basemap=None)[source]¶ Creates categorical choropleth using tab10 spectrum
Parameters: - gdf – A geopandas geodataframe.
- factor – The feature you want to plot (should be categorical).
- colors – Colors to use in the categorical plot. If None, will generate colors using the tab10 colormap.
- quietly – If true, will not print anything. Defaults to False.
- weight – The weight in the style function. Defaults to 1.
- alpha – The alpha in the style function. Defaults to 0.6.
- geometry_column – The geometry column of the gdf. Defaults to ‘geometry’.
- name (str) – Defaults to None. If not None, will generate a FeatureGroup with this name and return that instead of the GeoJson object.
- show (bool) – Defaults to False. The show parameter for the FeatureGroup that the GeoJson will be added to.
- basemap (folium.Map) – Defaults to None. If not none, will add the GeoJson or FeatureGroup to the supplied basemap.
Returns: A folium geojson or featuregroup.
-
TXHousing.analysis.choropleth.
continuous_choropleth
(gdf, factor, layer_name, scale_name=None, weight=1, alpha=0.6, colors=['blue', 'green', 'yellow', 'orange', 'red'], quants=[0.16666666666666666, 0.3333333333333333, 0.5, 0.6666666666666666, 0.8333333333333334], method='log', round_method=None, show=False, geometry_column='geometry', basemap=None)[source]¶ Parameters: - gdf – Geodataframe
- factor – factor for analysis
- layer_name – Name of feature group layer
- scale_name – Name of scale
- weight – Weight
- alpha – Alpha of polygons
- colors – A list of colors to use in the colormap, defaults to [‘blue’, ‘green’, ‘yellow’, ‘orange’, ‘red’].
- quants – The quantiles to use to ‘switch’ colors in the colormap. Defaults to [1/6, 2/6, 3/6, 4/6, 5/6]. If you want a log-based or linear colorscale, adjust the ‘method’ parameter and set quants to None.
- method – The method by which the color scale is generated. Defaults to ‘log’, can also be ‘quant’ or ‘linear’. This parameter is overridden by the “quantiles” parameter.
- round_method – If you want to round the color scale to integer values, supply round_method = ‘int’
- show – Show by default on start
- geometry_column – ‘geometry’
- basemap – If not None, will add the colormap and a scale (bound together) to the baesmap as a layer.
Returns: GeoJson, Colormap
-
TXHousing.analysis.choropleth.
heatmap
(gdf, geometry_column='geometry', with_time=False, time_column='Year', name=None, show=False, basemap=None, **kwargs)[source]¶ Create a heatmap or a heatmap with time from a geodataframe of points.
Parameters: - gdf – Geodataframe with points as the geometry type.
- geometry_column – The geometry column of the gdf. Defaults to ‘geometry’
- start_color – The start color, defaults to ‘white’
- end_color – The end color, defaults to the MI blue
- with_time – If true, plot a heat map with time, not just a heat map.
- time_column – The column used to specify the years of the data, defaults to ‘Year’
- name (str) – Defaults to None. If not None, will generate a FeatureGroup with this name and return that instead of the GeoJson object.
- show (bool) – Defaults to False. The show parameter for the FeatureGroup that the GeoJson will be added to.
- basemap (folium.Map) – Defaults to None. If not none, will add the GeoJson or FeatureGroup to the supplied basemap.
- **kwargs –
kwargs to be passed onto the ‘heatmap’ or ‘heatmapwithtime’ folium constructors.
Returns: HeatMap object or FeatureGroup
-
TXHousing.analysis.choropleth.
make_marker_cluster
(gdf, make_centroids=True, points_column='geometry', fast=False, name=None, show=False, basemap=None, **kwargs)[source]¶ Makes a marker cluster from a gdf and potentially adds it to a map/feature group.
Parameters: - gdf (GeoDataFrame) – A geodataframe.
- make_centroids (bool) – If true and the geodataframe has polygon geometry, it will make the centroids and use those to make the marker cluster.
- or int points_column (str) – If make_centroids is False, will assume the pointa are in this column. Defaults to ‘geometry’.
- fast (bool) – If True, use a FastMarkerCluster as opposed to a regular MarkerCluster.
- name (str) – Defaults to None. If not None, will generate a FeatureGroup with this name and return that instead of the MarkerCluster object.
- show (bool) – Defaults to False. The show parameter for the FeatureGroup that the marker cluster will be added to.
- basemap (folium.Map) – Defaults to None. If not none, will add the MarkerCluster or FeatureGroup to the supplied basemap.
- kwargs – kwargs to pass to the FastMarkerCluster or MarkerCluster initialization
Returns: Either a FeatureGroup or a MarkerCluster.
-
TXHousing.analysis.choropleth.
polygon_layer
(gdf, color='blue', weight=1, alpha=0.6, name=None, show=False, basemap=None)[source]¶ Parameters: - gdf –
- factor –
- color –
- weight –
- alpha –
- name (str) – Defaults to None. If not None, will generate a FeatureGroup with this name and return that instead of the GeoJson object.
- show (bool) – Defaults to False. The show parameter for the FeatureGroup that the GeoJson will be added to.
- basemap (folium.Map) – Defaults to None. If not none, will add the GeoJson or FeatureGroup to the supplied basemap.
Returns:
mastermaps module¶
-
TXHousing.analysis.mastermaps.
add_zipdata
(ziplist, basemap, features=['Views Per Property (vs CBSA)', 'Hotness Rank ', 'Median Listing Price_sf', 'Median Listing Price_mf'], names=['Views Per Property (Mean-Centered)', 'Realtor Hotness Rank', 'Median Listing Price for Single Family Homes', 'Median Listing Price for Multifamily Homes'])[source]¶ Adds zipdata to a basemap.
Parameters: - ziplist – A list of zipcodes to add to the basemap
- basemap – The basemap to add to.
- features – List of features to graph from the realtor datasets.
- names – The names of the layers the features will be added on.
Returns: A ZipBoundaries object with Realtor data attached
-
TXHousing.analysis.mastermaps.
create_austin_mastermap
(save_path=None)[source]¶ Generates Austin Mastermap. Save path defaults to ‘Figures/Mastermaps/Austin_Mastermap_v2.html
zoning_graphs module¶
Graphs which mostly rely on zoning data
-
TXHousing.analysis.zoning_graphs.
add_counties
(ax, county_list)[source]¶ Given a matplotlib axis, adds texas county outlines to it
-
TXHousing.analysis.zoning_graphs.
map_broad_zones
(data, county_list, name, minlat, maxlat, minlong, maxlong, save_path, colordic=None, featurename='Base Zoning')[source]¶ Plots an actual map of broad_zones in a data source within the lat/long bounds. If you want to do this for Austin or Dallas, just use the map_broad_zones_dallas_austin wrapper.
Parameters: - data – A gdf including a geometry and base_zone column.
- county_list – A list of county outlines to plot on the data.
- name – A name to be used in titling the egraph.
- maxlat, minlong, maxlong (minlat,) – Bounds of the graph
- save_path – A path at which to save the map.
- colordic – Dictionary which maps broad_zones to colors.
- featurename – Used for the title of the graph. Graph title is {featurename} around {name}.
-
TXHousing.analysis.zoning_graphs.
map_broad_zones_dallas_austin
(plot_austin=True, plot_dallas=True)[source]¶ Wrapper for map_broad_zones, just plots them around austin/dallas.
-
TXHousing.analysis.zoning_graphs.
plot_broad_zones_proportion
()[source]¶ Plot proportion of broad_zones by distance from city center, excluding nonresidential and agricultural land.
-
TXHousing.analysis.zoning_graphs.
plot_hd_locations
(save_path='Figures/Zoning/HDLocations.svg', width=8, height=5)[source]¶ Graphs locations of historic districts in Austin, Dallas, Houston
-
TXHousing.analysis.zoning_graphs.
plot_minimum_lot_size
(savepath='Figures/Zoning/Minimum_Lot_Size_Residential_No_Agriculture.svg', width=10, height=8)[source]¶ Graphs average minimum lot size in Austin/Dallas.
Methodological note: this treats zones with no minimum lot size as having a minimum lot size of zero. It also includes areas zoned as non-single family, which we might want to exclude in the future.
permit_graphs module¶
Graphs which mostly rely on permit data
parcel_graphs module¶
Graphs which mostly rely on municipal parcel data. Note that all of these graphs rely on the cached parcel data in csv format, not the actual parcel data, which is processed and cached in the data_processing package.
-
TXHousing.analysis.parcel_graphs.
calc_parking_costs
(save_path='Figures/property_value_histogram.svg')[source]¶ Calculates average land costs within 1 mile of the city center in Austin, Dallas, Houston. Relies on cached municipal parcel data. These are a bit conservative figures because they use lot size instead of base area of the actual building.
-
TXHousing.analysis.parcel_graphs.
plot_percent_undeveloped
(save_path='Figures/Zoning/percent_undeveloped.svg')[source]¶ Calculates the percent of land which is undeveloped (using base_area features and area calculations) conditional on distance from city center and broad_zone. Based on cached municipal parcel data.
misc_calcs module¶
Graphs which mostly rely on municipal parcel data. Note that all of these graphs rely on the cached parcel data in csv format, not the actual parcel data, which is processed and cached in the data_processing package.
-
TXHousing.analysis.parcel_graphs.
calc_parking_costs
(save_path='Figures/property_value_histogram.svg')[source] Calculates average land costs within 1 mile of the city center in Austin, Dallas, Houston. Relies on cached municipal parcel data. These are a bit conservative figures because they use lot size instead of base area of the actual building.
-
TXHousing.analysis.parcel_graphs.
plot_percent_undeveloped
(save_path='Figures/Zoning/percent_undeveloped.svg')[source] Calculates the percent of land which is undeveloped (using base_area features and area calculations) conditional on distance from city center and broad_zone. Based on cached municipal parcel data.
-
TXHousing.analysis.parcel_graphs.
plot_singlefamily_lotsizes
(save_path='Figures/Zoning/sf_lotsizes.svg', width=10, height=8)[source] Plots average lotsizes of single family homes in Houston conditional on distance from city center. This uses cached municipal parcel data.
suburbs module¶
This file contains most of the graphing for the suburbs analysis. It does not rely on raw parcel data, but the cached versions instead.
-
TXHousing.analysis.suburbs.
analyze_land_use_by_metro
(name)[source]¶ Calculates mean and median lot size as well as the land use by municipality around Austin, Dallas, or Houston, then caches them in shared_data/calculations.