简体   繁体   中英

Converting 3D point cloud to a 2D gridmap on python

I have a 3d point cloud (x,y,z) and I want to get a 2d gridmap image, by projecting the point cloud into this gridmap. Does anyone know how I can do that using Python?

Thank you!

I created fake point cloud and used scipy's griddata:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.interpolate import griddata
d = np.random.randint(0, 35, (100, 3))
x = d[:, 0]
y = d[:, 1]
z = d[:, 2]
# grid size or so to say average distance between grid cells
avg_dist = 1.5
xi = np.arange(x.min(), x.max(), avg_dist)
yi = np.arange(y.min(), y.max(), avg_dist)
zi = griddata((x, y), z, (xi[None,:], yi[:,None]), method='linear')
# Visualization of the result
plt.figure(figsize=(12,6))
CS = plt.contour(xi,yi,zi,15,linewidths=0.11,colors='k')
CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.jet)
plt.colorbar(CS)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM