Closed simonff closed 8 months ago
Hello @simonff I thought 2x2 is true as I tried the below native approach and in this approach the result is same. Can you tell us why are you expecting 1x1 if scale is 463m.
import numpy as np
image = ee.Image.pixelCoordinates(ee.Projection(SIN))
scale = 463.3127165279165
x_min, y_min, x_max, y_max = 4447800, -2223901, 4448801, -2222900
x_size = int(np.round((x_max - x_min) / np.abs(scale)))
y_size = int(np.round((y_max - y_min) / np.abs(scale)))
kwargs = {
"grid": {
"dimensions": {"width": x_size, "height": y_size},
"affineTransform": {
"translateX": x_min,
"translateY": y_max,
"scaleX": scale,
"scaleY": scale * (-1),
},
"crsCode": SIN,
},
}
params = {
"expression": image,
"fileFormat": "NUMPY_NDARRAY",
**kwargs,
}
result = ee.data.computePixels(params)
result
result:
array([[(4448031.65635826, -2223131.65635826),
(4448494.96907479, -2223131.65635826)],
[(4448031.65635826, -2223594.96907479),
(4448494.96907479, -2223594.96907479)]],
dtype=[('x', '<f8'), ('y', '<f8')])
P.S. I updated my code with this PR that's why I got the result in meter.
https://github.com/google/Xee/pull/120 fixed this
This seems like it should give me just one pixel because I'm asking for a 1x1 meter rectangle from a dataset whose scale is 463m:
Problem 1: I get ee_exception.EEException: Geometry.bounds: Unable to perform this geometry operation. Please specify a non-zero error margin. because this call doesn't have an error margin rpcs.append(('bounds', self.geometry.bounds()))
If I change it to rpcs.append(('bounds', self.geometry.bounds(1))), I get
Problem 2: The code now works, but returns a 3x2 array, not 1x1.
I think this happens because of a double conversion from projection units (meters) to degrees and then back in
At the end self.bounds is (4454267.556539465, -2212366.2541716346, 4455777.874164572, -2211369.618782846) while we started from (4447800,-2223901,4448801,-2222900)
If I simply hardcode self. bounds to be exactly what I pass, I get
Problem 3. Even so I get back a 2x2 array, not 1x1