I am trying to transform an ee.ImageCollection
(Landsat) for a Region of Interest into an xr.Dataset
so I can further process the data and ultimately export as a .csv
. I have tried using the library wxee
. However, values in the resulting xarray only show for certain coordinates, I think because there seems to be a scaling_factor of 1 instead of the true scale of each spectral band (that may be nonsense, but I can't see an alternative). Can anybody help?
Here is the code I have written and an example of the output:
Packages
import geopandas as gpd
import json
import wxee
import ee
Authorise access needed by Earth Engine
ee.Authenticate()
ee.Initialize()
Read in shapefile defining Region of Interest
shapefile = gpd.read_file('/Path/To/Shape')
js = json.loads(shapefile.to_json())
roi = ee.Geometry(ee.FeatureCollection(js).geometry())
Import Landsat 8 and 9 collections
# Filter by Region of Interest
l8 = (ee.ImageCollection('LANDSAT/LC08/C02/T1_L2').filterDate('2013-03-01', '2023-09-30')
.filterBounds(roi)
.select(['SR_B.']))
l9 = (ee.ImageCollection('LANDSAT/LC09/C02/T1_L2').filterDate('2021-10-31', '2023-09-30')
.filterBounds(roi)
.select(['SR_B.']))
# Merge the collections
merged_collection = l8.merge(l9)
Transform to xarray using wx.to_xarray()
ds = merged_collection.wx.to_xarray()