I have xyz coordinates with some associated data (classification and angle). I would like to use numpy.meshgrid to use a function to summarize the point data within each grid cell (e.g. mean z, std, etc.). The reason I would like to use numpy.meshgrid is for scalability (geopandas is not feasible for my project, since we are using a point cloud that contains millions of points).
So, I simply want to be able to go through each grid cell, filter for points within that grid cell (see data below e.g. lasx, lasy, and lasz) and compute mean, standard deviation, count, etc. (e.g. of the z-values below).
Here is my mesh grid:
binx=np.arange(min(lasx),max(lasx),30)
biny=np.arange(min(lasy),max(lasy),30)
xx, yy = np.meshgrid(binx,biny)
Here is some data for testing:
lasx = np.array([320999.12, 320997.33, 320995.03, 320996.22, 320995.61, 320996.65,
320991.71, 320992.75, 320991.95, 320992.89, 320991.23, 320994.58,
320992.58, 320985.69, 320987.6 , 320998.81, 320984.84, 320990.01,
320991.56, 320983.47, 320985.07, 320988.36, 320984.21, 320997.23,
320982.59, 320994.63, 320983.21, 320985.7 , 320995.28, 320984.52,
320995.12, 320981.91, 320994.09, 320985.04, 320994.28, 320984.22,
320990.29, 320985.68, 320997.12, 320984.28, 320994.98, 320984.6 ,
320996.17, 320984.68, 320998.33, 320984.47, 320998.41, 320986.34,
320996.67, 320992.11, 320987.13, 320998.71, 320987.07, 320995.59,
320988.23, 320994.73, 320994.73, 320989.05, 320995.25, 320990.47,
320994.11, 320996.89, 320992.02, 320992.08, 320993. , 320993.72,
320994.44, 320995.68, 320996.37, 320999.77, 320999.09, 320999.94,
320717.88, 320732.82, 320753.15, 320719.04, 320726.18, 320770.27,
320825.5 , 320779.35, 320751.4 , 320717.6 , 320731.44, 320764.28,
320798.3 , 320852.99, 320860.2 , 320814.51, 320774.91, 320738.15,
320718.73, 320749.17, 320777.43, 320814.38, 320857.39, 320911.5 ,
320918.48, 320876.19, 320836.37, 320786.07])
lasy = np.array([4096922.47, 4096925.41, 4096926.95, 4096928.31, 4096931.07,
4096932.53, 4096932.82, 4096933.65, 4096934.99, 4096936.38,
4096938.45, 4096939.61, 4096939.75, 4096941.53, 4096942.79,
4096942.22, 4096944.24, 4096945.29, 4096945.26, 4096947.01,
4096948.2 , 4096948.05, 4096949.32, 4096947.87, 4096950.99,
4096950.31, 4096952.26, 4096952.13, 4096952.25, 4096953.25,
4096953.56, 4096954.96, 4096954.27, 4096955.59, 4096956.57,
4096957.53, 4096958.38, 4096958.17, 4096959.27, 4096960.12,
4096960.09, 4096961.46, 4096961.96, 4096962.74, 4096962.57,
4096964.1 , 4096964.47, 4096965.3 , 4096964.93, 4096966.23,
4096967.9 , 4096968.43, 4096969.24, 4096969.63, 4096970.49,
4096970.53, 4096971.41, 4096973.11, 4096973.5 , 4096974.32,
4096975.09, 4096975.27, 4096976.93, 4096978.23, 4096979.54,
4096980.75, 4096982.02, 4096983.37, 4096985.85, 4096987.05,
4096989.59, 4096993.2 , 4096999.77, 4096999.86, 4096999.47,
4096998.85, 4096998.77, 4096999.45, 4096999.48, 4096998.73,
4096999.43, 4096997.65, 4096997.91, 4096999.43, 4096998.9 ,
4096999.71, 4096999.17, 4096998.4 , 4096998.27, 4096997.16,
4096996.74, 4096997.86, 4096997.69, 4096998.24, 4096999.32,
4096999.82, 4096999.17, 4096998.39, 4096997.68, 4096996.87])
lasz = np.array([ 0. , 0. , 0. , 0. , 0. , 0. , 0. , 8.83, 8.86,
9.29, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 5.36, 16.22, 0.21, 0. , 0. ,
0. , 9.89, 4.94, 9.14, 0. , 0. , 8.53, 4.82, 0.05,
0. , 8.24, 0. , 0. , 10.74, 0. , 0. , 0. , 9.61,
0. , 0. , 0. , 14.81, 0. , 0. , 0. , 0. , 5.08,
0. , 13.13, 0. , 0. , 7.39, 0. , 5.48, 0. , 0. ,
0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
3. , 0. , 3.51, 3.28, 0. , 0. , 0. , 0. , 18.37,
0. , 0. , 16.26, 0.08, 0. , 0. , 0.25, 8.08, 0. ,
0. , 9.44, 0. , 0.26, 6.45, 0. , 0. , 0. , 0. ,
0. ])