0

Good Afternoon All,

I'm attempting to create a contour map of surface elevation by using drilling data from a mineral exploration programme. I am new to programming, any feedback would be welcomed!

Each drill hole has a:

  1. hole id
  2. x co-ordinate (Easting)
  3. y co-ordinate (Northing)
  4. z value (surface elevation).

An excerpt of the data is as follows:

Sample Drilling Data

Methodology

I broke the work down into two steps.

1) Checking that the data plots in the correct area

I used pandas to extract the co-ordinates of each drilling hole from the csv file, and plotted the data using plt.scatter from matplotlib.

This is my output. So far it works, so now I want to plot the 3D (z axis) data.

Plotting of drill holes

2) Plotting of Surface_Elevation (z axis)

This is where I am having problems. I've read through several contouring guides for matplotlib which is dependent on plt.contour. The issue is that this function wants a 2D array, and the data that I want to contour is 1D. Am I missing something here?

My attempt

import matplotlib.pyplot as plt  # plot data
import pandas as pd  # extract data from csv

# access csv and assign as a variable
dataset = pd.read_csv('spreadsheet.csv')

# x_axis values extracted and converted to a list from the csv
x_axis = list(dataset["Orig_East"])

# y_axis values extracted and converted to a list from the csv
y_axis = list(dataset["Orig_North"])

# z_axis values extracted and converted to a list from the csv
z_axis = list(dataset["Surface_Elevation"])


plt.contour(x_axis, y_axis, z_axis, colors='black');
plt.ticklabel_format(useOffset=False, style='plain')  # remove exponential axis labels
plt.xlabel('Easting')  # label x axis
plt.ylabel('Northing')  # label y axis
plt.title('Surface Elevation') # label plot

# plot graph
plt.show()

IniMzungu
  • 87
  • 1
  • 10
  • 1
    Would you be fine with encoding the elevation into the color of the scatter marker? – Timo Nov 05 '20 at 12:34
  • Hi @timo. Thanks for the response. Yes, that would work with this type of data. – IniMzungu Nov 05 '20 at 12:39
  • 2
    [Then this will be of help.](https://stackoverflow.com/a/10761545/8881141) You can create a colorbar to indicate the z-value. Since you use pandas, you can directly plot from there `plt.scatter(df.X, df.Y, c=df.Z)` – Mr. T Nov 05 '20 at 12:55
  • @Mr. T. Great, thank you! – IniMzungu Nov 05 '20 at 13:11
  • 2
    Your data is good for making contour plots, https://matplotlib.org/gallery/images_contours_and_fields/irregulardatagrid.html#sphx-glr-gallery-images-contours-and-fields-irregulardatagrid-py – swatchai Nov 05 '20 at 13:15
  • Hi @swatchai, this is ideal. Thanks a lot! – IniMzungu Nov 05 '20 at 13:32

1 Answers1

1

A possible solution is to encode the elevation of each point into the color of the scatter marker. This can be done by calling plt.scatter(x, y, c=z) you can also specify a desired cmap, see the documentation.

Timo
  • 493
  • 4
  • 8