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

PROJ6+ + WKT2 support #1240

Merged
merged 9 commits into from Jan 27, 2021
Merged

PROJ6+ + WKT2 support #1240

merged 9 commits into from Jan 27, 2021

Conversation

metzm
Copy link
Contributor

@metzm metzm commented Jan 10, 2021

New GRASS locations now store the projection definition also in WKT (WKT2 with GDAL 3 / PROJ 6) and the spatial reference ID (SRID) if available. Two new files are (if possible) created for a new location: PERMANENT/PROJ_SRID and PERMANENT/PROJ_WKT. The file PERMANENT/PROJ_EPSG is no longer created and superseeded by PROJ_SRID which supports not only EPSG, but also other authorities. An existing file PERMANENT/PROJ_EPSG is read if PROJ_SRID does not exist.

For reprojections, the priority of spatial reference definitions is 1. SRID, 2. WKT, 3. PROJ4 style from GRASS definition

changed libraries
gis, proj

changed modules
g.proj, r.proj, v.proj, r.in.gdal, v.in.ogr, r.external, v.external, r.out.gdal, v.out.ogr

This PR also solves qgis/QGIS#18596 (comment)

testing
reprojection from/to a CRS with neither meters nor degrees as units might not convert coordinates to map units

use location nc_spm_08
EPSG:3358
NAD83(HARN) / North Carolina

CRS with feet as units
EPSG:2264
NAD83 / North Carolina (ftUS)
location nc_epsg_2264

CRS with different datum
EPSG:32617
UTM zone 17N
location nc_epsg_32617

reprojection with projection definitions from SRIDs

reproject nc_state from nc_spm_08 to location nc_epsg_2264 to location nc_epsg_32617 and back to nc_spm_08

v.proj location=nc_spm_08 mapset=PERMANENT input=nc_state output=nc_state_srid_1
v.proj location=nc_epsg_2264 mapset=PERMANENT input=nc_state_srid_1 output=nc_state_srid_1
v.proj location=nc_epsg_32617 mapset=PERMANENT input=nc_state_srid_1 output=nc_state_srid_1

reproject nc_state from nc_spm_08 to location nc_epsg_32617 to location nc_epsg_2264 and back to nc_spm_08

v.proj location=nc_spm_08 mapset=PERMANENT input=nc_state output=nc_state_srid_2
v.proj location=nc_epsg_32617 mapset=PERMANENT input=nc_state_srid_1 output=nc_state_srid_2
v.proj location=nc_epsg_2264 mapset=PERMANENT input=nc_state_srid_1 output=nc_state_srid_2

end results in nc_spm_08 should be identical (within floating point precision limits)

now rename all PROJ_EPSG, PROJ_SRID, and PROJ_WKT files in the three locations

reprojection with standard GRASS projection definitions

reproject nc_state from nc_spm_08 to location nc_epsg_2264 to location nc_epsg_32617 and back to nc_spm_08

v.proj location=nc_spm_08 mapset=PERMANENT input=nc_state output=nc_state_grass_1
v.proj location=nc_epsg_2264 mapset=PERMANENT input=nc_state_srid_1 output=nc_state_grass_1
v.proj location=nc_epsg_32617 mapset=PERMANENT input=nc_state_srid_1 output=nc_state_grass_1

reproject nc_state from nc_spm_08 to location nc_epsg_32617 to location nc_epsg_2264 and back to nc_spm_08

v.proj location=nc_spm_08 mapset=PERMANENT input=nc_state output=nc_state_grass_2
v.proj location=nc_epsg_32617 mapset=PERMANENT input=nc_state_srid_1 output=nc_state_grass_2
v.proj location=nc_epsg_2264 mapset=PERMANENT input=nc_state_srid_1 output=nc_state_grass_2

end results in nc_spm_08 should be identical (within floating point precision limits)

This is not yet working properly because the PROJ area of use (proj_area_set_bbox(), proj_create_crs_to_crs()) is not yet set properly. The new PROJ API needs an area of use, similar to the GRASS current region, to select the best coordinate transformation method. If this area of use is not set correctly, a wrong coordinate transformation method might be selected, and reprojection can fail. Therefore this PR is WIP.

