[gdal-dev] NetCDF: how to read coordinates from "lon" and "lat" variables?

andy aborruso at gmail.com
Tue Dec 3 05:51:23 PST 2024


Hi Michael,
It seems to work.

Is there no way not to hard-code the GeoTransform, SrcRect, etc.
parameters?

Thank you

<VRTDataset rasterXSize="174" rasterYSize="229">
  <SRS>EPSG:4326</SRS>
  <GeoTransform>4.36, 0.0894, 0.0, 48.88, 0.0, -0.0597</GeoTransform>
  <VRTRasterBand dataType="Float32" band="1">
    <Metadata>
      <MDI key="long_name">NO2 Concentration</MDI>
      <MDI key="units">ppb vol</MDI>
    </Metadata>
    <ComplexSource>
      <SourceFilename relativeToVRT="1">NETCDF:"out.input.nc
":NO2</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="174" RasterYSize="229"
DataType="Float32" BlockXSize="174" BlockYSize="1" />
      <SrcRect xOff="0" yOff="0" xSize="174" ySize="229" />
      <DstRect xOff="0" yOff="0" xSize="174" ySize="229" />
    </ComplexSource>
  </VRTRasterBand>
</VRTDataset>

On Tue, 3 Dec 2024 at 12:02, Michael Sumner <mdsumner at gmail.com> wrote:

> Try
>
> gdalinfo NETCDF:"out.input.nc":NO2
>
> If you see those lon and lat subdatasets listed under "geolocation" then
> you can use gdalwarp to create a georeferenced dataset, automatically with
> gdalwarp sds.in out.tif or by specifying a grid with some of
> -tr,-te,-t_srs,-ts.
>
> If they don't appear they can can be arranged via VRT.
>
> HTH
>
> On Tue, 3 Dec 2024, 21:52 andy via gdal-dev, <gdal-dev at lists.osgeo.org>
> wrote:
>
>> Hi,
>> I have a NetCDF file that I cannot share here.
>>
>> Using gdalinfo I have the below output.
>>
>> Is there any way to tell gdal to read coordinates from the “lon” and
>> “lat” variables/subdatasets, and thus have the coordinates of the vertices
>> not in pixels?
>>
>> Thank you very much
>>
>>
>> Driver: netCDF/Network Common Data Format
>> Files: none associated
>> Size is 512, 512
>> Subdatasets:
>>   SUBDATASET_1_NAME=NETCDF:"out.input.nc":NO2
>>   SUBDATASET_1_DESC=[25x1x229x174] NO2 (32-bit floating-point)
>>   SUBDATASET_2_NAME=NETCDF:"out.input.nc":O3
>>   SUBDATASET_2_DESC=[25x1x229x174] O3 (32-bit floating-point)
>>   SUBDATASET_3_NAME=NETCDF:"out.input.nc":PM10
>>   SUBDATASET_3_DESC=[25x1x229x174] PM10 (32-bit floating-point)
>>   SUBDATASET_4_NAME=NETCDF:"out.input.nc":PM25
>>   SUBDATASET_4_DESC=[25x1x229x174] PM25 (32-bit floating-point)
>>   SUBDATASET_5_NAME=NETCDF:"out.input.nc":Times
>>   SUBDATASET_5_DESC=[25x19] Times (8-bit character)
>>   SUBDATASET_6_NAME=NETCDF:"out.input.nc":lat
>>   SUBDATASET_6_DESC=[229x174] lat (64-bit floating-point)
>>   SUBDATASET_7_NAME=NETCDF:"out.input.nc":lon
>>   SUBDATASET_7_DESC=[229x174] lon (64-bit floating-point)
>>   SUBDATASET_8_NAME=NETCDF:"out.input.nc":pDUST
>>   SUBDATASET_8_DESC=[25x1x229x174] pDUST (32-bit floating-point)
>> Corner Coordinates:
>> Upper Left  (    0.0,    0.0)
>> Lower Left  (    0.0,  512.0)
>> Upper Right (  512.0,    0.0)
>> Lower Right (  512.0,  512.0)
>> Center      (  256.0,  256.0)
>>
>>
>>
>> --
>> ___________________
>>
>> Andrea Borruso
>> website: https://medium.com/tantotanto
>> 38° 7' 48" N, 13° 21' 9" E, EPSG:4326
>> ___________________
>>
>> "cercare e saper riconoscere chi e cosa,
>>  in mezzo all’inferno, non è inferno,
>> e farlo durare, e dargli spazio"
>>
>> Italo Calvino
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>

-- 
___________________

Andrea Borruso
website: https://medium.com/tantotanto
38° 7' 48" N, 13° 21' 9" E, EPSG:4326
___________________

"cercare e saper riconoscere chi e cosa,
 in mezzo all’inferno, non è inferno,
e farlo durare, e dargli spazio"

Italo Calvino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20241203/e575284e/attachment-0001.htm>


More information about the gdal-dev mailing list