[gdal-dev] NetCDF and EASE-2

Marsh, Chris chris.marsh at usask.ca
Sat Feb 1 16:34:46 PST 2020


HI Even,

Thanks for the detailed response. I have compiled master 3.1dev however strangest thing when I try to run it

$ export PATH=`pwd`/gdal-install/bin:$PATH
$ which gdal_translate
/Users/chris/Documents/science/analysis/gdal-install/bin/gdal_translate
 $ gdal_translate NETCDF:"`pwd`/SD_20160901.nc":snd_upd out.tif -co TILED=YES
ERROR 4: NETCDF:/Users/chris/Documents/science/analysis/SD_20160901.nc:snd_upd: No such file or directory
$ ls /Users/chris/Documents/science/analysis/SD_20160901.nc
/Users/chris/Documents/science/analysis/SD_20160901.nc

If I try to use my homebrew installed gdal_translate it works.

I've also tried without the `pwd` but that doesn't work either. This seems like a stupid PEBKAC but I'm out of ideas.

Trying the 2nd command resulted in

$ /gdal-install/bin/gdalmdimtranslate out.tif out2.tif -co TILED=YES -array band=1,transpose=[1,0],view=[::-1,::-1]
zsh: no matches found: band=1,transpose=[1,0],view=[::-1,::-1]

Cheers
Chris


Chris Marsh, PhD
University of Saskatchewan
chrismarsh.ca<http://chrismarsh.ca/>



On Sat, Feb 1, 2020 at 6:21 AM Even Rouault <even.rouault at spatialys.com<mailto:even.rouault at spatialys.com>> wrote:
CAUTION: This email originated from outside of the University of Saskatchewan. Do not click links or open attachments unless you recognize the sender and know the content is safe. If in doubt, please forward suspicious emails to phishing at usask.ca<mailto:phishing at usask.ca>


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<http://20160901.nc>":lon</MDI>
    <MDI key="Y_BAND">1</MDI>
    <MDI key="Y_DATASET">NETCDF:"SD_20160901.nc<http://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200202/363b8334/attachment.html>


More information about the gdal-dev mailing list