@marisn
Copy link
Contributor

marisn commented Jan 11, 2021

This is huge! Tested with importing vectors in EPSG:3059 without reprojecting and also with reprojecting on import into EPSG:4326 – works fine. Didn't test places where improper axis ordering might pop-up. At least in importing and displaying everything is fine.

@neteler
Copy link
Member

neteler commented Jan 11, 2021

Huge work @metzm !

The CI shows two errors with Ubuntu 16 (old but maybe still fixable):

make[4]: Entering directory '/home/runner/work/grass/grass/raster/r.external'
test -d OBJ.x86_64-pc-linux-gnu || mkdir -p OBJ.x86_64-pc-linux-gnu
gcc  -g -O2   -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include    -DPACKAGE=\""grassmods"\"   -I/usr/include/gdal -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"raster/r.external\" -o OBJ.x86_64-pc-linux-gnu/colors.o -c colors.c
gcc  -g -O2   -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include    -DPACKAGE=\""grassmods"\"   -I/usr/include/gdal -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"raster/r.external\" -o OBJ.x86_64-pc-linux-gnu/link.o -c link.c
gcc  -g -O2   -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include    -DPACKAGE=\""grassmods"\"   -I/usr/include/gdal -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"raster/r.external\" -o OBJ.x86_64-pc-linux-gnu/list.o -c list.c
gcc  -g -O2   -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include    -DPACKAGE=\""grassmods"\"   -I/usr/include/gdal -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"raster/r.external\" -o OBJ.x86_64-pc-linux-gnu/main.o -c main.c
gcc  -g -O2   -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include    -DPACKAGE=\""grassmods"\"   -I/usr/include/gdal -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"raster/r.external\" -o OBJ.x86_64-pc-linux-gnu/proj.o -c proj.c
proj.c: In function ‘check_projection’:
proj.c:76:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
     wkt = GDALGetProjectionRef(hDS);
         ^
