oh dear I missed a key element in the actual command: gdalwarp band1.vrt tiff_test.tif -ts 4000 4000 -te -1160000.000 6600000.000 40000.000 7800000.000 -t_srs "EPSG:3857"
Best On Thu, Feb 23, 2023 at 6:35 PM Michael Sumner <mdsum...@gmail.com> wrote: > in short, take the grid specification you want and pass it to gdalwarp, > you need the subdataset syntax of the particular variable > > 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) > > First check you have a fully fledged srs string in the source "Coordinate > System is:" > > gdalinfo NETCDF:"/home/me/netcdf_file.nc":hs > > if not you can add it with -a_srs in the gdal_translate step below. > > 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). > > gdal_translate NETCDF:"/home/me/netcdf_file.nc":hs -b 1 band1.vrt > gdalwarp band1.vrt tiff_test.tif -ts 4000 4000 -te -1160000.000 > 6600000.000 40000.000 7800000.000 -t_srs > > 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. > > Consider the -r argument for resampling by gdalwarp, nearest neighbour is > the default. > > 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. > > HTH, Mike > > > > On Wed, Feb 15, 2023 at 5:12 AM Javier Garcia <tirengar...@gmail.com> > wrote: > >> Hi, >> >> I would like to convert the next NetCDF file to a GeoTIFF WGS 84. >> >> NetCDF file `gdalinfo` output: >> >> Driver: netCDF/Network Common Data Format >> Files: /home/me/netcdf_file.nc >> Size is 512, 512 >> Metadata: >> NC_GLOBAL#altimetry=altiCERSAT >> NC_GLOBAL#altitude_resolution=n/a >> NC_GLOBAL#area=Ireland 2 min wave grid >> NC_GLOBAL#BETAMAX=1.52 >> NC_GLOBAL#CICE0=0.25 >> NC_GLOBAL#CICEN=0.75 >> NC_GLOBAL#comment= >> NC_GLOBAL#contact=wa...@mycompany.com >> NC_GLOBAL#Conventions=CF-1.5 >> NC_GLOBAL#creation_date=2017-07-27T12:20:30Z >> NC_GLOBAL#data_type=SWASH straight grid >> NC_GLOBAL#easternmost_longitude=-1.0333328 >> NC_GLOBAL#easting=longitude >> NC_GLOBAL#field_type=hourly >> NC_GLOBAL#FLAGTR=4 >> NC_GLOBAL#forcing_ice=iceCFSR >> NC_GLOBAL#forcing_wind=wndCFSR >> NC_GLOBAL#forecast_range=analysis >> NC_GLOBAL#forecast_type=hindcast >> NC_GLOBAL#grid=irluk-2m >> NC_GLOBAL#grid_projection=n/a >> NC_GLOBAL#history=2017-07-27T12:20:30Z : Creation >> NC_GLOBAL#institution=My Company >> NC_GLOBAL#institution_references=http://www.mycompany.com/ >> NC_GLOBAL#latitude_resolution= 0.0333333 >> NC_GLOBAL#longitude_resolution= 0.0333333 >> NC_GLOBAL#maximum_altitude=9000 m >> NC_GLOBAL#minimum_altitude=-12000 m >> NC_GLOBAL#netcdf_version=netCDF 4.3.0 >> NC_GLOBAL#northernmost_latitude=59.5000000 >> NC_GLOBAL#northing=latitude >> NC_GLOBAL#product_name=ww3.irluk-2m.199501_hs.nc >> NC_GLOBAL#product_version=1.0 >> NC_GLOBAL#REFCOAST=0.05 >> NC_GLOBAL#references=http://www.mycompany.com/waves/ >> NC_GLOBAL#REFICEBERG=0.3 >> NC_GLOBAL#REFSUBGRID=0.05 >> NC_GLOBAL#run_time=2017-07-27T12:20:30Z >> NC_GLOBAL#SDS4 namelist parameter WHITECAPWIDTH=0.30000001 >> NC_GLOBAL#source=TWM WAVEWATCH III (R) v4.18 >> NC_GLOBAL#southernmost_latitude=49.5000000 >> NC_GLOBAL#start_date=1995-01-01T00:00:00Z >> NC_GLOBAL#stop_date=1995-01-31T23:00:00Z >> NC_GLOBAL#title=TWM SWASH HINDCAST >> 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 >> NC_GLOBAL#WAVEWATCH_III_version_number=4.18b >> NC_GLOBAL#westernmost_longitude=-12.0000000 >> Subdatasets: >> SUBDATASET_1_NAME=NETCDF:"/home/me/netcdf_file.nc":MAPSTA >> SUBDATASET_1_DESC=[301x330] status map (16-bit integer) >> SUBDATASET_2_NAME=NETCDF:"/home/me/netcdf_file.nc":hs >> SUBDATASET_2_DESC=[744x301x330] sea_surface_wave_significant_height >> (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) >> >> >> I'm expecting as output a file with WGS 84 projection like this: >> >> `gdalinfo` output: >> >> >> Driver: GTiff/GeoTIFF >> Files: tiff_file.tif >> Size is 4000, 4000 >> Coordinate System is: >> PROJCRS["WGS 84 / Pseudo-Mercator", >> BASEGEOGCRS["WGS 84", >> DATUM["World Geodetic System 1984", >> ELLIPSOID["WGS 84",6378137,298.257223563, >> LENGTHUNIT["metre",1]]], >> PRIMEM["Greenwich",0, >> ANGLEUNIT["degree",0.0174532925199433]], >> ID["EPSG",4326]], >> CONVERSION["Popular Visualisation Pseudo-Mercator", >> METHOD["Popular Visualisation Pseudo Mercator", >> ID["EPSG",1024]], >> PARAMETER["Latitude of natural origin",0, >> ANGLEUNIT["degree",0.0174532925199433], >> ID["EPSG",8801]], >> PARAMETER["Longitude of natural origin",0, >> ANGLEUNIT["degree",0.0174532925199433], >> ID["EPSG",8802]], >> PARAMETER["False easting",0, >> LENGTHUNIT["metre",1], >> ID["EPSG",8806]], >> PARAMETER["False northing",0, >> LENGTHUNIT["metre",1], >> ID["EPSG",8807]]], >> CS[Cartesian,2], >> AXIS["easting (X)",east, >> ORDER[1], >> LENGTHUNIT["metre",1]], >> AXIS["northing (Y)",north, >> ORDER[2], >> LENGTHUNIT["metre",1]], >> USAGE[ >> SCOPE["unknown"], >> AREA["World - 85°S to 85°N"], >> BBOX[-85.06,-180,85.06,180]], >> ID["EPSG",3857]] >> Data axis to CRS axis mapping: 1,2 >> Origin = (-1160000.000000000000000,7799999.999999998137355) >> Pixel Size = (300.000000000000000,-300.000000000000000) >> Metadata: >> AREA_OR_POINT=Area >> Image Structure Metadata: >> COMPRESSION=LZW >> INTERLEAVE=PIXEL >> Corner Coordinates: >> Upper Left (-1160000.000, 7800000.000) ( 10d25'13.65"W, 57d11'40.60"N) >> Lower Left (-1160000.000, 6600000.000) ( 10d25'13.65"W, 50d52'46.07"N) >> Upper Right ( 40000.000, 7800000.000) ( 0d21'33.57"E, 57d11'40.60"N) >> Lower Right ( 40000.000, 6600000.000) ( 0d21'33.57"E, 50d52'46.07"N) >> Center ( -560000.000, 7200000.000) ( 5d 1'50.04"W, 54d 9'26.21"N) >> Band 1 Block=4000x1 Type=Byte, ColorInterp=Red >> Mask Flags: PER_DATASET ALPHA >> Band 2 Block=4000x1 Type=Byte, ColorInterp=Green >> Mask Flags: PER_DATASET ALPHA >> Band 3 Block=4000x1 Type=Byte, ColorInterp=Blue >> Mask Flags: PER_DATASET ALPHA >> Band 4 Block=4000x1 Type=Byte, ColorInterp=Alpha >> >> >> Any help will be appreciated. >> >> Javier >> _______________________________________________ >> gdal-dev mailing list >> gdal-dev@lists.osgeo.org >> https://lists.osgeo.org/mailman/listinfo/gdal-dev >> > > > -- > Michael Sumner > Software and Database Engineer > Australian Antarctic Division > Hobart, Australia > e-mail: mdsum...@gmail.com > -- Michael Sumner Software and Database Engineer Australian Antarctic Division Hobart, Australia e-mail: mdsum...@gmail.com
_______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/gdal-dev