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

sentinel-3: source coordinates use pixel-center convention #1061

Merged
merged 3 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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