[Qgis-developer] [Qgis-user] Using/visualizing 3D data (Z values)

gene martin.laloux at gmail.com
Wed Sep 26 12:44:09 PDT 2012


This solution works in the Python console 

x=[]
y=[]
z=[]
for elem in macouche.selectedFeatures(): 
           geom= elem.geometry() 
           wkb = geom.asWkb() 
           x.append(loads(wkb).x)
           y.append(loads(wkb).y)
           z.append(loads(wkb).z)

*For 3d scatter points*
from mpl_toolkits.mplot3d.axes3d import *
import pylab as plt
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.plot(x,y,z,'o')
plt.show()
or
fig = plt.figure()
ax = Axes3D(fig)
ax.scatter3D(x,y,z,c=z,cmap=plt.cm.jet)
plt.show()

<http://osgeo-org.1560.n6.nabble.com/file/n5004759/3dpoints.jpg> 

*and with a simple grid from the points*
from matplotlib.mlab import griddata
fig = plt.figure()
ax = fig.gca(projection='3d')
xi = np.linspace(min(x), max(x))
yi = np.linspace(min(y), max(y))
X, Y = np.meshgrid(xi, yi)
Z = griddata(x, y, z, xi, yi)
surf = ax.plot_surface(X, Y, Z, rstride=2, cstride=2,
cmap=cm.jet,linewidth=1, antialiased=True)
ax.scatter3D(x,y,z,c=z,cmap=plt.cm.jet)
plt.show()

<http://osgeo-org.1560.n6.nabble.com/file/n5004759/gridpoints.jpg> 
	
No color here because it is a  "discontinuous" surface (griddata). 



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Re-Qgis-user-Using-visualizing-3D-data-Z-values-tp5004272p5004759.html
Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.


More information about the Qgis-developer mailing list