[GRASS-dev] [GRASS GIS] #3930: reprojection error in r.proj / GRASS 7.8.1 -- N-S-coordinates interchanged with W-E

#3930: reprojection error in r.proj / GRASS 7.8.1 -- N-S-coordinates interchanged
with W-E
--------------------------------+---------------------------------
Reporter: guilo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone:
Component: Projections/Datums | Version: git-releasebranch78
Keywords: | CPU: x86-64
Platform: Linux |
--------------------------------+---------------------------------
= Description =

There is observed a serious error in map reprojection, using r.proj,
resulting in an interchange of N-S-coordinates with those of East-West.

The error occurs in GRASS version 7.8 (proj4 version 6.2, gdal version
2.42), in the reprojection with r.proj, from a newly created source map
projection, to an existent target map projection. Repeating the same
procedure, but using a formerly created source map projection (same
projection, but prior to GRASS 7.6), the maps are reprojected in a correct
way.

Under GRASS 7.6, the reprojection procedure is carried out correctly, for
both source map projection versions.

== Minimal working example ==

The example is based on the reprojection of a small section of a Landsat 8
image, from WGS84 / UTM 20N projection, into POSGAR 2007 / Argentina 4
projection. The file "testLandsatUTM20Nsection.tif" is attached to this
mail.

1. system: debian linux 10 (buster), gdal: 2.42, proj4: 6.2

2. new source map projection, created under GRASS 7.8:

  (Thu Oct 3 07:22:23 2019)\\
  g.proj -p\\
  -PROJ_INFO-------------------------------------------------\\
  name : WGS 84 / UTM zone 20N\\
  datum : wgs84\\
  ellps : wgs84\\
  proj : utm\\
  zone : 20\\
  no_defs : defined\\
  towgs84 : 0.000,0.000,0.000\\
  -PROJ_EPSG-------------------------------------------------\\
  epsg : 32620\\
  -PROJ_UNITS------------------------------------------------\\
  unit : meter\\
  units : meters\\
  meters : 1\\
  (Thu Oct 3 07:22:23 2019) Command finished (0 sec)

3. old source map projection, creation with GRASS prior to 7.6)

  (Thu Oct 3 07:31:21 2019)\\
  g.proj -p\\
  -PROJ_INFO-------------------------------------------------\\
  name : Universal Transverse Mercator\\
  proj : utm\\
  datum : wgs84\\
  ellps : wgs84\\
  zone : 20\\
  no_defs : defined\\
  towgs84 : 0.000,0.000,0.000\\
  -PROJ_UNITS------------------------------------------------\\
  unit : meter\\
  units : meters\\
  meters : 1\\
  (Thu Oct 3 07:31:22 2019) Command finished (0 sec)

4. target map projection:

  (Thu Oct 3 07:19:24 2019)\\
  g.proj -p\\
  -PROJ_INFO-------------------------------------------------\\
  name : POSGAR 2007 / Argentina 4\\
  ellps : grs80\\
  proj : tmerc\\
  lat_0 : -90\\
  lon_0 : -63\\
  k : 1\\
  x_0 : 4500000\\
  y_0 : 0\\
  towgs84 : 0,0,0,0,0,0,0\\
  no_defs : defined\\
  -PROJ_EPSG-------------------------------------------------\\
  epsg : 5346\\
  -PROJ_UNITS------------------------------------------------\\
  unit : meter\\
  units : meters\\
  meters : 1\\
  (Thu Oct 3 07:19:24 2019) Command finished (0 sec)

5. Reprojection results:

    5.1 correct reprojection with GRASS 7.6.2, from both, old and new
source projection

     a) from old source projection

     (Sat Nov 2 05:54:58 2019)\\
     r.proj -p location=L8utm20N mapset=PERMANENT
input=testLandsatUTM20Nsection\\
     Source cols: 500\\
     Source rows: 200\\
     Local north: 6959148.60238428\\
     Local south: 6953146.20142391\\
     Local west: 4310724.28971634\\
     Local east: 4325730.29211732\\
     Input map <testLandsatUTM20Nsection@PERMANENT> in location
<L8utm20N>:\\
     (Sat Nov 2 05:54:59 2019) Command finished (0 sec)\\

     b) from new source projection

     r.proj -p location=L8utm20N2019 input=testLandsatUTM20Nsection\\
     Source cols: 500\\
     Source rows: 200\\
     Local north: 6959148.60238428\\
     Local south: 6953146.20142391\\
     Local west: 4310724.28971634\\
     Local east: 4325730.29211732\\
     Input map <testLandsatUTM20Nsection@PERMANENT> in location
<L8utm20N2019>:\\
     (Sat Nov 2 05:56:10 2019) Command finished (0 sec)\\

  5.2 incorrect reprojection in GRASS 7.8.1, from new source projection

   N/S coordinates are interchanged with those of W/E

   r.proj -p location=L8utm20N2019 input=testLandsatUTM20Nsection\\
   Input map <testLandsatUTM20Nsection@PERMANENT> in location
