Opened 16 years ago

Last modified 7 years ago

#167 new defect

g.region: reports wrong center longitude and LL bounding box

Reported by: hamish Owned by: grass-dev@…
Priority: major Milestone: 6.4.6
Component: Default Version: svn-develbranch6
Keywords: g.region 180 Cc:
CPU: Unspecified Platform: Unspecified

Description

Hi,

if you set up a region which crosses 180 longitude, g.region -b and -l have problems calculating the center coord:

create a new location using EPSG 3112. (Australia; Lambert CC)

g.region n=1973000 s=-6188000 w=-5175000 e=4846000 res=1000
d.mon x0; d.grid -g 10
# looks ok, if you ignore that grid lines E of 180 are missing

---

g.region -b   # print max LL bounding box (WGS84)
north longitude:  19:37:06.913074N
south longitude:  44:19:08.88403S
west latitude:    69:34:08.058065E
east latitude:    168:13:13.623433E
center latitude:  118:53:40.840749E
center longitude: 12:21:00.985478S

/general/g.region/printwindow.c:

  • lat/lon swapped; "north longitude" -> "North latitude" etc.

after fixing that, the max bounding box calc still is wrong. furthest east is the bottom right corner (165W) but -b reports the value at the top right (168E). [simple a>b test too simple?] That eastern boundary value is used for the center lon calc, so the center lon is wrong as well (skewed to the west).

---

g.region -l    # print lat/lon  (current ellipsoid)
north-west corner: long: 97:34:49.670961E lat: 20:13:08.52602N
north-east corner: long: 168:13:13.623433E lat: 19:37:06.913074N
south-east corner: long: 165:02:10.589072W lat: 44:19:08.88403S
south-west corner: long: 69:34:08.058065E lat: 42:56:48.735964S
center longitude:  42:35:00.190847E
center latitude:   11:51:25.545225S
rows:              8161
cols:              10021

this time it gets the box corners correct but the center longitude is wrong. it's looking around the wrong side of the world and the answer is apparently 180deg out.

also note the center lat is different to the -b version, and that with -l the NW corner's lat is bigger than the NE lat, but for -b max bounding box the more southerly 19:37N is used, not the further out 20:13N.

Hamish

Change History (3)

comment:1 by hamish, 16 years ago

Center coord via another method for comparison:

g.region -c
center easting:  -164500.000000
center northing: -2107500.000000

echo "-164500 -2107500" | m.proj -o --quiet
132d26'33.612"E 18d18'35.426"S 0.000

which doesn't match either -b or -l's version, but looks about right if you plot it over 'd.grid -g 10':

# d.mark from wiki addons
d.mark -m at="-164500,-2107500"

compare:

g.region -l
center longitude:  42:35:00.190847E + 180 = +137.4166137
center latitude:   11:51:25.545225S

echo "137.4166137 11d51'25.545225\"S" | m.proj -i --quiet
380455.32       -1390800.80 0.00
d.mark -m at="380455.32,-1390800.80" fcolor=red
## (off a way to the NE)
g.region -b
center [lon]: 118:53:40.840749E 
center [lat]: 12:21:00.985478S

echo "118d53'40.840749\"E 12d21'00.985478\"S" | m.proj -i --quiet
-1671525.94     -1541908.71 0.00
d.mark -m at="-1671525.94,-1541908.71" fcolor=blue
## (off even further away to the NW)

Hamish

comment:2 by neteler, 8 years ago

Milestone: 6.4.06.4.6

comment:3 by mmetz, 7 years ago

CPU: Unspecified
Platform: Unspecified

These calculations can not be performed with longitudes wrapped to [-180, 180], fixed in trunk r70671.

g.region -l (Print the current region in lat/long using the current ellipsoid/datum) prints the corners and now also the center of the current region projected to lat/long.

g.region -b (Print the maximum bounding box in lat/long on WGS84) now tries to estimate the maximum bounding box based not only on the corners but also on the boundaries using the resolution of the current region. The result is a more realistic bounding box in lat/long. The reported center coordinates are the center coordinates of the lat/long box, not of the current window.

g.region -n (Print the convergence angle (degrees CCW). The difference between the projection's grid north and true north, measured at the center coordinates of the current region.) is now using the center coordinates of the current region projected to lat/long.

Note: See TracTickets for help on using tickets.