<div dir="ltr">in short, take the grid specification you want and pass it to gdalwarp, you need the subdataset syntax of the particular variable <div><br></div><div>you need target extent "-te xmin ymin xmax ymax" and  target size "-ts width height" (or use target resolution "-tr ...."  for a given pixel size) and -t_srs "EPSG:3857" (a compressed lookup syntax of the full srs string, see it at the bottom of the WKT) </div><div><br></div><div>First check you have a fully fledged srs string in the source "Coordinate System is:"</div><div><br></div><div>gdalinfo NETCDF:"/home/me/<a href="http://netcdf_file.nc/" target="_blank">netcdf_file.nc</a>":hs<br></div><div><br></div><div>if not you can add it with -a_srs in the gdal_translate step below. </div><div><br></div><div>Always a good idea to do a quick test first (take away the -b argument once you're satisfied to write all bands to the final tif). </div><div><br></div><div>gdal_translate NETCDF:"/home/me/<a href="http://netcdf_file.nc/" target="_blank">netcdf_file.nc</a>":hs -b 1 band1.vrt</div><div>gdalwarp band1.vrt  tiff_test.tif -ts 4000 4000 -te -1160000.000 6600000.000 40000.000  7800000.000 -t_srs </div><div><br></div><div>We can't advise on the right -a_srs if the "Coordinate System is:" element is missing in the source gdalinfo, please share that output if you have follow up questions.  For deeper investigation having the actual file can be necessary. </div><div><br></div><div>Consider the -r argument for resampling by gdalwarp, nearest neighbour is the default. </div><div><br></div><div>Finally, you say "WGS84" but provide Pseudo Mercator world grid - sometimes "WGS84" means "latitude/longitude ..." - but I've just taken your request as given. The principle always applies, good extent and srs info for the input, provide any extent, dimension, srs request for the output and the warper sorts it out. </div><div><br></div><div>HTH, Mike</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 15, 2023 at 5:12 AM Javier Garcia <<a href="mailto:tirengarfio@gmail.com">tirengarfio@gmail.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"><div dir="ltr"><div>Hi,</div><div><br></div><div>I would like to convert the next NetCDF file to a GeoTIFF WGS 84.</div><br>NetCDF file `gdalinfo` output:<br><br>Driver: netCDF/Network Common Data Format<br>Files: /home/me/<a href="http://netcdf_file.nc" target="_blank">netcdf_file.nc</a><br>Size is 512, 512<br>Metadata:<br>  NC_GLOBAL#altimetry=altiCERSAT<br>  NC_GLOBAL#altitude_resolution=n/a<br>  NC_GLOBAL#area=Ireland 2 min wave grid<br>  NC_GLOBAL#BETAMAX=1.52<br>  NC_GLOBAL#CICE0=0.25<br>  NC_GLOBAL#CICEN=0.75<br>  NC_GLOBAL#comment=<br>  NC_GLOBAL#contact=<a href="mailto:waves@mycompany.com" target="_blank">waves@mycompany.com</a><br>  NC_GLOBAL#Conventions=CF-1.5<br>  NC_GLOBAL#creation_date=2017-07-27T12:20:30Z<br>  NC_GLOBAL#data_type=SWASH straight grid<br>  NC_GLOBAL#easternmost_longitude=-1.0333328<br>  NC_GLOBAL#easting=longitude<br>  NC_GLOBAL#field_type=hourly<br>  NC_GLOBAL#FLAGTR=4<br>  NC_GLOBAL#forcing_ice=iceCFSR<br>  NC_GLOBAL#forcing_wind=wndCFSR<br>  NC_GLOBAL#forecast_range=analysis<br>  NC_GLOBAL#forecast_type=hindcast<br>  NC_GLOBAL#grid=irluk-2m<br>  NC_GLOBAL#grid_projection=n/a<br>  NC_GLOBAL#history=2017-07-27T12:20:30Z : Creation<br>  NC_GLOBAL#institution=My Company<br>  NC_GLOBAL#institution_references=<a href="http://www.mycompany.com/" target="_blank">http://www.mycompany.com/</a><br>  NC_GLOBAL#latitude_resolution=   0.0333333<br>  NC_GLOBAL#longitude_resolution=   0.0333333<br>  NC_GLOBAL#maximum_altitude=9000 m<br>  NC_GLOBAL#minimum_altitude=-12000 m<br>  NC_GLOBAL#netcdf_version=netCDF 4.3.0<br>  NC_GLOBAL#northernmost_latitude=59.5000000<br>  NC_GLOBAL#northing=latitude<br>  NC_GLOBAL#product_name=<a href="http://ww3.irluk-2m.199501_hs.nc" target="_blank">ww3.irluk-2m.199501_hs.nc</a><br>  NC_GLOBAL#product_version=1.0<br>  NC_GLOBAL#REFCOAST=0.05<br>  NC_GLOBAL#references=<a href="http://www.mycompany.com/waves/" target="_blank">http://www.mycompany.com/waves/</a><br>  NC_GLOBAL#REFICEBERG=0.3<br>  NC_GLOBAL#REFSUBGRID=0.05<br>  NC_GLOBAL#run_time=2017-07-27T12:20:30Z<br>  NC_GLOBAL#SDS4 namelist parameter WHITECAPWIDTH=0.30000001<br>  NC_GLOBAL#source=TWM WAVEWATCH III (R) v4.18<br>  NC_GLOBAL#southernmost_latitude=49.5000000<br>  NC_GLOBAL#start_date=1995-01-01T00:00:00Z<br>  NC_GLOBAL#stop_date=1995-01-31T23:00:00Z<br>  NC_GLOBAL#title=TWM SWASH HINDCAST<br>  NC_GLOBAL#WAVEWATCH_III_switches=F90 NOGRB NOPA LRB4 SHRD PR3 UQ FLX0 LN1 ST4 STAB0 NL1 BT4 DB1 MLIM TR0 BS0 IC0 REF1 XX0 WNT1 WNX1 CRT1 CRX1 O0 O1 O2 O3 O4 O5 O6 O7 011 NC4 TRKNC IS0<br>  NC_GLOBAL#WAVEWATCH_III_version_number=4.18b<br>  NC_GLOBAL#westernmost_longitude=-12.0000000<br>Subdatasets:<br>  SUBDATASET_1_NAME=NETCDF:"/home/me/<a href="http://netcdf_file.nc" target="_blank">netcdf_file.nc</a>":MAPSTA<br>  SUBDATASET_1_DESC=[301x330] status map (16-bit integer)<br>  SUBDATASET_2_NAME=NETCDF:"/home/me/<a href="http://netcdf_file.nc" target="_blank">netcdf_file.nc</a>":hs<br>  SUBDATASET_2_DESC=[744x301x330] sea_surface_wave_significant_height (32-bit floating-point)<br>Corner Coordinates:<br>Upper Left  (    0.0,    0.0)<br>Lower Left  (    0.0,  512.0)<br>Upper Right (  512.0,    0.0)<br>Lower Right (  512.0,  512.0)<br>Center      (  256.0,  256.0)<br><br><br>I'm expecting as output a file with WGS 84 projection like this: <br><br>`gdalinfo` output:<br><br><br>Driver: GTiff/GeoTIFF<br>Files: tiff_file.tif<br>Size is 4000, 4000<br>Coordinate System is:<br>PROJCRS["WGS 84 / Pseudo-Mercator",<br>    BASEGEOGCRS["WGS 84",<br>        DATUM["World Geodetic System 1984",<br>            ELLIPSOID["WGS 84",6378137,298.257223563,<br>                LENGTHUNIT["metre",1]]],<br>        PRIMEM["Greenwich",0,<br>            ANGLEUNIT["degree",0.0174532925199433]],<br>        ID["EPSG",4326]],<br>    CONVERSION["Popular Visualisation Pseudo-Mercator",<br>        METHOD["Popular Visualisation Pseudo Mercator",<br>            ID["EPSG",1024]],<br>        PARAMETER["Latitude of natural origin",0,<br>            ANGLEUNIT["degree",0.0174532925199433],<br>            ID["EPSG",8801]],<br>        PARAMETER["Longitude of natural origin",0,<br>            ANGLEUNIT["degree",0.0174532925199433],<br>            ID["EPSG",8802]],<br>        PARAMETER["False easting",0,<br>            LENGTHUNIT["metre",1],<br>            ID["EPSG",8806]],<br>        PARAMETER["False northing",0,<br>            LENGTHUNIT["metre",1],<br>            ID["EPSG",8807]]],<br>    CS[Cartesian,2],<br>        AXIS["easting (X)",east,<br>            ORDER[1],<br>            LENGTHUNIT["metre",1]],<br>        AXIS["northing (Y)",north,<br>            ORDER[2],<br>            LENGTHUNIT["metre",1]],<br>    USAGE[<br>        SCOPE["unknown"],<br>        AREA["World - 85°S to 85°N"],<br>        BBOX[-85.06,-180,85.06,180]],<br>    ID["EPSG",3857]]<br>Data axis to CRS axis mapping: 1,2<br>Origin = (-1160000.000000000000000,7799999.999999998137355)<br>Pixel Size = (300.000000000000000,-300.000000000000000)<br>Metadata:<br>  AREA_OR_POINT=Area<br>Image Structure Metadata:<br>  COMPRESSION=LZW<br>  INTERLEAVE=PIXEL<br>Corner Coordinates:<br>Upper Left  (-1160000.000, 7800000.000) ( 10d25'13.65"W, 57d11'40.60"N)<br>Lower Left  (-1160000.000, 6600000.000) ( 10d25'13.65"W, 50d52'46.07"N)<br>Upper Right (   40000.000, 7800000.000) (  0d21'33.57"E, 57d11'40.60"N)<br>Lower Right (   40000.000, 6600000.000) (  0d21'33.57"E, 50d52'46.07"N)<br>Center      ( -560000.000, 7200000.000) (  5d 1'50.04"W, 54d 9'26.21"N)<br>Band 1 Block=4000x1 Type=Byte, ColorInterp=Red<br>  Mask Flags: PER_DATASET ALPHA <br>Band 2 Block=4000x1 Type=Byte, ColorInterp=Green<br>  Mask Flags: PER_DATASET ALPHA <br>Band 3 Block=4000x1 Type=Byte, ColorInterp=Blue<br>  Mask Flags: PER_DATASET ALPHA <br>Band 4 Block=4000x1 Type=Byte, ColorInterp=Alpha<br><br><br><div>Any help will be appreciated.</div><div><br></div><div>Javier<br></div></div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Michael Sumner<br>Software and Database Engineer<br>Australian Antarctic Division<br>Hobart, Australia<br>e-mail: <a href="mailto:mdsumner@gmail.com" target="_blank">mdsumner@gmail.com</a></div>