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

Convert value outside of ee.Image boundary to NaN. #140

Merged
merged 9 commits into from
Feb 16, 2024

Conversation

dabhicusp
Copy link
Collaborator

Fixed: #131.

As mentioned in the #131, the current code returns 0 values for the external boundary of the clipped region. However, this is incorrect, and therefore, these values should be converted to the NaN values.

Approach: Create a global image with a constant value, and then blend this image with the actual image, ensuring that the original image data is preserved in the final image.

@dabhicusp dabhicusp requested a review from naschmitz February 13, 2024 12:08
@dabhicusp
Copy link
Collaborator Author

The last 2 commit based on the below examples:

Ex:

point = ee.Geometry.Point(-40.2414893624401 ,105.48790177216375 )
distance = 311.5
scale = 5000
projection = ee.Projection("EPSG:4326", [1, 0, 0, 0, -1, 0]).atScale(scale)

geometry = point.buffer(distance, proj=projection).bounds(proj=projection)
geometry.getInfo()

Output:

{'geodesic': False,
 'crs': {'type': 'name', 'properties': {'name': 'EPSG:4326'}},
 'type': 'Polygon',
 'coordinates': [[[-54.232749912601655, 91.49664122200221],
   [-26.250228812278554, 91.49664122200221],
   [-26.250228812278554, 119.47916232232531],
   [-54.232749912601655, 119.47916232232531],
   [-54.232749912601655, 91.49664122200221]]]}

2.) geometry.bounds().getInfo()

{'geodesic': False,
 'type': 'Polygon',
 'coordinates': [[[-54.232749912601655, 91.49664122200221],
   [-26.250228812278554, 91.49664122200221],
   [-26.250228812278554, 91.49664122200221],
   [-54.232749912601655, 91.49664122200221],
   [-54.232749912601655, 91.49664122200221]]]}

So geometry.bounds() is not working properly on the above examples so I updated it with only geometry.

@dabhicusp dabhicusp requested a review from naschmitz February 15, 2024 15:14
@copybara-service copybara-service bot merged commit 3851238 into main Feb 16, 2024
11 checks passed
@dabhicusp dabhicusp deleted the convert_0_to_NaN branch February 17, 2024 09:18
@dabhicusp dabhicusp restored the convert_0_to_NaN branch February 27, 2024 12:36
@dabhicusp dabhicusp deleted the convert_0_to_NaN branch February 27, 2024 12:41
@dabhicusp dabhicusp restored the convert_0_to_NaN branch February 27, 2024 12:48
@dabhicusp dabhicusp deleted the convert_0_to_NaN branch February 27, 2024 12:53
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.

Missing values outside ee.Image boundaries potentially in data range
2 participants