<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div dir="ltr">
<div dir="ltr">
<div>HI Even,</div>
<div><br>
</div>
<div>Thanks for the detailed response. I have compiled master 3.1dev however strangest thing when I try to run it</div>
<div><br>
</div>
<div>$ export PATH=`pwd`/gdal-install/bin:$PATH<br>
$ which gdal_translate<br>
/Users/chris/Documents/science/analysis/gdal-install/bin/gdal_translate<br>
 $ gdal_translate NETCDF:"`pwd`/SD_20160901.nc":snd_upd out.tif -co TILED=YES<br>
ERROR 4: NETCDF:/Users/chris/Documents/science/analysis/SD_20160901.nc:snd_upd: No such file or directory<br>
$ ls /Users/chris/Documents/science/analysis/SD_20160901.nc<br>
/Users/chris/Documents/science/analysis/SD_20160901.nc</div>
<div><br>
</div>
<div>If I try to use my homebrew installed gdal_translate it works.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Trying the 2nd command resulted in</div>
<div><br>
</div>
<div>$ /gdal-install/bin/gdalmdimtranslate out.tif out2.tif -co TILED=YES -array band=1,transpose=[1,0],view=[::-1,::-1]<br>
zsh: no matches found: band=1,transpose=[1,0],view=[::-1,::-1]</div>
<div><br>
</div>
<div>Cheers</div>
<div>Chris<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr" data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div dir="ltr"><span style="font-size:12.8px;color:rgb(102,102,102)">Chris Marsh, PhD</span></div>
<div dir="ltr"><span style="font-size:12.8px;color:rgb(102,102,102)"></span><span><span style="font-size:12.8px;color:rgb(102,102,102)"></span></span><span><span style="font-size:12.8px;color:rgb(102,102,102)">University of Saskatchewan</span></span><br style="font-size:12.8px;color:rgb(102,102,102)">
<span style="font-size:12.8px;color:rgb(102,102,102)"></span><a href="http://chrismarsh.ca/" style="font-size:12.8px;color:rgb(102,102,102)" target="_blank">chrismarsh.ca</a></div>
<span style="color:rgb(102,102,102)"></span><br style="color:rgb(102,102,102)">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sat, Feb 1, 2020 at 6:21 AM Even Rouault <<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>> wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
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
<a href="mailto:phishing@usask.ca" target="_blank">phishing@usask.ca</a><br>
<br>
<br>
Chris,<br>
<br>
There are 2 issues with this netCDF file:<br>
- the lon,lat indexing is done in a transposed way w.r.t the netCDF<br>
conventions. That is in this file the fastest varying dimension is the<br>
latitude, instead of longitude<br>
- the spacing of the lat variable is not constant<br>
<br>
I've a somewhat complicated workflow to propose to create a georeferenced<br>
GeoTIFF file. It assumes you are running GDAL master 3.1.0dev to be able to<br>
use the gdalmdimtranslate utility<br>
<br>
1) Create a tiled geotiff<br>
<br>
gdal_translate NETCDF:"SD_20160901.nc":snd_upd out.tif -co TILED=YES<br>
<br>
2) Transpose it, and also mirror the values in the x and y directions. I'm not<br>
sure why this mirroring is needed at all (at least the one in the horizontal<br>
direction. The one in the version direction might perhaps be explained by a<br>
north-up vs south-up convention difference between netCDF and GeoTIFF)<br>
<br>
gdalmdimtranslate out.tif out2.tif -co TILED=YES \<br>
    -array band=1,transpose=[1,0],view=[::-1,::-1]<br>
<br>
(in theory 1. and 2. could be merged in a single step, but doing the<br>
transposition on the initial netCDF file will be very inefficient. Doing it on<br>
a source tiled file is the best)<br>
<br>
3) Create a out2.tif.aux.xml file with the following content<br>
<br>
<PAMDataset><br>
  <Metadata domain="GEOLOCATION"><br>
    <MDI key="LINE_OFFSET">0</MDI><br>
    <MDI key="LINE_STEP">1</MDI><br>
    <MDI key="PIXEL_OFFSET">0</MDI><br>
    <MDI key="PIXEL_STEP">1</MDI><br>
    <MDI key="SRS">EPSG:4326</MDI><br>
    <MDI key="X_BAND">1</MDI><br>
    <MDI key="X_DATASET">NETCDF:"SD_<a href="http://20160901.nc" target="_blank">20160901.nc</a>":lon</MDI><br>
    <MDI key="Y_BAND">1</MDI><br>
    <MDI key="Y_DATASET">NETCDF:"SD_<a href="http://20160901.nc" target="_blank">20160901.nc</a>":lat</MDI><br>
  </Metadata><br>
</PAMDataset><br>
<br>
4) Warp it:<br>
<br>
gdalwarp out2.tif out3.tif -overwrite -co TILED=YES<br>
<br>
Even<br>
<br>
--<br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
</blockquote>
</div>
</div>
</body>
</html>