def PlotRasterLithology(DataDirectory, fname_prefix, geol_raster='geol'): """ Make a hillshade and rasterise a geology shapefile and drape on the top. Uses the LSDPlottingTools libraries. https://github.com/LSDtopotools/LSDMappingTools Args: stream_order: the stream order of the profiles that you are analysing shapefile_name: name of the lithology shapefile geol_field: the field of the shapefile that has the lithology information Author: FJC """ import LSDPlottingTools as LSDP from LSDMapFigure.PlottingRaster import MapFigure # set figure sizes based on format fig_width_inches = 8 # some raster names raster_ext = '.bil' BackgroundRasterName = fname_prefix + raster_ext HSName = fname_prefix + '_hs' + raster_ext if not os.path.isfile(DataDirectory + HSName): # make a hillshade BM.GetHillshade(DataDirectory + BackgroundRasterName, DataDirectory + HSName) # create the map figure MF = MapFigure(HSName, DataDirectory, coord_type="UTM") #geology LithName = geol_raster print("The geology raster is" + LithName) MF.add_drape_image(LithName, DataDirectory, colourmap=plt.cm.jet, alpha=0.5, show_colourbar=False, discrete_cmap=True, cbar_type=int, mask_value=0) MF.save_fig(fig_width_inches=fig_width_inches, FigFileName=DataDirectory + fname_prefix + '_lith.png', FigFormat='png', Fig_dpi=300, fixed_cbar_characters=6, adjust_cbar_characters=False, transparent=True) # Save the figure
def PlotKsnFromSlopeArea(DataDirectory, fname_prefix, theta=0.45, cbar_loc='right', custom_cbar_min_max=[]): """ Make a plot of the slope area data with a fixed concavity """ import numpy as np print("Calculating ksn...") # read the csv and get some info df = pd.read_csv(DataDirectory + fname_prefix + "_slopes.csv") # now force a fit of ks based on this concavity area = df['drainage_area'].values slope = df['slope'].values ksn = slope / (area**(-theta)) df['ksn'] = ksn print(np.max(ksn), np.min(ksn)) print(ksn) df.to_csv(DataDirectory + fname_prefix + '_ksn.csv', index=False) # set figure sizes based on format fig_width_inches = 6 # some raster names raster_ext = '.bil' BackgroundRasterName = fname_prefix + raster_ext HSName = fname_prefix + '_hs' + raster_ext if not os.path.isfile(DataDirectory + HSName): # make a hillshade BM.GetHillshade(DataDirectory + BackgroundRasterName, DataDirectory + HSName) # create the map figure MF = MapFigure(HSName, DataDirectory, coord_type="UTM", cbar_loc='right', font_size=16) #MF.add_drape_image(BackgroundRasterName,DataDirectory,colourmap = 'gray', alpha=0.5) # add the ksn data ChannelPoints = LSDP.LSDMap_PointData(df, data_type="pandas", PANDEX=True) MF.add_point_data(ChannelPoints, this_colourmap='viridis', column_for_plotting='ksn', colour_log=True, zorder=100, show_colourbar=True, colourbar_location='bottom', font_size=24, colorbarlabel="log$_{10}(k_{sn})", manual_size=1.5, colour_manual_scale=[0, 1.8]) #plt.show() MF.save_fig(fig_width_inches=fig_width_inches, FigFileName=DataDirectory + fname_prefix + '_ksn.png', FigFormat='png', Fig_dpi=300, fixed_cbar_characters=6, adjust_cbar_characters=False, axis_style='Thin', transparent=True) # Save the figure plt.clf()
def PlotRasterLithologyWithClusters(DataDirectory, OutDirectory, fname_prefix, stream_order=1, geol_raster='geol'): """ Make a hillshade of the raster with the channels coloured by the cluster value. Rasterise a geology shapefile and drape on the top. Uses the LSDPlottingTools libraries. https://github.com/LSDtopotools/LSDMappingTools Args: stream_order: the stream order of the profiles that you are analysing shapefile_name: name of the lithology shapefile geol_field: the field of the shapefile that has the lithology information Author: FJC """ import LSDPlottingTools as LSDP from LSDMapFigure.PlottingRaster import MapFigure df = pd.read_csv(DataDirectory + fname_prefix + '_all_tribs.csv') cluster_df = pd.read_csv( OutDirectory + fname_prefix + '_profiles_clustered_SO{}.csv'.format(stream_order)) # set figure sizes based on format fig_width_inches = 8 # some raster names raster_ext = '.bil' BackgroundRasterName = fname_prefix + raster_ext HSName = fname_prefix + '_hs' + raster_ext if not os.path.isfile(DataDirectory + HSName): # make a hillshade BM.GetHillshade(DataDirectory + BackgroundRasterName, DataDirectory + HSName) # create the map figure MF = MapFigure(HSName, DataDirectory, coord_type="UTM") #geology LithName = geol_raster print("The geology raster is" + LithName) MF.add_drape_image(LithName, DataDirectory, colourmap=plt.cm.jet, alpha=0.5, show_colourbar=False, discrete_cmap=True, cbar_type=int, mask_value=0) clusters = cluster_df.cluster_id.unique() for cl in clusters: # plot the whole channel network in black ChannelPoints = LSDP.LSDMap_PointData(df, data_type="pandas", PANDEX=True) MF.add_point_data(ChannelPoints, show_colourbar="False", unicolor='white', manual_size=1.5, zorder=2, alpha=0.5) # plot the clustered profiles in the correct colour this_df = cluster_df[cluster_df.cluster_id == cl] this_colour = str(this_df.colour.unique()[0]) ClusteredPoints = LSDP.LSDMap_PointData(this_df, data_type="pandas", PANDEX=True) MF.add_point_data(ClusteredPoints, show_colourbar="False", zorder=100, unicolor=this_colour, manual_size=2.5) MF.save_fig(fig_width_inches=fig_width_inches, FigFileName=OutDirectory + fname_prefix + '_lith_clusters_SO{}.png'.format(stream_order), FigFormat='png', Fig_dpi=300, fixed_cbar_characters=6, adjust_cbar_characters=False, transparent=True) # Save the figure
def PlotElevationWithClusters(DataDirectory, OutDirectory, fname_prefix, stream_order=1, cbar_loc='right', custom_cbar_min_max=[]): """ Make a plot of the raster with the channels coloured by the cluster value. Uses the LSDPlottingTools libraries. https://github.com/LSDtopotools/LSDMappingTools Args: stream_order: the stream order of the profiles that you are analysing cbar_loc: location of the colourbar, can be right, top, bottom, left, or none. custom_cbar_min_max: list of [min, max] to recast the raster to for display. Author: FJC """ print("I'm plotting the elevation with channels coloured by cluster") df = pd.read_csv(DataDirectory + fname_prefix + '_all_tribs.csv') cluster_df = pd.read_csv( OutDirectory + fname_prefix + '_profiles_clustered_SO{}.csv'.format(stream_order)) # set figure sizes based on format fig_width_inches = 4.92126 # some raster names raster_ext = '.bil' BackgroundRasterName = fname_prefix + raster_ext HSName = fname_prefix + '_hs' + raster_ext if not os.path.isfile(DataDirectory + HSName): # make a hillshade BM.GetHillshade(DataDirectory + BackgroundRasterName, DataDirectory + HSName) MF = MapFigure(HSName, DataDirectory, coord_type="UTM", colourbar_location=cbar_loc) MF.add_drape_image(BackgroundRasterName, DataDirectory, colourmap='gray', alpha=0.5, colorbarlabel="Elevation (m)", colour_min_max=custom_cbar_min_max) # # create the map figure # MF = MapFigure(BackgroundRasterName, DataDirectory,coord_type="UTM",colour_min_max = custom_cbar_min_max) clusters = cluster_df.cluster_id.unique() for cl in clusters: # plot the whole channel network in black ChannelPoints = LSDP.LSDMap_PointData(df, data_type="pandas", PANDEX=True) MF.add_point_data(ChannelPoints, show_colourbar="False", unicolor='w', manual_size=1, zorder=2, alpha=1) # plot the clustered profiles in the correct colour this_df = cluster_df[cluster_df.cluster_id == cl] this_colour = str(this_df.colour.unique()[0]) ClusteredPoints = LSDP.LSDMap_PointData(this_df, data_type="pandas", PANDEX=True) MF.add_point_data(ClusteredPoints, show_colourbar="False", zorder=100, unicolor=this_colour, manual_size=2) MF.save_fig(fig_width_inches=fig_width_inches, FigFileName=OutDirectory + fname_prefix + '_elev_clusters_SO{}.png'.format(stream_order), FigFormat='png', Fig_dpi=300, fixed_cbar_characters=6, adjust_cbar_characters=False, axis_style='Thin', transparent=True) # Save the figure
def PlotHillshadewithClusters(DataDirectory, OutDirectory, fname_prefix, stream_order=1): """ Make a hillshade of the raster with the channels coloured by the cluster value. Uses the LSDPlottingTools libraries. https://github.com/LSDtopotools/LSDMappingTools Args: stream_order: the stream order of the profiles that you are analysing Author: FJC """ import LSDPlottingTools as LSDP from LSDMapFigure.PlottingRaster import MapFigure print( "I'm plotting a shaded relief map with the channels coloured by cluster" ) df = pd.read_csv(DataDirectory + fname_prefix + '_all_tribs.csv') cluster_df = pd.read_csv( OutDirectory + fname_prefix + '_profiles_clustered_SO{}.csv'.format(stream_order)) # set figure sizes based on format fig_width_inches = 8 # some raster names raster_ext = '.bil' BackgroundRasterName = fname_prefix + raster_ext HSName = fname_prefix + '_hs' + raster_ext if not os.path.isfile(DataDirectory + HSName): # make a hillshade BM.GetHillshade(DataDirectory + BackgroundRasterName, DataDirectory + HSName) # create the map figure MF = MapFigure(HSName, DataDirectory, coord_type="UTM") clusters = cluster_df.cluster_id.unique() for cl in clusters: # plot the whole channel network in black ChannelPoints = LSDP.LSDMap_PointData(df, data_type="pandas", PANDEX=True) MF.add_point_data(ChannelPoints, show_colourbar="False", unicolor='0.9', manual_size=2, zorder=1, alpha=0.5) # plot the clustered profiles in the correct colour this_df = cluster_df[cluster_df.cluster_id == cl] this_colour = str(this_df.colour.unique()[0]) ClusteredPoints = LSDP.LSDMap_PointData(this_df, data_type="pandas", PANDEX=True) MF.add_point_data(ClusteredPoints, show_colourbar="False", zorder=100, unicolor=this_colour, manual_size=3) MF.save_fig(fig_width_inches=fig_width_inches, FigFileName=OutDirectory + fname_prefix + '_hs_clusters_SO{}.png'.format(stream_order), FigFormat='png', Fig_dpi=300, fixed_cbar_characters=6, adjust_cbar_characters=False, transparent=True) # Save the figure