<L8utm20N2019>:\\
   Source cols: 500\\
   Source rows: 200\\
   Local north: 4325730.29211624\\
   Local south: 4310724.28971522\\
   Local west: 6953146.20150881\\
   Local east: 6959148.60246907\\
   (Sat Nov 2 06:01:24 2019) Command finished (0 sec)\\

  5.3 correct reprojection in GRASS 7.8.1, from old source projection

   (Sat Nov 2 05:59:57 2019)\\
   r.proj -p location=L8utm20N mapset=PERMANENT
input=testLandsatUTM20Nsection\\
   Source cols: 500\\
   Source rows: 200\\
   Local north: 6959148.60238337\\
   Local south: 6953146.201423\\
   Local west: 4310724.28971655\\
   Local east: 4325730.29211746\\
   Input map <testLandsatUTM20Nsection@PERMANENT> in location <L8utm20N>:\\
   (Sat Nov 2 05:59:58 2019) Command finished (0 sec)\\

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3930&gt;
GRASS GIS <https://grass.osgeo.org>

#3930: reprojection error in r.proj / GRASS 7.8.1 -- N-S-coordinates interchanged
with W-E
---------------------------------+---------------------------------
  Reporter: guilo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone:
Component: Projections/Datums | Version: git-releasebranch78
Resolution: | Keywords:
       CPU: x86-64 | Platform: Linux
---------------------------------+---------------------------------
Changes (by guilo):

* Attachment "testLandsatUTM20Nsection.tif" added.

small image in geotiff-format, in UTM20N projection

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3930&gt;
GRASS GIS <https://grass.osgeo.org>

#3930: reprojection error in r.proj / GRASS 7.8.1 -- N-S-coordinates interchanged
with W-E
---------------------------------+---------------------------------
  Reporter: guilo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone:
Component: Projections/Datums | Version: git-releasebranch78
Resolution: | Keywords:
       CPU: x86-64 | Platform: Linux
---------------------------------+---------------------------------

Comment (by mmetz):

Replying to [ticket:3930 guilo]:
> = Description =
>
> There is observed a serious error in map reprojection, using r.proj,
resulting in an interchange of N-S-coordinates with those of East-West.
>
> The error occurs in GRASS version 7.8 (proj4 version 6.2, gdal version
2.42), in the reprojection with r.proj, from a newly created source map
projection, to an existent target map projection. Repeating the same
procedure, but using a formerly created source map projection (same
projection, but prior to GRASS 7.6), the maps are reprojected in a correct
way.

You must have used GRASS 7.8.0, not GRASS 7.8.1

This can only happen in GRASS 7.8.0 and has already been fixed in GRASS
7.8.1, soon to be released.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3930#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3930: reprojection error in r.proj / GRASS 7.8.1 -- N-S-coordinates interchanged
with W-E
---------------------------------+---------------------------------
  Reporter: guilo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone:
Component: Projections/Datums | Version: git-releasebranch78
Resolution: | Keywords:
       CPU: x86-64 | Platform: Linux
---------------------------------+---------------------------------

Comment (by guilo):

>> Description

>>There is observed a serious error in map reprojection, using r.proj,
resulting in an interchange of N-S-coordinates with those of East-West.

>>The error occurs in GRASS version 7.8 (proj4 version 6.2, gdal version
2.42), in the reprojection with r.proj, from a newly created source map
projection, to an existent target map projection. Repeating the same
procedure, but using a formerly created source map projection (same
projection, but prior to GRASS 7.6), the maps are reprojected in a correct
way.

>>Under GRASS 7.6, the reprojection procedure is carried out correctly,
for both source map projection versions.

> You must have used GRASS 7.8.0, not GRASS 7.8.1

> This can only happen in GRASS 7.8.0 and has already been fixed in GRASS
7.8.1, soon to be released.

  The version used was GRASS 7.8.1.dev Startup. The error was also observed
with GRASS 7.9.dev Startup.

  Considering your comment, I recompiled today, with updated code, and the
error has gone, in both versions, GRASS 7.8.1.dev (54cf0c2af) and GRASS
7.9.dev Startup (58c5ca582). These latest builds were compiled with proj4
libs version 6.2.1.

  So, the issue is solved. Thank you for your comment.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3930#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3930: reprojection error in r.proj / GRASS 7.8.1 -- N-S-coordinates interchanged
with W-E
---------------------------------+---------------------------------
  Reporter: guilo | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone:
Component: Projections/Datums | Version: git-releasebranch78
Resolution: fixed | Keywords:
       CPU: x86-64 | Platform: Linux
---------------------------------+---------------------------------
Changes (by mmetz):

* status: new => closed
* resolution: => fixed

Comment:

Replying to [comment:2 guilo]:
> Considering your comment, I recompiled today, with updated code, and
the error has gone, in both versions, GRASS 7.8.1.dev (54cf0c2af) and
GRASS 7.9.dev Startup (58c5ca582). These latest builds were compiled with
proj4 libs version 6.2.1.
>
> So, the issue is solved. Thank you for your comment.

Thanks for the confirmation, closing as fixed.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3930#comment:3&gt;
GRASS GIS <https://grass.osgeo.org>