Skip to content

Commit

Permalink
sentinel-3: source coordinates use pixel-center convention (#1061)
Browse files Browse the repository at this point in the history
* sentinel-3: source coordinates use pixel-center convention

* ref update

* sentinel-3: source coordinates use pixel-center convention
  • Loading branch information
jdries authored Feb 20, 2025
1 parent da18deb commit b9f43ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions openeogeotrellis/collections/sentinel3.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,20 @@ def create_final_grid(final_bbox, resolution, rim_pixels=0 ):
Returns
-------
target_coordinates: float
A 2D-array containing the final coordinates
A 2D-array containing the final coordinates of pixel centers
target_shape : (int,int)
A tuple containing the number of rows/columns
"""

final_xmin, final_ymin, final_xmax, final_ymax = final_bbox
#the boundingbox of the tile seems to missing the last pixels, that is why we add 1 resolution to the second argument
# target coordinates have to be computed as pixel centers
grid_x, grid_y = np.meshgrid(
np.arange(final_xmin - (rim_pixels * resolution), final_xmax + resolution +(rim_pixels * resolution), resolution),
np.arange(final_ymax + (rim_pixels * resolution), final_ymin - resolution - (rim_pixels * resolution), -resolution) # without lat mirrored
np.arange(final_xmin + 0.5 * resolution - (rim_pixels * resolution),
final_xmax - 0.5 * resolution + resolution + (rim_pixels * resolution), resolution),
np.arange(final_ymax - 0.5 * resolution + (rim_pixels * resolution),
final_ymin + 0.5 * resolution - resolution - (rim_pixels * resolution),
-resolution) # without lat mirrored
# np.arange(ref_ymin, ref_ymax, self.final_grid_resolution) #with lat mirrored
)
target_shape = grid_x.shape
Expand Down
2 changes: 1 addition & 1 deletion tests/data/binary
10 changes: 5 additions & 5 deletions tests/data_collections/test_sentinel3.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def test_read_single_edge_with_some_data():
"instant":1717326516089,
},
"key_extent":{
"xmin":13.86,"xmax":18.10,"ymin":47.096,"ymax":47.597
"xmin":13.857467,"xmax":18.10,"ymin":47.096,"ymax":47.597925
},
"key_epsg":4326
}
Expand All @@ -112,13 +112,13 @@ def test_read_single_edge_with_some_data():

#instant should be rounded to the minute
assert spacetimekey.instant == datetime(2024, 6, 2, 11, 8,0)
from rasterio.transform import from_origin, from_bounds
# from rasterio.transform import from_origin, from_bounds

arr = result[0][1].cells

transform = from_bounds(13.86, 47.096, 18.10, 47.597, arr.shape[2], arr.shape[1])

# new_dataset = rasterio.open('ref_file_edge3.tif', 'w', driver='GTiff',
# transform = from_bounds(13.857467, 47.096, 18.10, 47.597925, arr.shape[2], arr.shape[1])
#
# new_dataset = rasterio.open('ref_file_edge_shift.tif', 'w', driver='GTiff',
# height=arr.shape[1], width=arr.shape[2],
# count=2, dtype=str(arr.dtype),
# crs=CRS.from_epsg(4326),
Expand Down

0 comments on commit b9f43ec

Please sign in to comment.