map2loop.fault_orientation.MapData#

class map2loop.fault_orientation.MapData(tmp_path: str = '', verbose_level: VerboseLevel = VerboseLevel.ALL)#

Bases: object

A data structure containing all the map data loaded from map files

raw_data#

A list containing the raw geopanda data frames before any modification

Type:

list of geopandas.DataFrames

data#

A list containing the geopanda data frames or raster image of all the different map data

Type:

list of geopandas.DataFrames

contacts#

A dataframe containing the contacts between units in polylines

Type:

geopandas.DataFrame

basal_contacts#

A dataframe containing the contacts between units labelled with whether it is basal or not

Type:

geopandas.DataFrame

filenames#

A list of the filenames/urls of where to find the data to be loaded

Type:

list of data source filenames

dirtyflags#

A list of flags indicating whether the data has been loaded or dirtied

Type:

list of booleans

data_states#

Enums representing the state of each of the data sets

Type:

intEnum

working_projection#

A string containing the projection e.g. “EPSG:28350”

Type:

str

bounding_box#

The bounding box in cartesian coordinates with 6 elements

Type:

dict

bounding_box_polygon#

The bounding box in polygonal form

Type:

shapely.Polygon

bounding_box_str#

The bounding box in string form (used for url requests)

Type:

str

config_filename#

The filename of the json config file

Type:

str

colour_filename#

