2

I have converted a NetCDF file to Geotiff. However when I display the Geotiff file it appears flipped or upside down. Here is my code:

import xarray as xr 
import rioxarray as rio 
import rasterio

nc_file = xr.open_dataset('Africa_salinity.nc')
nc_file

sss = nc_file['sss']
sss

sss = sss.rio.set_spatial_dims(x_dim='lon', y_dim='lat')
sss.rio.crs

sss.rio.write_crs("epsg:4326", inplace=True)

sss.rio.to_raster(r"Africa_19.tiff")

ax = show((sss))

How can I rotate the file and save it as tiff to use for further analysis?

Nishita
  • 37
  • 1
  • 3

1 Answers1

0

You should be able to fix this using CDO on the command line. The following will likely work:

cdo invertlat infile outfile

This will invert the latitudes as the name suggests

Robert Wilson
  • 3,192
  • 11
  • 19