Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support added for the int datatype earth engine image. #149

Merged
merged 9 commits into from
Mar 13, 2024

Conversation

dabhicusp
Copy link
Collaborator

The existing code of the Xee is incapable of processing the Earth Engine images which have data of integer datatype. As illustrated in the example below, instead of yielding a "NaN" value, it produces a value that is one less than the ee_mask_value. For instance, if the ee_mask_value is set to -99990, the code will return -99989.

Ex.:
Before :

image = ee.Image('USGS/GMTED2010').select('be75')
proj_4326 = ee.Projection('EPSG:4326', [1, 0, 0, 0, -1, 0]).atScale(10000)
image = image.reproject(proj_4326)
geom = ee.Geometry.Rectangle( [[-179.99, -80], [179.99, 80]], None, geodesic=False,)
ic = ee.ImageCollection([image])
ds = xarray.open_dataset(ic, projection=image.projection(), geometry=geom,
     ee_mask_value=-99999, engine='ee'
)
ds.be75.values

Result:

array([[[     0.,      0.,      0., ..., -99998., -99998., -99998.],
        [     0.,      0.,      0., ..., -99998., -99998., -99998.],
        [     0.,      0.,      0., ..., -99998., -99998., -99998.],
        ...,
        [     0.,      0.,      0., ..., -99998., -99998., -99998.],
        [     0.,      0.,      0., ..., -99998., -99998., -99998.],
        [     0.,      0.,      0., ..., -99998., -99998., -99998.]]])

After updating the code :

ic = ee.ImageCollection([image])
ds = ee_local_class.open_dataset(ic, projection=image.projection(), geometry=geom,
     ee_mask_value=-99999,
)
ds.be75.values

Result:

array([[[ 0.,  0.,  0., ..., nan, nan, nan],
        [ 0.,  0.,  0., ..., nan, nan, nan],
        [ 0.,  0.,  0., ..., nan, nan, nan],
        ...,
        [ 0.,  0.,  0., ..., nan, nan, nan],
        [ 0.,  0.,  0., ..., nan, nan, nan],
        [ 0.,  0.,  0., ..., nan, nan, nan]]])

Copy link
Collaborator

@naschmitz naschmitz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an integration test case that would've failed before but passes now?

@mahrsee1997 mahrsee1997 requested a review from naschmitz March 7, 2024 12:24
@copybara-service copybara-service bot merged commit 10c79ec into main Mar 13, 2024
11 checks passed
@dabhicusp dabhicusp deleted the ee_int_image branch March 13, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants