Get the latitude and longitude of a 2B-CLDCLASS-lidar granule with python


Example of python code to read the latitude and longitude of a 2B-CLDCLASS-lidar granule using python

#!/usr/bin/env python

from pyhdf.SD import SD, SDC 
from pyhdf.HDF import *
from pyhdf.VS import *

import pprint

file_path = ''
file_name = '2008183012329_11573_CS_2B-CLDCLASS-LIDAR_GRANULE_P_R04_E02.hdf'

# Read HDF Files (VD data) Latitude & Longitude

f = HDF(file_path+file_name, SDC.READ) 
vs = f.vstart()

Latitude = vs.attach('Latitude')
Longitude = vs.attach('Longitude')

latitude_table = Latitude[:]
longitude_table = Longitude[:]

Latitude.detach() 
Longitude.detach() 
vs.end()
f.close()

for i in range(100):
    print('lat,long:',latitude_table[i][0],longitude_table[i][0])

returns for the first 100 values:

lat,long: -0.008913800120353699 5.306268692016602
lat,long: -0.018581800162792206 5.304210662841797
lat,long: -0.028249800205230713 5.302152633666992
lat,long: -0.037917785346508026 5.300094127655029
lat,long: -0.0475856252014637 5.298036098480225
lat,long: -0.05725346505641937 5.29597806930542
lat,long: -0.06692130118608475 5.293920040130615
lat,long: -0.07658914476633072 5.2918620109558105
lat,long: -0.0862569808959961 5.289803981781006
lat,long: -0.09592482447624207 5.287745475769043
lat,long: -0.10559280216693878 5.285687446594238
lat,long: -0.11526080220937729 5.283629417419434
lat,long: -0.1249288022518158 5.281570911407471
lat,long: -0.1345967948436737 5.279512882232666
lat,long: -0.1442648023366928 5.277454376220703
lat,long: -0.15393279492855072 5.275396347045898
lat,long: -0.16360069811344147 5.273338317871094
lat,long: -0.17326854169368744 5.271280288696289
lat,long: -0.1829363852739334 5.269221782684326
lat,long: -0.19260422885417938 5.2671637535095215
lat,long: -0.20227205753326416 5.265105724334717
lat,long: -0.21193990111351013 5.263047695159912
lat,long: -0.2216077446937561 5.260989665985107
lat,long: -0.23127558827400208 5.258931636810303
lat,long: -0.24094341695308685 5.256873607635498
lat,long: -0.250611275434494 5.254815578460693
lat,long: -0.2602790892124176 5.252757549285889
lat,long: -0.2699469327926636 5.250699043273926
lat,long: -0.27961477637290955 5.248641014099121
lat,long: -0.2892826199531555 5.246582984924316
lat,long: -0.2989504635334015 5.2445244789123535
lat,long: -0.30861830711364746 5.242466449737549
lat,long: -0.31828615069389343 5.240408420562744
lat,long: -0.3279539942741394 5.238349914550781
lat,long: -0.3376218378543854 5.236291885375977
lat,long: -0.34728965163230896 5.234233856201172
lat,long: -0.35695749521255493 5.232175350189209
lat,long: -0.3666253387928009 5.230117321014404
lat,long: -0.3762931823730469 5.2280592918396
lat,long: -0.38596102595329285 5.226001262664795
lat,long: -0.3956288695335388 5.22394323348999
lat,long: -0.4052967131137848 5.2218852043151855
lat,long: -0.41496455669403076 5.219826698303223
lat,long: -0.42463237047195435 5.217768669128418
lat,long: -0.4343002140522003 5.215710163116455
lat,long: -0.4439680576324463 5.21365213394165
lat,long: -0.45363590121269226 5.2115936279296875
lat,long: -0.46330368518829346 5.209535598754883
lat,long: -0.4729713797569275 5.207477569580078
lat,long: -0.48263904452323914 5.205419063568115
lat,long: -0.49230673909187317 5.2033610343933105
lat,long: -0.5019744038581848 5.201302528381348
lat,long: -0.5116420984268188 5.199244499206543
lat,long: -0.5213097929954529 5.19718599319458
lat,long: -0.5309776067733765 5.195127964019775
lat,long: -0.5406454801559448 5.1930694580078125
lat,long: -0.5503132939338684 5.191011428833008
lat,long: -0.5599811673164368 5.188953399658203
lat,long: -0.5696489810943604 5.18689489364624
lat,long: -0.5793167948722839 5.1848368644714355
lat,long: -0.5889845490455627 5.182778358459473
lat,long: -0.598652184009552 5.180720329284668
lat,long: -0.608319878578186 5.178661823272705
lat,long: -0.6179875731468201 5.1766037940979
lat,long: -0.6276552677154541 5.174545764923096
lat,long: -0.6373229026794434 5.172487258911133
lat,long: -0.6469905972480774 5.170429229736328
lat,long: -0.6566582918167114 5.168370723724365
lat,long: -0.6663259863853455 5.1663126945495605
lat,long: -0.6759936213493347 5.164254188537598
lat,long: -0.6856613159179688 5.162196159362793
lat,long: -0.6953290104866028 5.16013765335083
lat,long: -0.704996645450592 5.158079624176025
lat,long: -0.7146641612052917 5.156021595001221
lat,long: -0.7243316769599915 5.153963088989258
lat,long: -0.7339991927146912 5.151905059814453
lat,long: -0.7436667084693909 5.14984655380249
lat,long: -0.7533342242240906 5.1477885246276855
lat,long: -0.7630017399787903 5.145730018615723
lat,long: -0.7726694345474243 5.143671989440918
lat,long: -0.7823371291160583 5.141613483428955
lat,long: -0.7920048236846924 5.139554977416992
lat,long: -0.8016724586486816 5.137496471405029
lat,long: -0.8113401532173157 5.135437965393066
lat,long: -0.8210078477859497 5.133379936218262
lat,long: -0.8306753635406494 5.131321430206299
lat,long: -0.8403429388999939 5.129262924194336
lat,long: -0.8500104546546936 5.127204418182373
lat,long: -0.8596779704093933 5.125146389007568
lat,long: -0.869345486164093 5.1230878829956055
lat,long: -0.8790130019187927 5.121029376983643
lat,long: -0.8886805176734924 5.11897087097168
lat,long: -0.8983480334281921 5.116912364959717
lat,long: -0.9080155491828918 5.114854335784912
lat,long: -0.9176830649375916 5.112795829772949
lat,long: -0.9273505806922913 5.110737323760986
lat,long: -0.937018096446991 5.108678817749023
lat,long: -0.9466856122016907 5.1066203117370605
lat,long: -0.9563531279563904 5.104561805725098
lat,long: -0.9660206437110901 5.102503299713135

can be used to plot a Plot cldclass-lidar granule vertical profile using python source code

Plot cldclass-lidar granule vertical profile using python 3 Plot cldclass-lidar granule vertical profile using python 3
Plot cldclass-lidar granule vertical profile using python 3 Plot cldclass-lidar granule vertical profile using python 3
Plot cldclass-lidar granule vertical profile using python 3