I have to convert ellipsoidal height to Mean sea level on 5 million points which only possible on GPU segments.
Below is my code
import cudf
import pandas as pd
import numpy as np
from laspy.file import File
import gdal
import pyproj
from numba import cuda
from scipy.interpolate import RectBivariateSpline as Spline
infile=File("pointcloud.las",mode='r')
lasfile_df = cudf.DataFrame()
lasfile_df['X']=infile.x
lasfile_df['Y']=infile.y
lasfile_df['Z']=infile.z
http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/binary/binarygeoid.html
Download WW15MGH.DAC
egm=np.fromfile("/content/drive/MyDrive/WW15MGH.DAC",">i2").reshape(721,1440)/100
@cuda.jit
def ellipsoid_to_msl(lon,lat,height,out):
for i,(lon,lat,height) in enumerate(zip(lon,lat,height)):
longs=np.arange(0,360,0.25)
lats=np.arange(-90,90.1,0.25)
interp=Spline(lats,longs,egm)
lat*=-1
if lon<0:
lon+=360
z=interp.ev(lat,lon)
out[i]=height-z
lasfile_df=lasfile_df.apply_rows(ellipsoid_to_msl,
incols={'X':'lon','Y':'lat','Z':'height'},
outcols={'out': np.float64},
kwargs={})
In the lasfile_df, the apply_rows is not working properly.
Can anyone explain how to do it using a cuda dataframe because in a pandas dataframe it takes a lot of time?