[GRASS-dev] [GRASS-user] Unable to read .prj file

Markus Neteler neteler at osgeo.org
Sat Feb 9 03:05:32 PST 2019


(adding grass-dev)

On Sat, Feb 9, 2019 at 11:14 AM Markus Neteler <neteler at osgeo.org> wrote:
> On Sat, Feb 9, 2019 at 10:57 AM Helmut Kudrnovsky <hellik at web.de> wrote:
> >
> > >Just the GRASS GIS logics (still) prevent from accepting a .prj file as
> > input.
> >
> > at least in the GUI and the location wizzard you can use a .prj-file to
> > create a new location.
>
> Yes but not on the beloved command line:
>
> grass77 -c bla.prj  ~/grassdata/mylocation
> Starting GRASS GIS...
> Creating new GRASS GIS location <mylocation>...
> ERROR: ERROR 4: `bla.prj' not recognized as a supported file format.
> ERROR: Unable to read georeferenced file <bla.prj> using GDAL library

I checked further and found a difference between g.proj and
gdalsrsinfo opening files:

general/g.proj/input.c, line 271 :
(inofficially: https://github.com/GRASS-GIS/grass-ci/blob/master/general/g.proj/input.c#L271)

        if ((gdal_ds = GDALOpen(geofile, GA_ReadOnly))) {

apps/gdalsrsinfo.cpp, line 306
https://github.com/OSGeo/gdal/blob/master/gdal/apps/gdalsrsinfo.cpp#L306

    poGDALDS = static_cast<GDALDataset *>(GDALOpenEx( pszInput, 0,
nullptr, nullptr, nullptr ));

It seems that GDALOpenEx() is more flexible concerning the input (it
exists since GDAL 2.0):
https://www.gdal.org/classGDALDataset.html#a9cb8585d0b3c16726b08e25bcc94274a

Perhaps g.proj should be updated accordingly?

Markus


More information about the grass-dev mailing list