def plot_district_voronoi(voronoi_gpd: gpd.geodataframe.GeoDataFrame, area_name: str): fig, ax = plt.subplots(1, 1, figsize=(10, 10)) voronoi_gpd.plot(ax=ax) ax.set_title("Voronoi tessellation of " + area_name) ax.set_axis_off() plt.axis('equal') plt.show()
def plot_extreme_edges(gdf: gpd.geodataframe.GeoDataFrame, aoi: gpd.geodataframe.GeoDataFrame, **kwargs) -> None: """ Plots extreme depths along edges along with an overview map showing current plotted domain versus all other domains. :param gdf: :param aoi: :param \**kwargs: See below :Keyword Arguments: * *mini_map* (gpd.geodataframe.GeoDataFrame) -- Multiple domain perimeters. """ if 'mini_map' in kwargs.keys(): mini_map = list(kwargs.values())[0] fig, (ax_string) = plt.subplots(1, 2, figsize=(20, 8)) ax1 = plt.subplot2grid((1, 2), (0, 0)) aoi.plot(color='k', alpha=0.25, ax=ax1) gdf.plot(column='abs_max', cmap='viridis', legend=True, ax=ax1, markersize=16) ax1.set_title( 'Cell Locations with Depths > 1 ft\n(Check for Ponding)'.format( len(gdf)), fontsize=12, fontweight='bold') ax1.axis('off') ax2 = plt.subplot2grid((1, 2), (0, 1)) mini_map.plot(color='#BFBFBF', edgecolor='k', ax=ax2, markersize=16) aoi.plot(color='#FFC0CB', edgecolor='k', ax=ax2) ax2.set_title( 'Current domain (pink) compared to all domains (grey)'.format( len(gdf)), fontsize=12, fontweight='bold') ax2.axis('off') else: fig, ax = plt.subplots(figsize=(7, 7)) aoi.plot(color='k', alpha=0.25, ax=ax) gdf.plot(column='abs_max', cmap='viridis', legend=True, ax=ax, markersize=16) ax.set_title( 'Cell Locations with Depths > 1 ft\n(Check for Ponding)'.format( len(gdf)), fontsize=12, fontweight='bold') ax.axis('off')
def plot_descriptive_stats(stat_lists: tuple, aoi: gpd.geodataframe.GeoDataFrame, domain: str) -> None: """ Plots the descriptive statistics (Max, Min) for cell centers with the area of interest underneath. :param stat_lists: :param aoi: """ maximums, minimums = stat_lists # Plot descriptive statistics fig, (ax_string) = plt.subplots(1, 2, figsize=(20, 8)) ax1 = plt.subplot2grid((1, 2), (0, 0)) aoi.plot(color='k', alpha=0.25, ax=ax1) maximums.plot(column='max', cmap='viridis', markersize=0.1, legend=True, ax=ax1) ax1.set_title('Maximum Depth (ft)') ax2 = plt.subplot2grid((1, 2), (0, 1)) aoi.plot(color='k', alpha=0.25, ax=ax2) ax2 = minimums.plot(column='min', cmap='viridis', markersize=0.1, legend=True, ax=ax2, s=1) ax2.set_title('Minimum Depth (ft)') ax1.axis('off') ax2.axis('off') fig.suptitle('Depths at Cell Centers of Domain {}'.format(domain), fontsize=16, fontweight='bold')
def plot_district_boundary_on_osm_tile( district_gdf: gpd.geodataframe.GeoDataFrame, figsize: int, linewidth: float, zoom: int): """Gets the image tile corresponding to the bounding box of a district geo dataframe and plots the tile along with the district boundary. Args: district_gdf (gpd.geodataframe.GeoDataFrame): Geo dataframe of a district. figsize (int): The figure size of the plot, we assume that the length and breadth are the same. linewidth (float): Denotes the width of the line used in plotting the boundary of the district zoom (int): level of zoom to be used with contextily library to get the zoom detail on a map tile. """ district_ax = district_gdf.plot(figsize=(figsize, figsize), alpha=0.5, edgecolor='k', facecolor="none", linewidth=linewidth) return ctx.add_basemap(district_ax, crs=district_gdf.crs, zoom=zoom)
def plot_removed_values(faults: gpd.geodataframe.GeoDataFrame, vertices_out: gpd.geodataframe.GeoDataFrame, vertices_in: gpd.geodataframe.GeoDataFrame, radius: Union[float, int], **kwargs): """ Plotting the points that were kept and removed and traces of layer boundaries and faults Args: faults: GeoDataFrame containing the fault LineStrings vertices_out: GeoDataFrame containing the kept vertices vertices_in: GeoDataFrame containing the removed vertices radius: float/int indicating the radius of the buffer around faults Kwargs: color_vertices_out: str/color value for vertices_out color_vertices_in: str/color value for vertices_in color_fault_traces: str/color value for fault traces color_fault_buffer: str/color value for fault buffer """ # Getting the color for vertices_out color_vertices_out = kwargs.get('color_vertices_out', 'green') # Getting the color for vertices_in color_vertices_in = kwargs.get('color_vertices_in', 'red') # Getting the color for faults color_fault_traces = kwargs.get('color_fault_traces', '#1f77b4') # Getting the color for the fault buffer color_fault_buffer = kwargs.get('color_fault_buffer', '#adebad') # Checking that the color values are provided as strings if not isinstance(color_vertices_out, str): raise TypeError('Color values must be provided as strings') # Checking that the color values are provided as strings if not isinstance(color_vertices_out, str): raise TypeError('Color values must be provided as strings') # Checking that the color values are provided as strings if not isinstance(color_vertices_out, str): raise TypeError('Color values must be provided as strings') # Checking that the color values are provided as strings if not isinstance(color_vertices_out, str): raise TypeError('Color values must be provided as strings') # Checking that the faults are stored as GeoDataFrame if not isinstance(faults, (gpd.geodataframe.GeoDataFrame, type(None))): raise TypeError('Faults must be of type GeoDataFrame') # Checking that the faults are all of geom_type LineString if not all(faults.geom_type == 'LineString'): raise TypeError('All faults must be of type LineString') # Checking that the kept vertices are stored as GeoDataFrame if not isinstance(faults, (gpd.geodataframe.GeoDataFrame, type(None))): raise TypeError('Kept vertices must be of type GeoDataFrame') # Checking that the removed vertices are stored as GeoDataFrame if not isinstance(faults, (gpd.geodataframe.GeoDataFrame, type(None))): raise TypeError('Removed vertices must be of type GeoDataFrame') # Checking that the vertices are all of geom_type Point if not all(vertices_out.geom_type == 'Point'): raise TypeError('All vertices must be of type Point') # Checking that the vertices are all of geom_type Point if not all(vertices_in.geom_type == 'Point'): raise TypeError('All vertices must be of type Point') # Create buffer around faults faults_buffer = [ faults.loc[i].geometry.buffer(radius) for i in range(len(faults)) ] # Create GeoDataFrame from buffered entries faults_buffer_gdf = gpd.GeoDataFrame({'geometry': faults_buffer}, crs=faults.crs) # Create figure fig, ax = plt.subplots(figsize=(15, 15)) # Plot Faults faults.plot(ax=ax, aspect='equal', color=color_fault_traces) # Plot removed and kept vertices vertices_out.plot(ax=ax, color=color_vertices_out, zorder=5) vertices_in.plot(ax=ax, color=color_vertices_in, zorder=5) # Plotting the buffer around faults faults_buffer_gdf.plot(ax=ax, aspect='equal', color=color_fault_buffer, zorder=1) # Plot grid plt.grid() return fig, ax