0

I am having an issue with geolocation of TIF and netCDF files.

First, I convert swath data to grid data with the ECOSTRESS_swath2grid.py script proposed here: https://github.com/spestana/ECOSTRESS_swath2grid.

In the netCDF saving file method, I define gridded longitude and latitude matrices with: lons_netcdf, lats_netcdf = areaDef.get_lonlats()

In the TIF saving file method, I define geotransform vector with the same areaDef variable used in the netCDF method, such as: gt = [areaDef.area_extent[0], ps, 0, areaDef.area_extent[3], 0, -ps].

Then, opening both files in Qgis, I realized there was an offset of 8 m at the east of the images between pixels of TIF and netCDF files. I haven’t notice latitudinal offset.

Thus, I compared the differences between geoTIFF longitude and latitude arrays and those of the netCDF file.

To define lon_tif and lat_tif variable, I open the newly saved TIF file with rioxarray and select x and y variable data, such as: tif = xr.open_rasterio(outName) lon_tif = tif.x.data lat_tif = tif.y.data

I get the following results :

for longitude

np.unique(lon_tif – lons_netcdf[0,:])

array([5.94099880e-09, 1.78229955e-08, 2.97049922e-08, ..., 1.31907991e-04, 1.31919873e-04, 1.31931755e-04])

len(np.unique(lon_tif – lons_netcdf[0,:]))

11104

np.max(np.unique(lon_tif – lons_netcdf[0,:]))

0.0001319317554191457

for latitude

np.unique(lat_tif - lats_netcdf[:,0])

array([-1.42108547e-14, -7.10542736e-15, 0.00000000e+00])

Why is there a difference in gelocation between areaDef.get_lonlats() and geotransform methods ? And which method is the best to get gridded latitude and longitude ? Note that both tif and netcdf longitude and latitude are in float64 dtype.

lopoly
  • 1

0 Answers0