I have some code with a sample geotiff file, I'd like the plot to show the lat/lon coordinates and not the pixel (?) values.
How can I do that?
import rioxarray
fl = 'https://download.osgeo.org/geotiff/samples/gdal_eg/cea.tif'
da = rioxarray.open_rasterio(fl, masked=True)
da.plot()
plt.show()
content of da
:
<xarray.DataArray (band: 1, y: 515, x: 514)>
[264710 values with dtype=float32]
Coordinates:
* band (band) int64 1
* x (x) float64 -2.846e+04 -2.84e+04 ... 2.268e+03 2.328e+03
* y (y) float64 4.256e+06 4.256e+06 ... 4.225e+06 4.225e+06
spatial_ref int64 0
Attributes:
AREA_OR_POINT: Area
scale_factor: 1.0
add_offset: 0.0
I'd like the x and y axis on the plot to display lat/lon coordinates (ie some value between -180 and 180) if possible.
da.lat
and da.lon
are empty