proj.c:117:5: error: expected ‘}’ before ‘else’
     else {
     ^
../../include/Make/Compile.make:32: recipe for target 'OBJ.x86_64-pc-linux-gnu/proj.o' failed
make[4]: Leaving directory '/home/runner/work/grass/grass/raster/r.external'

and

make[4]: Entering directory '/home/runner/work/grass/grass/raster/r.in.gdal'
test -d OBJ.x86_64-pc-linux-gnu || mkdir -p OBJ.x86_64-pc-linux-gnu
gcc  -g -O2   -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include    -DPACKAGE=\""grassmods"\"   -I/usr/include/gdal -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -I/home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include -DRELDIR=\"raster/r.in.gdal\" -o OBJ.x86_64-pc-linux-gnu/main.o -c main.c
main.c: In function ‘main’:
main.c:957:11: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   gdalwkt = GDALGetGCPProjection(hDS);
           ^
main.c:958:10: error: too few arguments to function ‘OSRImportFromWkt’
   hSRS = OSRImportFromWkt(&gdalwkt);
          ^
In file included from /home/runner/work/grass/grass/dist.x86_64-pc-linux-gnu/include/grass/gprojects.h:34:0,
                 from main.c:29:
/usr/include/gdal/ogr_srs_api.h:324:16: note: declared here
 OGRErr CPL_DLL OSRImportFromWkt( OGRSpatialReferenceH, char ** );
                ^
make[4]: *** [OBJ.x86_64-pc-linux-gnu/main.o] Error 1
../../include/Make/Compile.make:32: recipe for target 'OBJ.x86_64-pc-linux-gnu/main.o' failed
make[4]: Leaving directory '/home/runner/work/grass/grass/raster/r.in.gdal'

Oh, it is an antique GDAL: Unpacking libgdal1i (1.11.3+dfsg-3build2) ... so perhaps we just drop Ubuntu 16 from GitHub actions (@wenzeslaus , others)?

@marisn
Copy link
Contributor

marisn commented Jan 12, 2021

Oh, it is an antique GDAL: Unpacking libgdal1i (1.11.3+dfsg-3build2) ... so perhaps we just drop Ubuntu 16 from GitHub actions (@wenzeslaus , others)?

+1 for dropping Ubuntu 16

@nilason
Copy link
Contributor

nilason commented Jan 12, 2021

Oh, it is an antique GDAL: Unpacking libgdal1i (1.11.3+dfsg-3build2) ... so perhaps we just drop Ubuntu 16 from GitHub actions (@wenzeslaus , others)?

Note that also ubuntu-18.04 fails. There is a compiler macro condition block in raster/r.external/proj.c:26-116:

#if GDAL_VERSION_NUM >= 3000000`)
[...]
#else
[...]
#endif

which causes failure with GDAL < 3.

raster/r.external/proj.c Outdated Show resolved Hide resolved
@nilason
Copy link
Contributor

nilason commented Jan 12, 2021

Amazing work! So far tested the first suggested test with PROJ 7.2.1 and GDAL 3.2.1. Seem to work just fine!

Compiling with clang issued the following three warnings on files you modified. They are not caused by this PR, but maybe you wouldn't mind addressing them while you're at it.

lib/proj/do_proj.c :

/usr/bin/clang  -g -pipe -arch x86_64   -fno-common  -I/Dev/grass/dist.x86_64-apple-darwin19.6.0/include -I/Dev/grass/dist.x86_64-apple-darwin19.6.0/include    -I/opt/local/include -DPACKAGE=\""grasslibs"\"  -I/opt/local/lib/proj7/include -I/Dev/grass/dist.x86_64-apple-darwin19.6.0/include -I/Dev/grass/dist.x86_64-apple-darwin19.6.0/include -DRELDIR=\"lib/proj\" -o OBJ.x86_64-apple-darwin19.6.0/do_proj.o -c do_proj.c
do_proj.c:176:13: warning: enumeration values 'PJ_TYPE_TEMPORAL_DATUM', 'PJ_TYPE_ENGINEERING_DATUM', and
      'PJ_TYPE_PARAMETRIC_DATUM' not handled in switch [-Wswitch]
    switch (proj_get_type(pj)) {
            ^
do_proj.c:176:13: note: add missing switch cases
    switch (proj_get_type(pj)) {
            ^
1 warning generated.

raster/r.in.gdal/main.c :

/usr/bin/clang  -g -pipe -arch x86_64    -I/Dev/grass/dist.x86_64-apple-darwin19.6.0/include  -DPACKAGE=\""grassmods"\"  -I/opt/local/lib/proj7/include -I/opt/local/include  -DRELDIR=\"raster/r.in.gdal\" -o OBJ.x86_64-apple-darwin19.6.0/main.o -c main.c
main.c:1282:6: warning: ignoring return value of function declared with 'warn_unused_result' attribute
      [-Wunused-result]
            GDALRasterIO(hBand, GF_Read, 0, rowmap[row], ncols_gdal, 1,
            ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:1337:6: warning: ignoring return value of function declared with 'warn_unused_result' attribute
      [-Wunused-result]
            GDALRasterIO(hBand, GF_Read, 0, rowmap[row], ncols_gdal, 1,
            ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:1411:6: warning: ignoring return value of function declared with 'warn_unused_result' attribute
      [-Wunused-result]
            GDALRasterIO(hBand, GF_Read, 0, rowmap[row], ncols_gdal, 1,
            ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 warnings generated.

vector/v.out.ogr/main.c :

/usr/bin/clang  -g -pipe -arch x86_64    -I/Dev/grass/dist.x86_64-apple-darwin19.6.0/include -I/opt/local/include -I/opt/local/include -DPACKAGE=\""grassmods"\"  -I/opt/local/include/postgresql12 -I/opt/local/lib/proj7/include  -DRELDIR=\"vector/v.out.ogr\" -o OBJ.x86_64-apple-darwin19.6.0/main.o -c main.c
main.c:834:2: warning: ignoring return value of function declared with 'warn_unused_result' attribute
      [-Wunused-result]
        OGR_L_StartTransaction(Ogr_layer);
        ^~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
main.c:895:2: warning: ignoring return value of function declared with 'warn_unused_result' attribute
      [-Wunused-result]
        OGR_L_CommitTransaction(Ogr_layer);
        ^~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~
2 warnings generated.

raster/r.in.gdal/main.c Outdated Show resolved Hide resolved
@nilason
Copy link
Contributor

nilason commented Jan 12, 2021

so perhaps we just drop Ubuntu 16 from GitHub actions (@wenzeslaus , others)?

I don't think that would be necessary, at least not for this enhancement.

But this needs a good testing with GDAL <3

@nilason
Copy link
Contributor

nilason commented Jan 12, 2021

I encountered problems with projecting back and forth between epsg 23700 and 3035.

#!/usr/bin/env bash

GISDBASE=$HOME/grassdata
GRASS=`which grass79`

cat << EOF > script.sh
#!/usr/bin/env bash

v.proj location=projtest_3035 mapset=PERMANENT input=point_23700_2 output=point_23700_2

echo "original:"
v.out.ascii input=point_23700@PERMANENT format=point
echo "back-and-forth:"
v.out.ascii input=point_23700_2@PERMANENT format=point
EOF

chmod +x run.sh

cat << EOF > point_23700.geojson
{
"type": "FeatureCollection",
"name": "point_23700",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::23700" } },
"features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 737000.0, 240000.0 ] } }
]
}
EOF

$GRASS -c --text EPSG:23700:3 $GISDBASE/projtest_23700 --exec v.import input=point_23700.geojson

$GRASS -c EPSG:3035 $GISDBASE/projtest_3035 --exec v.proj location=projtest_23700 mapset=PERMANENT input=point_23700 output=point_23700_2

$GRASS --text $GISDBASE/projtest_23700/PERMANENT --exec $(pwd)/script.sh

results in:

Executing <v.import input=point_23700.geojson> ...
WARNING: Datum <Hungarian_Datum_1972> not recognised by GRASS and no
         parameters found

and

Executing <v.proj location=projtest_23700 mapset=PERMANENT input=point_23700 output=point_23700_2> ...
ERROR: North must be larger than South, but 240000 (north) <= 240000 (south
Execution of <v.proj location=projtest_23700 mapset=PERMANENT input=point_23700 output=point_23700_2> finished.

While using ogr2ogr is pretty straightforward:

ogr2ogr -t_srs EPSG:3035 -f GeoJSON point_3035.geojson point_23700.geojson
ogr2ogr -t_srs EPSG:23700 -f GeoJSON point_23700_2.geojson point_3035.geojson

@wenzeslaus
Copy link
Member

...so perhaps we just drop Ubuntu 16 from GitHub actions (@wenzeslaus , others)?

Fine with me. Fair enough for 8.0 and a major improvement like this one.

metzm and others added 2 commits January 15, 2021 17:04
Add missing parenthesis

Co-authored-by: nilason <n_larsson@yahoo.com>
* fix some compiler warnings
* fix support for GDAL < 3
* fix vector reprojection of a single point
@metzm
Copy link
Contributor Author

metzm commented Jan 15, 2021

Thanks all for your helpful comments!

I have fixed support for older GDAL/PROJ versions. Removing support for older GDAL/PROJ versions would be very helpful! The code base of the respective libraries and modules could be substantially cleaned up (removing lots of these #if* blocks. But this would be another big PR.

Compiler warnings have been taken care of, and reprojection of a single point works now.

As long as my original test fails, this PR will remain a draft. I am looking into it.

@neteler
Copy link
Member

neteler commented Jan 15, 2021

...so perhaps we just drop Ubuntu 16 from GitHub actions (@wenzeslaus , others)?

Fine with me. Fair enough for 8.0 and a major improvement like this one.

Ok, see #1254

fix reprojection for PROJ6+
fix G_debug typo
adjust for PROJ area of interest
@metzm
Copy link
Contributor Author

metzm commented Jan 21, 2021

The last commit ab7a768 fixes issues with the area of interest to be set for PROJ 6+. However, my tests still fail.
Test case: create a location with EPSG:2264, then try r.proj loc=nc_spm_08 map=PERMANENT in=landcover_1m -g or r.proj loc=nc_spm_08 map=PERMANENT in=elev_state_500m
At least r.proj loc=nc_spm_08 map=PERMANENT in=elev_state_500m -g is working...

@metzm
Copy link
Contributor Author

metzm commented Jan 23, 2021

There is a bug in PROJ causing my tests to fail with point not within available datum shift grids. The bug has been fixed in PROJ master with ebe3425. Still, I have to rewrite the relevant code in GRASS lib/proj to avoid this bug in PROJ.

avoid bug in PROJ fn proj_create_crs_to_crs()
@metzm metzm marked this pull request as ready for review January 23, 2021 19:20
@metzm
Copy link
Contributor Author

metzm commented Jan 25, 2021

This PR (together with previous commits) would fix bugs also present in G78:

CRS mismatch between input and output when creating a location from some GDAL/OGR recognized input, importing to this location and exporting again. The CRS should be exactly preserved. This bug happens when GRASS is compiled with PROJ6+ and GDAL3.

A bug in PROJ can cause PROJ to select a wrong coordinate operation with a datum transformation grid that does not cover the whole area of interest. In these cases, reprojection fails. This PR takes care of this bug.

Fixing these bugs in G78 requires that all changes related to the new SRID and WKT2 handling including all affected import and export modules need to be backported.

@nilason
Copy link
Contributor

nilason commented Jan 25, 2021

My previous observations, issues have all been solved.
Plan to do some more testing, but I saw an error while reprojecting in GUI Data tab:

r.proj dbase=/grassdata location=nc_spm_08 mapset=user1 input=testelev output=testelev method=bilinear
TypeError
:
Validate() takes 1 positional argument but 2 were given

This may be an issue for a follow-up PR though.

general/g.proj/input.c Show resolved Hide resolved
raster/r.out.gdal/main.c Show resolved Hide resolved
vector/v.out.ogr/main.c Show resolved Hide resolved
vector/v.out.ogr/main.c Outdated Show resolved Hide resolved
vector/v.out.ogr/main.c Outdated Show resolved Hide resolved
@metzm
Copy link
Contributor Author

metzm commented Jan 25, 2021

My previous observations, issues have all been solved.
Plan to do some more testing, but I saw an error while reprojecting in GUI Data tab:

r.proj dbase=/grassdata location=nc_spm_08 mapset=user1 input=testelev output=testelev method=bilinear
TypeError
:
Validate() takes 1 positional argument but 2 were given

This may be an issue for a follow-up PR though.

This looks like a GUI issue. Please provide the full GUI output.

@metzm
Copy link
Contributor Author

metzm commented Jan 25, 2021

My previous observations, issues have all been solved.
Plan to do some more testing, but I saw an error while reprojecting in GUI Data tab:

r.proj dbase=/grassdata location=nc_spm_08 mapset=user1 input=testelev output=testelev method=bilinear
TypeError
:
Validate() takes 1 positional argument but 2 were given

This may be an issue for a follow-up PR though.

Not reproducible through the menu "Raster -> Develop raster map -> Reproject raster map from different location".

Must be a bug in the Data tab.

@metzm
Copy link
Contributor Author

metzm commented Jan 25, 2021

Thanks very much @rouault for your suggestions!
I think this PR is now a working solution with reasonably good code quality and no apparent errors. As always, the new code can always be improved.

@nilason
Copy link
Contributor

nilason commented Jan 26, 2021

Not reproducible through the menu "Raster -> Develop raster map -> Reproject raster map from different location".

Must be a bug in the Data tab.

Yes, its only in Data tab and also unrelated to this PR. Reported with #1273.

@nilason nilason mentioned this pull request Jan 26, 2021
27 tasks
@metzm metzm marked this pull request as draft January 26, 2021 19:19
 * free memory
 * code cleanup
@mlennert
Copy link
Contributor

Thanks very much @rouault for your suggestions!
I think this PR is now a working solution with reasonably good code quality and no apparent errors. As always, the new code can always be improved.

No possibility for me to test this seriously in the near future, but big kudos to @metzm for this great improvement !

@metzm metzm marked this pull request as ready for review January 27, 2021 20:11
@metzm metzm merged commit 6e0d4b8 into OSGeo:master Jan 27, 2021
@metzm metzm deleted the proj_wkt branch January 27, 2021 20:15
metzm added a commit that referenced this pull request Feb 19, 2021
Co-authored-by: nilason <n_larsson@yahoo.com>

* adjust lib/gis, lib/proj, g.proj, r.proj, v.proj, r.in.gdal, r.external, r.out.gdal, v.in.ogr, v.external, v.out.ogr
@metzm
Copy link
Contributor Author

metzm commented Feb 19, 2021

@neteler backported to G78

@neteler neteler modified the milestones: 8.0.0, 7.8.6 Feb 19, 2021
marisn pushed a commit to marisn/grass that referenced this pull request Mar 22, 2021
Co-authored-by: nilason <n_larsson@yahoo.com>

* adjust lib/gis, lib/proj, g.proj, r.proj, v.proj, r.in.gdal, r.external, r.out.gdal, v.in.ogr, v.external, v.out.ogr
neteler added a commit to OSGeo/grass-addons that referenced this pull request Apr 14, 2021
* r.in.nasadem + r.in.srtm.region: fix PROJ parsing

Due to OSGeo/grass#1240 the output structure of `g.proj -g` changed, leading to

```
r.in.nasadem user='neteler' password='XXXXXXXXX' output=nasadem resolution=30
Traceback (most recent call last):
  File "/home/mundialis/.grass7/addons/scripts/r.in.nasadem", line 631, in <module>
    main()
  File "/home/mundialis/.grass7/addons/scripts/r.in.nasadem", line 475, in main
    SRCGISRC, TMPLOC = createTMPlocation()
  File "/home/mundialis/.grass7/addons/scripts/r.in.nasadem", line 342, in createTMPlocation
    if grass.parse_command('g.proj', flags='g')['EPSG'] != str(epsg):
KeyError: 'EPSG'
ERROR: Region <r_in_nasadem_region_409609> not found
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/mundialis/.grass7/addons/scripts/r.in.nasadem", line 312, in cleanup
    grass.run_command("g.region", region=tmpregionname)
  File "/home/mundialis/software/grass78_git/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 441, in run_command
    return handle_errors(returncode, returncode, args, kwargs)
  File "/home/mundialis/software/grass78_git/dist.x86_64-pc-linux-gnu/etc/python/grass/script/core.py", line 342, in handle_errors
    raise CalledModuleError(module=None, code=code,
grass.exceptions.CalledModuleError: Module run None g.region region=r_in_nasadem_region_409609 ended with error
Process ended with non-zero return code 1. See errors in the (error) output.
```

The change is the introduction of `srid`:

```
{'name': 'WGS 84', 'datum': 'wgs84', 'ellps': 'wgs84', 'proj': 'll', 'no_defs': 'defined', 'srid': 'EPSG:4326', 'unit': 'degree', 'units': 'degrees', 'meters': '1.0'}
```

which is addressed by this PR (feedback concerning the Python style is welcome).

Fixes
- r.in.nasadem
- r.in.srtm.region

(perhaps other addons are affected as well)

Co-authored-by: Guido Riembauer <62383722+griembauer@users.noreply.github.com>
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Oct 26, 2022
Co-authored-by: nilason <n_larsson@yahoo.com>

* adjust lib/gis, lib/proj, g.proj, r.proj, v.proj, r.in.gdal, r.external, r.out.gdal, v.in.ogr, v.external, v.out.ogr
ninsbl pushed a commit to ninsbl/grass that referenced this pull request Feb 17, 2023
Co-authored-by: nilason <n_larsson@yahoo.com>

* adjust lib/gis, lib/proj, g.proj, r.proj, v.proj, r.in.gdal, r.external, r.out.gdal, v.in.ogr, v.external, v.out.ogr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants