[gdal-dev] NetCDF and EASE-2
Even Rouault
even.rouault at spatialys.com
Sat Feb 1 04:21:39 PST 2020
Chris,
There are 2 issues with this netCDF file:
- the lon,lat indexing is done in a transposed way w.r.t the netCDF
conventions. That is in this file the fastest varying dimension is the
latitude, instead of longitude
- the spacing of the lat variable is not constant
I've a somewhat complicated workflow to propose to create a georeferenced
GeoTIFF file. It assumes you are running GDAL master 3.1.0dev to be able to
use the gdalmdimtranslate utility
1) Create a tiled geotiff
gdal_translate NETCDF:"SD_20160901.nc":snd_upd out.tif -co TILED=YES
2) Transpose it, and also mirror the values in the x and y directions. I'm not
sure why this mirroring is needed at all (at least the one in the horizontal
direction. The one in the version direction might perhaps be explained by a
north-up vs south-up convention difference between netCDF and GeoTIFF)
gdalmdimtranslate out.tif out2.tif -co TILED=YES \
-array band=1,transpose=[1,0],view=[::-1,::-1]
(in theory 1. and 2. could be merged in a single step, but doing the
transposition on the initial netCDF file will be very inefficient. Doing it on
a source tiled file is the best)
3) Create a out2.tif.aux.xml file with the following content
<PAMDataset>
<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">EPSG:4326</MDI>
<MDI key="X_BAND">1</MDI>
<MDI key="X_DATASET">NETCDF:"SD_20160901.nc":lon</MDI>
<MDI key="Y_BAND">1</MDI>
<MDI key="Y_DATASET">NETCDF:"SD_20160901.nc":lat</MDI>
</Metadata>
</PAMDataset>
4) Warp it:
gdalwarp out2.tif out3.tif -overwrite -co TILED=YES
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list