Miscellaneous Operations
In [1]:
Copied!
import geolime as geo
from pyproj import CRS
import numpy as np
import geolime as geo
from pyproj import CRS
import numpy as np
Load rocklea drillholes geolime objects:
In [3]:
Copied!
dh = geo.datasets.load(data_name="rocklea_dome/dh_hyper.geo")
dh = geo.datasets.load(data_name="rocklea_dome/dh_hyper.geo")
Explore Loaded objects¶
In [4]:
Copied!
dh.name
dh.name
Out[4]:
'rck_hs'
List all available methods and attribute of an object:
In [5]:
Copied!
dh
dh
Out[5]:
Drillholes └─aggregate() └─bounds() └─builtins ⇨ {'X': 0, 'Y': 1, 'Z': 2, 'HOLEID': 3, 'FROM': 4, 'TO': 5} └─centroid() └─collar_coords() └─convert_to_gis_object() └─coords() └─data() └─default_support ⇨ AttributeSupportType.ELEMENT └─delete_composites() └─delete_holes() └─describe() └─element_count() └─generate_attribute_name() └─holeids() └─internals() └─keep_composites() └─keep_holes() └─mid_coords() └─name ⇨ rck_hs └─node_coords() └─plot_2d() └─properties() └─property() └─read_file() └─read_manifest() └─refresh_attributes() └─region() └─region_mask() └─regions() └─remove_attribute() └─remove_property() └─remove_region() └─sample_count() └─set_property() └─set_property_expr() └─set_property_value() └─set_region() └─set_region_condition() └─set_region_value() └─to_csv() └─to_dataframe() └─to_file() └─to_pyvista() └─transform() └─translate_by() └─user_properties()
List all existing properties¶
In [6]:
Copied!
dh.properties()
dh.properties()
Out[6]:
['__TOPO_LEVEL__', '__TOPO_TYPE__', '__TOPO_ELEMENT_V1__', '__TOPO_ELEMENT_V2__', 'FROM', 'TO', 'HOLEID', 'X_COLLAR', 'Y_COLLAR', 'Z_COLLAR', 'X_M', 'Y_M', 'Z_M', 'X_B', 'Y_B', 'Z_B', 'X_E', 'Y_E', 'Z_E', 'Fe_pct', 'Al2O3', 'SiO2_pct', 'K2O_pct', 'CaO_pct', 'MgO_pct', 'TiO2_pct', 'P_pct', 'S_pct', 'Mn_pct', 'LOI', 'Fe_ox_ai', 'hem_over_goe', 'kaolin_abundance', 'kaolin_composition', 'wmAlsmai', 'wmAlsmci', 'carbai3pfit', 'carbci3pfit', 'Depth']
In [7]:
Copied!
dh.describe()
dh.describe()
Out[7]:
__TOPO_LEVEL__ | __TOPO_TYPE__ | __TOPO_ELEMENT_V1__ | __TOPO_ELEMENT_V2__ | FROM | TO | X_COLLAR | Y_COLLAR | Z_COLLAR | X_M | ... | LOI | Fe_ox_ai | hem_over_goe | kaolin_abundance | kaolin_composition | wmAlsmai | wmAlsmci | carbai3pfit | carbci3pfit | Depth | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
count | 7134.0 | 7134.0 | 7134.000000 | 7134.000000 | 7134.000000 | 7134.000000 | 7134.000000 | 7.134000e+03 | 7134.000000 | 7134.000000 | ... | 4979.000000 | 6920.000000 | 6663.000000 | 3850.000000 | 3850.000000 | 1693.000000 | 1693.000000 | 343.000000 | 343.000000 | 7134.000000 |
mean | 2.0 | 1.0 | 3662.478133 | 3663.478133 | 20.547939 | 21.547939 | 547414.513625 | 7.475480e+06 | 458.496790 | 547414.513625 | ... | 11.303017 | 0.175605 | 910.741882 | 0.162095 | 1.023877 | 0.053175 | 2207.759327 | 0.070173 | 2319.090816 | 42.666526 |
std | 0.0 | 0.0 | 2118.998485 | 2118.998485 | 13.833730 | 13.833730 | 686.760995 | 1.585644e+03 | 7.466562 | 686.760995 | ... | 4.642987 | 0.083948 | 8.857894 | 0.082429 | 0.046523 | 0.038166 | 3.046365 | 0.024599 | 9.787246 | 11.263359 |
min | 2.0 | 1.0 | 0.000000 | 1.000000 | 0.000000 | 1.000000 | 545494.900000 | 7.472793e+06 | 441.000000 | 545494.900000 | ... | 0.710000 | 0.001300 | 869.780000 | 0.017200 | 0.937000 | 0.020000 | 2186.280000 | 0.040100 | 2296.430000 | 7.000000 |
25% | 2.0 | 1.0 | 1823.250000 | 1824.250000 | 9.000000 | 10.000000 | 546904.700000 | 7.474003e+06 | 453.800000 | 546904.700000 | ... | 9.670000 | 0.107000 | 907.705000 | 0.091025 | 0.991000 | 0.028100 | 2206.370000 | 0.052750 | 2312.235000 | 37.000000 |
50% | 2.0 | 1.0 | 3663.500000 | 3664.500000 | 19.000000 | 20.000000 | 547586.100000 | 7.475604e+06 | 458.200000 | 547586.100000 | ... | 11.200000 | 0.185500 | 911.130000 | 0.161000 | 1.007000 | 0.039600 | 2206.910000 | 0.063600 | 2321.900000 | 46.000000 |
75% | 2.0 | 1.0 | 5499.750000 | 5500.750000 | 31.000000 | 32.000000 | 547947.600000 | 7.476004e+06 | 463.600000 | 547947.600000 | ... | 11.900000 | 0.246000 | 914.480000 | 0.226000 | 1.049750 | 0.064200 | 2208.140000 | 0.080500 | 2324.615000 | 51.000000 |
max | 2.0 | 1.0 | 7324.000000 | 7325.000000 | 60.000000 | 61.000000 | 548498.100000 | 7.479595e+06 | 478.600000 | 548498.100000 | ... | 45.280000 | 0.355000 | 974.080000 | 0.413000 | 1.192000 | 0.285000 | 2233.120000 | 0.182000 | 2338.390000 | 61.000000 |
8 rows × 38 columns
List user defined properties¶
In [8]:
Copied!
dh.user_properties()
dh.user_properties()
Out[8]:
['X_COLLAR', 'Y_COLLAR', 'Z_COLLAR', 'X_M', 'Y_M', 'Z_M', 'X_B', 'Y_B', 'Z_B', 'X_E', 'Y_E', 'Z_E', 'Fe_pct', 'Al2O3', 'SiO2_pct', 'K2O_pct', 'CaO_pct', 'MgO_pct', 'TiO2_pct', 'P_pct', 'S_pct', 'Mn_pct', 'LOI', 'Fe_ox_ai', 'hem_over_goe', 'kaolin_abundance', 'kaolin_composition', 'wmAlsmai', 'wmAlsmci', 'carbai3pfit', 'carbci3pfit', 'Depth']
List existing regions¶
In [9]:
Copied!
dh.regions()
dh.regions()
Out[9]:
[]
Spatial Information¶
In [10]:
Copied!
dh.bounds()
dh.bounds()
Out[10]:
array([[5.4549490e+05, 7.4727934e+06, 3.8970000e+02], [5.4849810e+05, 7.4795953e+06, 4.7810000e+02]])
In [11]:
Copied!
dh.centroid()
dh.centroid()
Out[11]:
array([5.47414514e+05, 7.47548047e+06, 4.37448851e+02])
Aggregate value along a drillhole¶
Drillhole properties can be aggregated to extract one value per drillholes. Aggregation methods are available
Get the smallest grade per drillhole¶
In [12]:
Copied!
dh.aggregate(properties=["Fe"], agg_methods=["min"])
dh.aggregate(properties=["Fe"], agg_methods=["min"])
Out[12]:
HOLEID | X | X_min | Y | Y_min | Z | Z_min | __TOPO_LEVEL___min | __TOPO_TYPE___min | __TOPO_ELEMENT_V1___min | ... | LOI_min | Fe_ox_ai_min | hem_over_goe_min | kaolin_abundance_min | kaolin_composition_min | wmAlsmai_min | wmAlsmci_min | carbai3pfit_min | carbci3pfit_min | Depth_min | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | RKC278 | 548001.3 | 548001.3 | 7474002.1 | 7474002.1 | 453.5 | 406.5 | 2 | 1 | 0 | ... | 7.30 | 0.01950 | 891.13 | 0.0269 | 0.958 | 0.0210 | 2206.08 | 0.0582 | 2301.30 | 47.0 |
1 | RKC279 | 547804.6 | 547804.6 | 7474004.5 | 7474004.5 | 453.4 | 407.4 | 2 | 1 | 48 | ... | 8.16 | 0.01950 | 893.42 | 0.0243 | 0.974 | 0.0217 | 2205.88 | 0.0450 | 2301.66 | 46.0 |
2 | RKC280 | 547310.8 | 547310.8 | 7474002.2 | 7474002.2 | 453.8 | 403.8 | 2 | 1 | 95 | ... | 8.53 | 0.03920 | 892.49 | 0.0254 | 0.946 | 0.0240 | 2205.81 | 0.0420 | 2323.12 | 51.0 |
3 | RKC281 | 547100.8 | 547100.8 | 7474003.4 | 7474003.4 | 453.4 | 416.4 | 2 | 1 | 146 | ... | 8.27 | 0.03150 | 895.25 | 0.1160 | 0.971 | 0.0222 | 2205.89 | 0.0626 | 2314.86 | 37.0 |
4 | RKC282 | 547199.0 | 547199.0 | 7474801.2 | 7474801.2 | 456.0 | 449.0 | 2 | 1 | 184 | ... | NaN | 0.11500 | 908.45 | 0.1520 | 1.065 | NaN | NaN | NaN | NaN | 7.0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
187 | RKC482 | 547748.8 | 547748.8 | 7475997.8 | 7475997.8 | 465.5 | 410.5 | 2 | 1 | 7125 | ... | 7.42 | 0.05810 | 892.78 | 0.0229 | 0.986 | 0.0215 | 2206.20 | 0.0436 | 2322.69 | 55.0 |
188 | RKC483 | 547825.6 | 547825.6 | 7473716.0 | 7473716.0 | 452.7 | 405.7 | 2 | 1 | 7181 | ... | 5.24 | 0.01510 | 889.28 | 0.0321 | 0.965 | 0.0299 | 2205.54 | 0.0526 | 2310.33 | 47.0 |
189 | RKC484 | 547866.5 | 547866.5 | 7473820.9 | 7473820.9 | 452.4 | 406.4 | 2 | 1 | 7229 | ... | 8.00 | 0.00686 | 884.35 | 0.0353 | 0.976 | 0.0237 | 2205.70 | 0.0479 | 2305.67 | 46.0 |
190 | RKC485 | 547913.3 | 547913.3 | 7473917.2 | 7473917.2 | 452.4 | 407.4 | 2 | 1 | 7276 | ... | 8.75 | 0.03780 | 888.81 | 0.0306 | 0.985 | 0.0219 | 2205.02 | NaN | NaN | 46.0 |
191 | RKD015 | 547905.0 | 547905.0 | 7476800.0 | 7476800.0 | 470.0 | 469.0 | 2 | 1 | 7322 | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | 41.0 |
192 rows × 45 columns
Dealing with condition¶
Extract values where condition are required¶
In [13]:
Copied!
dh["Z_M"].mean()
dh["Z_M"].mean()
Out[13]:
437.4488505747126
In [14]:
Copied!
dh.data(names="Fe_pct", region="Z_M < 437")
dh.data(names="Fe_pct", region="Z_M < 437")
Out[14]:
array([48., 40., 56., ..., 39., 16., 12.])
In [15]:
Copied!
dh.data(names="Fe_pct", region="(Z_M < 437) and (SiO2_pct < 20)")
dh.data(names="Fe_pct", region="(Z_M < 437) and (SiO2_pct < 20)")
Out[15]:
array([48., 56., 55., ..., 47., 44., 43.])
Property creation¶
Create property from numpy array¶
In [16]:
Copied!
fe_gaussian_scores = geo.gauss_score(dh["Fe_pct"])
fe_gaussian_scores = geo.gauss_score(dh["Fe_pct"])
In [17]:
Copied!
dh.set_property(name="fe_gauss", data=fe_gaussian_scores)
dh.set_property(name="fe_gauss", data=fe_gaussian_scores)
Create property from other properties¶
In [18]:
Copied!
dh.set_property_expr(name="Composite_Thickness", expr="TO - FROM")
dh.set_property_expr(name="Composite_Thickness", expr="TO - FROM")
In [19]:
Copied!
dh.set_property_expr(name="Fe_pct_acc", expr="Fe_pct * Composite_Thickness")
dh.set_property_expr(name="Fe_pct_acc", expr="Fe_pct * Composite_Thickness")
In [20]:
Copied!
geo.scatter(
geo_object=dh,
property_x="Fe_pct",
property_y="SiO2_pct",
width=650,
height=650
)
geo.scatter(
geo_object=dh,
property_x="Fe_pct",
property_y="SiO2_pct",
width=650,
height=650
)
In [21]:
Copied!
geo.histogram_plot(
[{"object": dh, "property": "fe_gauss"}],
width=650,
height=400
)
geo.histogram_plot(
[{"object": dh, "property": "fe_gauss"}],
width=650,
height=400
)
Create empty property to be filled later¶
In [22]:
Copied!
dh.set_property_expr(name="High_Fe", expr="nan")
dh.set_property_expr(name="High_Fe", expr="Fe_pct", region="Fe_pct > 30")
dh.set_property_expr(name="High_Fe", expr="nan")
dh.set_property_expr(name="High_Fe", expr="Fe_pct", region="Fe_pct > 30")
In [23]:
Copied!
geo.histogram_plot(
[
{"object": dh, "property": "Fe_pct"},
{"object": dh, "property": "High_Fe"}
],
width=650,
height=400
)
geo.histogram_plot(
[
{"object": dh, "property": "Fe_pct"},
{"object": dh, "property": "High_Fe"}
],
width=650,
height=400
)
Property deletion¶
In [24]:
Copied!
dh.remove_property(name="fe_gauss")
dh.remove_property(name="fe_gauss")
Out[24]:
True
Region creation¶
Create region from external array¶
In [25]:
Copied!
dh.set_region(name="fe_gaussian_postivie", data = fe_gaussian_scores > 0)
dh.set_region(name="fe_gaussian_postivie", data = fe_gaussian_scores > 0)
Create region from property condition¶
In [26]:
Copied!
dh.set_region_condition(name="Ore", condition="Fe_pct > 30")
dh.set_region_condition(name="Ore", condition="Fe_pct > 30")
Region deletion¶
In [27]:
Copied!
dh.remove_region(name="fe_new_values_gt_10")
dh.remove_region(name="fe_new_values_gt_10")
Out[27]:
False
Using numpy when condition thickens¶
In [28]:
Copied!
dh.set_region_condition(name="Fe_pct_lt_5", condition="Fe_pct < 5")
dh.set_region_condition(name="SiO2_pct_gt_25", condition="SiO2_pct > 25")
dh.set_region_condition(name="Fe_pct_lt_5", condition="Fe_pct < 5")
dh.set_region_condition(name="SiO2_pct_gt_25", condition="SiO2_pct > 25")
In [29]:
Copied!
fe_high_silica_array = np.where(
dh['SiO2_pct_gt_25'] & dh['Fe_pct_lt_5'],
5,
dh['Fe_pct']
)
fe_high_silica_array = np.where(
dh['SiO2_pct_gt_25'] & dh['Fe_pct_lt_5'],
5,
dh['Fe_pct']
)
In [30]:
Copied!
dh.set_property(name="fe_high_silica", data=fe_high_silica_array)
dh.set_property(name="fe_high_silica", data=fe_high_silica_array)
Need to export to Pandas DataFrame for tabular like tasks¶
In [31]:
Copied!
dh.to_dataframe()
dh.to_dataframe()
Out[31]:
__TOPO_LEVEL__ | __TOPO_TYPE__ | __TOPO_ELEMENT_V1__ | __TOPO_ELEMENT_V2__ | FROM | TO | HOLEID | X_COLLAR | Y_COLLAR | Z_COLLAR | ... | carbci3pfit | Depth | Composite_Thickness | Fe_pct_acc | High_Fe | fe_gaussian_postivie | Ore | Fe_pct_lt_5 | SiO2_pct_gt_25 | fe_high_silica | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 2 | 1 | 0 | 1 | 0.0 | 1.0 | RKC278 | 548001.3 | 7474002.1 | 453.5 | ... | NaN | 47.0 | 1.0 | NaN | NaN | True | False | False | False | NaN |
1 | 2 | 1 | 1 | 2 | 1.0 | 2.0 | RKC278 | 548001.3 | 7474002.1 | 453.5 | ... | NaN | 47.0 | 1.0 | NaN | NaN | True | False | False | False | NaN |
2 | 2 | 1 | 2 | 3 | 2.0 | 3.0 | RKC278 | 548001.3 | 7474002.1 | 453.5 | ... | NaN | 47.0 | 1.0 | NaN | NaN | True | False | False | False | NaN |
3 | 2 | 1 | 3 | 4 | 3.0 | 4.0 | RKC278 | 548001.3 | 7474002.1 | 453.5 | ... | NaN | 47.0 | 1.0 | NaN | NaN | True | False | False | False | NaN |
4 | 2 | 1 | 4 | 5 | 4.0 | 5.0 | RKC278 | 548001.3 | 7474002.1 | 453.5 | ... | 2312.89 | 47.0 | 1.0 | NaN | NaN | True | False | False | False | NaN |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
7129 | 2 | 1 | 7319 | 7320 | 43.0 | 44.0 | RKC485 | 547913.3 | 7473917.2 | 452.4 | ... | NaN | 46.0 | 1.0 | 16.0 | NaN | False | False | False | True | 16.0 |
7130 | 2 | 1 | 7320 | 7321 | 44.0 | 45.0 | RKC485 | 547913.3 | 7473917.2 | 452.4 | ... | NaN | 46.0 | 1.0 | 12.0 | NaN | False | False | False | True | 12.0 |
7131 | 2 | 1 | 7322 | 7323 | 0.0 | 1.0 | RKD015 | 547905.0 | 7476800.0 | 470.0 | ... | NaN | 41.0 | 1.0 | NaN | NaN | True | False | False | False | NaN |
7132 | 2 | 1 | 7323 | 7324 | 0.0 | 1.0 | RKD015 | 547905.0 | 7476800.0 | 470.0 | ... | NaN | 41.0 | 1.0 | NaN | NaN | True | False | False | False | NaN |
7133 | 2 | 1 | 7324 | 7325 | 0.0 | 1.0 | RKD015 | 547905.0 | 7476800.0 | 470.0 | ... | NaN | 41.0 | 1.0 | NaN | NaN | True | False | False | False | NaN |
7134 rows × 47 columns
Last update:
2023-10-31