0

I am using this file. I wrote this code.

import rioxarray
import xarray


xds = xarray.open_dataset("LIS_HIST_201401010000.d01 copy.nc")

floodFraction = xds.FloodedFrac_tavg.transpose('east_west','north_south')
floodFraction.rio.set_spatial_dims(x_dim="north_south", y_dim="east_west", inplace=True)
floodFraction.rio.write_crs("EPSG:4326", inplace=True)
floodFraction.rio.to_raster('floodFraction.tif')

After running this script, my terminal shows this

NotGeoreferencedWarning: The given matrix is equal to Affine.identity or its flipped counterpart. GDAL may ignore this matrix and save no geotransform without raising an error. This behavior is somewhat driver-specific.
  s = writer(path, mode, driver=driver,

The obtained tif file looks like this

enter image description here

1

The problem with your dataset is that the lat/lon data is masked:

<xarray.DataArray 'lon' (north_south: 320, east_west: 300)>
array([[      nan,       nan,       nan, ...,       nan,       nan,       nan],
       [      nan,       nan,       nan, ...,       nan,       nan,       nan],
       [      nan,       nan,       nan, ...,       nan,       nan,       nan],
       ...,
       [68.04999 , 68.149994, 68.25    , ..., 97.75    , 97.850006, 97.95001 ],
       [68.04999 , 68.149994, 68.25    , ..., 97.75    , 97.850006, 97.95001 ],
       [68.04999 , 68.149994, 68.25    , ..., 97.75    , 97.850006, 97.95001 ]],

Due to this, the geotransform cannot be properly determined. I would recommend attempting to fill in the masked lat/lon data if you know what it is or can derive it before exporting to a raster.

| improve this answer | |
  • I am still not able to see anything on QGIS. – Shreya Gupta Aug 6 at 7:27
  • The lat/long data you have is written as 2D as well. You will need to convert to 1D. – snowman2 Aug 6 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.