Reputation: 665
I remember seeing on a blog post a nice technique to visualize geographical data. It was just lines representing latitude and the high of the lines the variable to be shown. I tried to sketch it on the following picture:
Does some of you remember the library or even the blog post which explained how to generate these maps? (I vaguely remember it being matplotlib & python, but I could very well be wrong)
Upvotes: 1
Views: 1872
Reputation: 20344
I think this is the kind of thing you want - plotting lines of constant latitude on a 3d axis. I've explained what each section does in comments
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import itertools
#read in data from csv organised in columns labelled 'lat','lon','elevation'
data = np.recfromcsv('elevation-sample.csv', delimiter=',')
# create a 3d axis on a figure
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# Find unique (i.e. constant) latitude points
id_list = np.unique(data['lat'])
# stride is how many lines to miss. set to 1 to get every line
# higher to miss more
stride = 5
# Extract each line from the dataset and plot it on the axes
for id in id_list[::stride]:
this_line_data = data[np.where(data['lat'] == id)]
lat,lon,ele = zip(*this_line_data)
ax.plot(lon,lat,ele, color='black')
# set the viewpoint so we're looking straight at the longitude (x) axis
ax.view_init(elev=45., azim=90)
ax.set_xlabel('Longitude')
ax.set_ylabel('Latitude')
ax.set_zlabel('Elevation')
ax.set_zlim([0,1500])
plt.show()
The data set I used to test is not mine, but I found it on github here.
This gives output as follows:
Note - you can swap latitude and longitude if I've misinterpreted the axis labels in your sketch.
Upvotes: 4
Reputation: 1877
Are you thinking a 3D plot similar to this? Possibly you could also do a cascade plot like this? The code for the last type of plot is something like this:
# Input parameters:
padding = 1 # Relative distance between plots
ax = gca() # Matplotlib axes to plot in
spectra = np.random.rand((10, 100)) # Series of Y-data
x_data = np.arange(len(spectra[0])) # X-data
# Figure out distance between plots:
max_value = 0
for spectrum in spectra:
spectrum_yrange = (np.nanmax(spectrum) -
np.nanmin(spectrum))
if spectrum_yrange > max_value:
max_value = spectrum_yrange
# Plot the individual lines
for i, spectrum in enumerate(spectra):
# Normalize the data to max_value
data = (spectrum - spectrum.min()) / float(max_value)
# Offset the individual lines
data += i * padding
ax.plot(x_data, data)
Upvotes: 1