The filename of the csv colour table file (columns are unit name and colour in #000000 form)

Type:

str

tmp_path#

The path to the directory holding the temporary files

Type:

str

verbose_level#

A selection that defines how much console logging is output

Type:

m2l_enums.VerboseLevel

config#

A link to the config structure which is defined in config.py

Type:

Config

The initialiser for the map data

Parameters:
  • tmp_path (str, optional) – The directory for storing temporary files. Defaults to “”.

  • verbose_level (VerboseLevel, optional) – How much console output is sent. Defaults to VerboseLevel.ALL.

__init__(tmp_path: str = '', verbose_level: VerboseLevel = VerboseLevel.ALL)#

The initialiser for the map data

Parameters:
  • tmp_path (str, optional) – The directory for storing temporary files. Defaults to “”.

  • verbose_level (VerboseLevel, optional) – How much console output is sent. Defaults to VerboseLevel.ALL.

Methods

__init__([tmp_path, verbose_level])

The initialiser for the map data

calculate_bounding_box_and_projection()

Calculate the bounding box and projection from the geology file

check_filename(datatype)

Check the filename for datatype is set

check_filenames()

Check all filenames to see if they are valid

check_map(datatype)

Check the validity of a map data from file

colour_units(stratigraphic_units[, random])

Add a colour column to the units in the stratigraphic units structure

export_wkt_format_files()

Save out the geology and fault GeoDataFrames in WKT format This is used by map2model

extract_all_contacts([save_contacts])

Extract the contacts between units in the geology GeoDataFrame

extract_basal_contacts(stratigraphic_column)

Identify the basal unit of the contacts based on the stratigraphic column

get_bounding_box([polygon])

Get the bounding box in dict or polygon form

get_colour_filename()

Get the colour lookup table filename

get_config_filename()

Get the config filename

get_empty_dataframe(datatype)

Create a basic empty geodataframe for a specified datatype

get_filename(datatype)

Get a filename of a specified datatype

get_ignore_codes()

Get the list of codes to ignore

get_map_data(datatype)

Get the data geopanda of the specified datatype

get_raw_map_data(datatype)

Get the raw data geopanda of the specified datatype

get_value_from_raster(datatype, x, y)

Get the value from a raster map at the specified point

get_value_from_raster_df(datatype, df)

Add a 'Z' column to a dataframe with the heights from the 'X' and 'Y' coordinates

get_working_projection()

Get the working projection

load_all_map_data()

Load all the map data for each datatype.

load_map_data(datatype)

Load map data from file, reproject and clip it and then check data is valid

load_raster_map_data(datatype)

Load raster map data from file, reproject and clip it and then check data is valid

open_http_query()

Attempt to open the http url and unzip the file if required Note: This is specific to opening remotely hosted dtm data in geotiff format

parse_fault_map()

Parse the fault shapefile data into a consistent format

parse_fault_orientations()

Parse the fault orientations shapefile data into a consistent format

parse_fold_map()

Parse the fold shapefile data into a consistent format

parse_geology_map()

Parse the geology shapefile data into a consistent format

parse_structure_map()

Parse the structure shapefile data into a consistent format

recreate_bounding_box_str()

Creates the bounding box string from the bounding box dict

save_all_map_data(output_dir[, extension])

Save all the map data to file

save_raw_map_data(output_dir, datatype[, ...])

Save the map data from datatype to file

set_bounding_box(bounding_box)

Set the bounding box of the map data

set_colour_filename(filename)

Set the filename of the colour csv file

set_config_filename(filename[, ...])

Set the config filename and update the config structure

set_filename(datatype, filename)

Set the filename for a specific datatype

set_filenames_from_australian_state(state)

Set the shape/dtm filenames appropriate to the Australian state

set_ignore_codes(codes)

Set the codes to ignore in the geology shapefile

set_working_projection(projection)

Set the working projection for the map data

set_working_projection_on_map_data(datatype)

Set the working projection on the GeoDataFrame structure or if already set reproject the data

update_filename_with_bounding_box(filename)

Update the filename/url with the bounding box This replace all instances of {BBOX_STR} with the bounding_box_str

update_filename_with_projection(filename)

Update the filename/url with the projection This replace all instances of {PROJ_STR} with the projection string

calculate_bounding_box_and_projection()#

Calculate the bounding box and projection from the geology file

Returns:

dict, str – The bounding box and projection of the geology shapefile

check_filename(datatype: Datatype) bool#

Check the filename for datatype is set

Parameters:

datatype (Datatype) – The datatype of the filename to check

Returns:

bool – true if the filename is set, false otherwise

check_filenames() bool#

Check all filenames to see if they are valid

Returns:

bool – true if the filenames are set, false otherwise

check_map(datatype: Datatype)#

Check the validity of a map data from file

Parameters:

datatype (Datatype) – The datatype to check

colour_units(stratigraphic_units: DataFrame, random: bool = False) DataFrame#

Add a colour column to the units in the stratigraphic units structure

Parameters:
  • stratigraphic_units (pandas.DataFrame) – The stratigraphic units data

  • random (bool, optional) – Flag of whether to add random colours to missing entries in the colour lookup table. Defaults to False.

Returns:

pandas.DataFrame – The modified units

export_wkt_format_files()#

Save out the geology and fault GeoDataFrames in WKT format This is used by map2model

extract_all_contacts(save_contacts=True)#

Extract the contacts between units in the geology GeoDataFrame

extract_basal_contacts(stratigraphic_column: list, save_contacts=True)#

Identify the basal unit of the contacts based on the stratigraphic column

Parameters:

stratigraphic_column (list) – The stratigraphic column to use

get_bounding_box(polygon: bool = False)#

Get the bounding box in dict or polygon form

Parameters:

polygon (bool, optional) – Flag to get the bounding box in polygon form. Defaults to False.

Returns:

dict or shapely.Polygon – The bounding box in the requested form

get_colour_filename()#

Get the colour lookup table filename

Returns:

str – The colour lookup table filename

get_config_filename()#

Get the config filename

Returns:

str – The config filename

get_empty_dataframe(datatype: Datatype)#

Create a basic empty geodataframe for a specified datatype

Parameters:

datatype (Datatype) – The datatype of the empty dataset

Returns:

geopandas.GeoDataFrame or None – The created geodataframe

get_filename(datatype: Datatype)#

Get a filename of a specified datatype

Parameters:

datatype (Datatype) – The datatype of the filename wanted

Returns:

string – The filename of the datatype specified

get_ignore_codes() list#

Get the list of codes to ignore

Returns:

list – The list of strings to ignore

get_map_data(datatype: Datatype)#

Get the data geopanda of the specified datatype

Parameters:

datatype (Datatype) – The datatype to retrieve

Returns:

geopandas.GeoDataFrame – The dataframe

get_raw_map_data(datatype: Datatype)#

Get the raw data geopanda of the specified datatype

Parameters:

datatype (Datatype) – The datatype to retrieve

Returns:

geopandas.GeoDataFrame – The raw data

get_value_from_raster(datatype: Datatype, x, y)#

Get the value from a raster map at the specified point

Parameters:
  • datatype (Datatype) – The datatype of the raster map to retrieve from

  • x (float or int) – The easting coordinate of the value

  • y (float or int) – The northing coordinate of the value

Returns:

float or int – The value at the point specified

get_value_from_raster_df(datatype: Datatype, df: DataFrame)#

Add a ‘Z’ column to a dataframe with the heights from the ‘X’ and ‘Y’ coordinates

Parameters:
  • datatype (Datatype) – The datatype of the raster map to retrieve from

  • df (pandas.DataFrame) – The original dataframe with ‘X’ and ‘Y’ columns

Returns:

pandas.DataFrame – The modified dataframe

get_working_projection()#

Get the working projection

Returns:

str – The working projection in “EPSG:<int>” form

load_all_map_data()#

Load all the map data for each datatype. Cycles through each type and loads it

load_map_data(datatype: Datatype)#

Load map data from file, reproject and clip it and then check data is valid

Parameters:

datatype (Datatype) – The datatype to load

load_raster_map_data(datatype: Datatype)#

Load raster map data from file, reproject and clip it and then check data is valid

Parameters:

datatype (Datatype) – The raster datatype to load

open_http_query()#

Attempt to open the http url and unzip the file if required Note: This is specific to opening remotely hosted dtm data in geotiff format

Parameters:

url (str) – The url to open

Returns:

_type_ – The geotiff file

parse_fault_map() tuple#

Parse the fault shapefile data into a consistent format

Returns:

tuple – A tuple of (bool: success/fail, str: failure message)

parse_fault_orientations() tuple#

Parse the fault orientations shapefile data into a consistent format

Returns:

tuple – A tuple of (bool: success/fail, str: failure message)

parse_fold_map() tuple#

Parse the fold shapefile data into a consistent format

Returns:

tuple – A tuple of (bool: success/fail, str: failure message)

parse_geology_map() tuple#

Parse the geology shapefile data into a consistent format

Returns:

tuple – A tuple of (bool: success/fail, str: failure message)

parse_structure_map() tuple#

Parse the structure shapefile data into a consistent format

Returns:

tuple – A tuple of (bool: success/fail, str: failure message)

recreate_bounding_box_str()#

Creates the bounding box string from the bounding box dict

save_all_map_data(output_dir: str, extension: str = '.csv')#

Save all the map data to file

Parameters:
  • output_dir (str) – The directory to save to

  • extension (str, optional) – The extension to use for the data. Defaults to “.csv”.

save_raw_map_data(output_dir: str, datatype: Datatype, extension: str = '.shp.zip')#

Save the map data from datatype to file

Parameters:
  • output_dir (str) – The directory to save to

  • datatype (Datatype) – The datatype of the geopanda to save

  • extension (str, optional) – The extension to use for the data. Defaults to “.csv”.

set_bounding_box(bounding_box)#

Set the bounding box of the map data

Parameters:

bounding_box (tuple or dict) – The bounding box to use for maps

set_colour_filename(filename: Path | str)#

Set the filename of the colour csv file

Parameters:

filename (str) – The csv colour look up table filename

set_config_filename(filename: Path | str, legacy_format: bool = False, lower: bool = False)#

Set the config filename and update the config structure

Parameters:
  • filename (str) – The filename of the config file

  • legacy_format (bool, optional) – Whether the file is in m2lv2 form. Defaults to False.

set_filename(datatype: Datatype, filename: str)#

Set the filename for a specific datatype

Parameters:
  • datatype (Datatype) – The datatype for the filename specified

  • filename (str) – The filename to store

set_filenames_from_australian_state(state: str)#

Set the shape/dtm filenames appropriate to the Australian state

Parameters:

state (str) – The abbreviated Australian state name

Raises:

ValueError – state string not in state list [‘WA’, ‘SA’, ‘QLD’, ‘NSW’, ‘TAS’, ‘VIC’, ‘ACT’, ‘NT’]

set_ignore_codes(codes: list)#

Set the codes to ignore in the geology shapefile

Parameters:

codes (list) – The list of codes to ignore

set_working_projection(projection)#

Set the working projection for the map data

Parameters:

projection (int or str) – The projection to use for map reprojection

set_working_projection_on_map_data(datatype: Datatype)#

Set the working projection on the GeoDataFrame structure or if already set reproject the data

Parameters:

datatype (Datatype) – The datatype to set or reproject

update_filename_with_bounding_box(filename: str)#

Update the filename/url with the bounding box This replace all instances of {BBOX_STR} with the bounding_box_str

Parameters:

filename (str) – The original filename

Raises:

ValueError – Filename is blank

Returns:

str – The modified filename

update_filename_with_projection(filename: str)#

Update the filename/url with the projection This replace all instances of {PROJ_STR} with the projection string

Parameters:

filename (str) – The original filename

Raises:

ValueError – Filename is blank

Returns:

str – The modified filename