2

I'm trying to use GDAL to create raster images from NOAA GSIP L2 data products. By looking at the provided NetCDF files from NOAA, it appears that geolocation arrays are provided. I tried following the instructions from this post to use the geolocation arrays to produce a GeoTiff image for one of the included variables. Below are my VRT files,

lon.vrt

<VRTDataset rasterXSize="5212" rasterYSize="2705">
  <VRTRasterBand dataType="Float32" band="1">
    <Metadata>
      <MDI key="long_name">pixel longitude</MDI>
      <MDI key="NETCDF_VARNAME">pixel_longitude</MDI>
      <MDI key="SCALED">0</MDI>
      <MDI key="units">degrees</MDI>
      <MDI key="valid_max">180</MDI>
      <MDI key="valid_min">-180</MDI>
      <MDI key="_FillValue">-999</MDI>
    </Metadata>
    <NoDataValue>-999</NoDataValue>
    <UnitType>degrees</UnitType>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">NETCDF:gsipL2_goes13_2014060_0545.nc:pixel_longitude</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="5212" RasterYSize="2705" DataType="Float32" BlockXSize="5212" BlockYSize="1" />
      <SrcRect xOff="0" yOff="0" xSize="5212" ySize="2705" />
      <DstRect xOff="0" yOff="0" xSize="5212" ySize="2705" />
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

lat.vrt

<VRTDataset rasterXSize="5212" rasterYSize="2705">
  <VRTRasterBand dataType="Float32" band="1">
    <Metadata>
      <MDI key="long_name">pixel latitude</MDI>
      <MDI key="NETCDF_VARNAME">pixel_latitude</MDI>
      <MDI key="SCALED">0</MDI>
      <MDI key="units">degrees</MDI>
      <MDI key="valid_max">90</MDI>
      <MDI key="valid_min">-90</MDI>
      <MDI key="_FillValue">-999</MDI>
    </Metadata>
    <NoDataValue>-999</NoDataValue>
    <UnitType>degrees</UnitType>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">NETCDF:gsipL2_goes13_2014060_0545.nc:pixel_latitude</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="5212" RasterYSize="2705" DataType="Float32" BlockXSize="5212" BlockYSize="1" />
      <SrcRect xOff="0" yOff="0" xSize="5212" ySize="2705" />
      <DstRect xOff="0" yOff="0" xSize="5212" ySize="2705" />
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

flux_swd_sfc.vrt

<VRTDataset rasterXSize="5212" rasterYSize="2705">
  <metadata domain="GEOLOCATION">
    <mdi key="X_DATASET">lon.vrt</mdi>
    <mdi key="X_BAND">1</mdi>
    <mdi key="Y_DATASET">lat.vrt</mdi>
    <mdi key="Y_BAND">1</mdi>
    <mdi key="PIXEL_OFFSET">0</mdi>
    <mdi key="LINE_OFFSET">0</mdi>
    <mdi key="PIXEL_STEP">1</mdi>
    <mdi key="LINE_STEP">1</mdi>
  </metadata>
  <VRTRasterBand dataType="Int16" band="1">
    <Metadata>
      <MDI key="add_offset">0</MDI>
      <MDI key="long_name">shortwave downward surface radiative flux</MDI>
      <MDI key="missing_value">-999</MDI>
      <MDI key="NETCDF_VARNAME">flux_swd_sfc</MDI>
      <MDI key="RANGE_MAX">1400</MDI>
      <MDI key="RANGE_MIN">0</MDI>
      <MDI key="SCALED">1</MDI>
      <MDI key="scale_factor">0.042727217</MDI>
      <MDI key="units">W/m^2</MDI>
      <MDI key="valid_max">32766</MDI>
      <MDI key="valid_min">0</MDI>
      <MDI key="_FillValue">32767</MDI>
    </Metadata>
    <NoDataValue>32767</NoDataValue>
    <UnitType>W/m^2</UnitType>
    <Scale>0.04272721707820892</Scale>
    <SimpleSource>
      <SourceFilename relativeToVRT="1">NETCDF:gsipL2_goes13_2014060_0545.nc:flux_swd_sfc</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="5212" RasterYSize="2705" DataType="Int16" BlockXSize="5212" BlockYSize="1" />
      <SrcRect xOff="0" yOff="0" xSize="5212" ySize="2705" />
      <DstRect xOff="0" yOff="0" xSize="5212" ySize="2705" />
    </SimpleSource>
  </VRTRasterBand>
</VRTDataset>

I then called gdalwarp

gdalwarp -geoloc flux_swd_sfc.vrt flux_swd_sfc.tif

However, I get the following errors,

Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
ERROR 2: gdalgeoloc.cpp, 288: cannot allocate 4611686018427387904 bytes
ERROR 2: gdalgeoloc.cpp: 291: Multiplication overflow : 18446744071562067968 * 18446744071562067968 * 4
ERROR 2: gdalgeoloc.cpp: 293: Multiplication overflow : 18446744071562067968 * 18446744071562067968 * 4

I'm hoping that I messed up the implementation somehow and that is why I'm getting those errors. Otherwise, I'm not sure how to get around the overflow issue.

An example file can be downloaded from here.

  • I think you need to set dataType to Float32 in flux_swd_sfc.vrt because you scale with a Float. If my assumption is wrong or that does not help, maybe try to convert the VRTs to GTiff and warp afterwards? Try to add some GDAL_CACHEMAX setting, e.g. --config GDAL_CACHEMAX 1024. – pLumo Jul 11 '18 at 14:37
  • @RoVo I tried setting the dataType="Float32" in the flux_swd_sfc.vrt and adding --config GDAL_CACHEMAX 2014, but neither worked. – user13317 Jul 11 '18 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.