rgdal-dev / gdal_todo

A place to record wishlist items for GDAL facilities
0 stars 0 forks source link

DRAFT L2 issue geolocation #12

Closed mdsumner closed 1 year ago

mdsumner commented 1 year ago

L2 ocean colour geolocation arrays in different group

Feature request to auto-detect geolocation arrays from L2 NASA ocean colour.

This file SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc contains data arrays in group "geophysical_data" and geolocation arrays in group "navigation_data", but not currently known to GDAL.

  SUBDATASET_1_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/aot_862
  SUBDATASET_1_DESC=[3232x3200] atmosphere_optical_thickness_due_to_ambient_aerosol (16-bit integer)
  SUBDATASET_2_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/angstrom
  SUBDATASET_2_DESC=[3232x3200] aerosol_angstrom_exponent (16-bit integer)
  SUBDATASET_3_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/Rrs_410
  SUBDATASET_3_DESC=[3232x3200] surface_ratio_of_upwelling_radiance_emerging_from_sea_water_to_downwelling_radiative_flux_in_air (16-bit integer)
  SUBDATASET_4_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/Rrs_443
  SUBDATASET_4_DESC=[3232x3200] surface_ratio_of_upwelling_radiance_emerging_from_sea_water_to_downwelling_radiative_flux_in_air (16-bit integer)
  SUBDATASET_5_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/Rrs_486
  SUBDATASET_5_DESC=[3232x3200] surface_ratio_of_upwelling_radiance_emerging_from_sea_water_to_downwelling_radiative_flux_in_air (16-bit integer)
  SUBDATASET_6_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/Rrs_551
  SUBDATASET_6_DESC=[3232x3200] surface_ratio_of_upwelling_radiance_emerging_from_sea_water_to_downwelling_radiative_flux_in_air (16-bit integer)
  SUBDATASET_7_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/Rrs_671
  SUBDATASET_7_DESC=[3232x3200] surface_ratio_of_upwelling_radiance_emerging_from_sea_water_to_downwelling_radiative_flux_in_air (16-bit integer)
  SUBDATASET_8_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/chlor_a
  SUBDATASET_8_DESC=[3232x3200] mass_concentration_of_chlorophyll_in_sea_water (32-bit floating-point)
  SUBDATASET_9_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/Kd_490
  SUBDATASET_9_DESC=[3232x3200] /geophysical_data/Kd_490 (16-bit integer)
  SUBDATASET_10_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/pic
  SUBDATASET_10_DESC=[3232x3200] /geophysical_data/pic (16-bit integer)
  SUBDATASET_11_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/poc
  SUBDATASET_11_DESC=[3232x3200] /geophysical_data/poc (16-bit integer)
  SUBDATASET_12_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/par
  SUBDATASET_12_DESC=[3232x3200] surface_downwelling_photosynthetic_photon_flux_in_air (16-bit integer)
  SUBDATASET_13_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/l2_flags
  SUBDATASET_13_DESC=[3232x3200] /geophysical_data/l2_flags (32-bit integer)
  SUBDATASET_14_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/navigation_data/longitude
  SUBDATASET_14_DESC=[3232x3200] longitude (32-bit floating-point)
  SUBDATASET_15_NAME=NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/navigation_data/latitude
  SUBDATASET_15_DESC=[3232x3200] latitude (32-bit floating-point)

The file is obtainable via this getfile cgi mech, but requires earthdata credentials:

https://oceandata.sci.gsfc.nasa.gov/ob/getfile/SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc

it's browsable at https://oceancolor.gsfc.nasa.gov/cgi/browse.pl?per=DAY&day=19448&sub=level3&prm=CHL&set=10&ndx=0&mon=19417&rad=0&frc=0&dnm=D@M (click on New Zealand, it's the 3rd column as shown in this screenshot).

image

Expected behavior and actual behavior.

GDAL could recognize this product as having geolocation arrays for the data in group "geophysical_data", they have the same dimensions.

I had aspired to PR this myself but it's beyond me atm.

To illustrate that it would work through the warper, I created a stripped down VRT (I removed the original Metadata) that works with gdalwarp in the usual ways.

<VRTDataset rasterXSize="3200" rasterYSize="3232">
  <Metadata domain="GEOLOCATION">
    <MDI key="LINE_OFFSET">0</MDI>
    <MDI key="LINE_STEP">1</MDI>
    <MDI key="PIXEL_OFFSET">0</MDI>
    <MDI key="PIXEL_STEP">1</MDI>
    <MDI key="SRS">GEOGCS["WGS 84 (CRS84)",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Longitude",EAST],AXIS["Latitude",NORTH],AUTHORITY["OGC","CRS84"]]</MDI>
    <MDI key="X_BAND">1</MDI>
    <MDI key="X_DATASET">NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/navigation_data/longitude</MDI>
    <MDI key="Y_BAND">1</MDI>
    <MDI key="Y_DATASET">NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/navigation_data/latitude</MDI>
  </Metadata>
  <VRTRasterBand dataType="Float32" band="1" blockXSize="33" blockYSize="33">
    <Metadata>
      <MDI key="long_name">Chlorophyll Concentration, OCI Algorithm</MDI>
      <MDI key="NETCDF_VARNAME">chlor_a</MDI>
      <MDI key="reference">Hu, C., Lee Z., and Franz, B.A. (2012). Chlorophyll-a algorithms for oligotrophic oceans: A novel approach based on three-band reflectance difference, J. Geophys. Res., 117, C01011, doi:10.1029/2011JC007395.</MDI>
      <MDI key="standard_name">mass_concentration_of_chlorophyll_in_sea_water</MDI>
      <MDI key="units">mg m^-3</MDI>
      <MDI key="valid_max">100</MDI>
      <MDI key="valid_min">0.001</MDI>
      <MDI key="_FillValue">-32767</MDI>
    </Metadata>
    <NoDataValue>-32767</NoDataValue>
    <UnitType>mg m^-3</UnitType>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">NETCDF:"SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc":/geophysical_data/chlor_a</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="3200" RasterYSize="3232" DataType="Float32" BlockXSize="33" BlockYSize="33" />
      <SrcRect xOff="0" yOff="0" xSize="3200" ySize="3232" />
      <DstRect xOff="0" yOff="0" xSize="3200" ySize="3232" />
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

e.g.

gdalwarp SNPP_VIIRS.20230401T023601.L2.OC.NRT.nc.vrt -tr 5000 5000 -t_srs "+proj=laea +lon_0=167 +lat_0=-33"  SNPP_VIIRS.20230401T023601.L2.OC.NRT_LAEA.tif

gdal_translate SNPP_VIIRS.20230401T023601.L2.OC.NRT_LAEA.tif SNPP_VIIRS.20230401T023601.L2.OC.NRT_LAEA.png -scale -ot Byte -exponent 0.2
mdsumner commented 1 year ago

done!