如何在R中提取CALIPSO LiDAR HDF4子数据集为栅格或data.frame
Based on your workflow, here's a structured guide to process your CALIPSO LiDAR data and extract the Cloud Top Height subdataset, with actionable steps for your chosen approach and additional tips:
Key Context Recap
- Data format: HDF4 (verified via HDFView)
- Target subdataset: Cloud Top Height (stored as a 56160-row × 5-column table)
Completing Approach A: Convert to GeoTIFF with gdalUtils
You’ve already started by retrieving the list of subdatasets—here’s how to finish the conversion and avoid common pitfalls:
Step 1: Locate the Cloud Top Height Subdataset
First, print the sds object to identify the exact path of your target subdataset. CALIPSO’s HDF4 datasets use descriptive labels, so look for entries containing "Cloud_Top_Height":
# Print all available subdatasets print(sds) # Example output snippet: "HDF4_SDS:UNKNOWN:\"CAL_LID_L2_333mCLay-ValStage1-V3-01.2011-08-16T0...\":2"
Filter the list to isolate your target:
cloud_top_sds <- sds[grep("Cloud_Top_Height", sds)]
Step 2: Run gdal_translate for Conversion
Use the subdataset path to convert to GeoTIFF. Ensure your file paths use forward slashes (or escaped backslashes for Windows) to avoid errors:
library(gdalUtils) # Convert subdataset to GeoTIFF gdal_translate( src_dataset = cloud_top_sds, dst_dataset = "C:/Users/Thomas/Desktop/cloud_top_height.tif", # Optional: Preserve floating-point precision (CALIPSO height data is often Float32) ot = "Float32" )
Critical Tips
- Spatial Metadata: Verify the output GeoTIFF retains CALIPSO’s geolocation data using
rgdal::GDALinfo("cloud_top_height.tif")—this ensures you can align the height data with other spatial datasets later. - Alternative Workflow: If you don’t need a GeoTIFF, use
rhdf4to directly read the table into a data frame for analysis:library(rhdf4) cloud_top_df <- HDF4Read("C:/Users/Thomas/Desktop/NASA Sat Data/Cloud Layer Data/CAL_LID_L2_333mCLay-ValStage1-V3-01.2011-08-16T0...", dataset = "Cloud_Top_Height")
内容的提问来源于stack exchange,提问作者Thomas Schönwetter

