Skip to content

Commit e9e31a0

Browse files
mankoffYannChemin
andauthored
r.latlong: return central pixel values for lat or long (#6611)
* Update main.c to return central pixel values for lat or long Ref to issue #3274 from @mankoff * Revert "Update main.c to return central pixel values for lat or long" This reverts commit 20cbf59. * Adjust lat and lon to cell center * Update test --------- Co-authored-by: Yann Chemin <[email protected]>
1 parent 3dfb5b5 commit e9e31a0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

raster/r.latlong/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ int main(int argc, char *argv[])
125125
Rast_get_d_row(infd, inrast, row);
126126

127127
for (col = 0; col < ncols; col++) {
128-
latitude = ymax - ((double)row * stepy);
129-
longitude = xmin + ((double)col * stepx);
128+
latitude = ymax - ((double)row * stepy) - (stepy / 2.0);
129+
longitude = xmin + ((double)col * stepx) + (stepx / 2.0);
130130
if (not_ll) {
131131
if (GPJ_transform(&iproj, &oproj, &tproj, PJ_FWD, &longitude,
132132
&latitude, NULL) < 0)

raster/r.latlong/tests/test_r_latlong.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def test_latlong_lat(setup_maps):
7373
west: 0
7474
rows: 3
7575
cols: 3
76-
3 3 3
77-
2 2 2
78-
1 1 1"""
76+
2.5 2.5 2.5
77+
1.5 1.5 1.5
78+
0.5 0.5 0.5"""
7979

8080
assert ascii_clean == expected_output
8181

@@ -105,9 +105,9 @@ def test_l_flag(setup_maps):
105105
west: 0
106106
rows: 3
107107
cols: 3
108-
0 1 2
109-
0 1 2
110-
0 1 2"""
108+
0.5 1.5 2.5
109+
0.5 1.5 2.5
110+
0.5 1.5 2.5"""
111111

112112
assert ascii_clean == expected_output
113113

0 commit comments

Comments
 (0)