Opened 6 years ago
Last modified 5 years ago
#3750 new defect
Grass 7.7.svn (r74061): CLI location creation: cannot read .prj file for new location
Reported by: | rshepard | Owned by: | |
---|---|---|---|
Priority: | normal | Milestone: | 7.8.3 |
Component: | wxGUI | Version: | svn-trunk |
Keywords: | locaton wizard, .prj file | Cc: | |
CPU: | x86-32 | Platform: | Linux |
Description
Trying to create a new location using a shapefile .prj. GRASS tells me it annot read the file using gdal.
Markus N. confirms this and recommends using the .shp file instead.
Setting the location's projection on the command line works, but not from the GUI. The 2019-02-09 thread has more details.
Attachments (1)
Change History (10)
by , 6 years ago
Attachment: | location_wizard.PNG added |
---|
comment:1 by , 6 years ago
Replying to rshepard:
Trying to create a new location using a shapefile .prj. GRASS tells me it annot read the file using gdal.
for me it works with the GUI location wizard; see attached screenshot to choose the option read projection from a .prj file.
Markus N. confirms this and recommends using the .shp file instead.
that's the option read projection from a georeferenced file.
Setting the location's projection on the command line works, but not from the GUI. The 2019-02-09 thread has more details.
isn't it the other way around?
CLI with .prj file doesn't work, but GUI with .prj file works.
follow-up: 4 comment:2 by , 6 years ago
# write out user's WKT string as .prj file echo 'PROJCS["NAD_1983_UTM_Zone_11N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]' > bla.prj # attempt to generate a new location from it: 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 could be updated accordingly?
comment:3 by , 6 years ago
Summary: | Grass 7.7.svn (r74061): GUI location widget cannot read .prj file for new location → Grass 7.7.svn (r74061): CLI location creation: cannot read .prj file for new location |
---|
follow-up: 5 comment:4 by , 6 years ago
Replying to neteler:
# write out user's WKT string as .prj file echo 'PROJCS["NAD_1983_UTM_Zone_11N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]' > bla.prj # attempt to generate a new location from it: 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 libraryI 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):
No, the trick is here: https://github.com/OSGeo/gdal/blob/a0e1932541cb4edc6d2e254d7af6f64cd0dc0806/gdal/apps/gdalsrsinfo.cpp#L334
If GDALOpenEx()
fails, it checks if it is a *.prj file
comment:5 by , 6 years ago
Replying to mmetz:
Replying to neteler:
# write out user's WKT string as .prj file echo 'PROJCS["NAD_1983_UTM_Zone_11N",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]' > bla.prj # attempt to generate a new location from it: 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 libraryI 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):
No, the trick is here: https://github.com/OSGeo/gdal/blob/a0e1932541cb4edc6d2e254d7af6f64cd0dc0806/gdal/apps/gdalsrsinfo.cpp#L334
If
GDALOpenEx()
fails, it checks if it is a *.prj file
Please try trunk r74072
comment:6 by , 6 years ago
Great, the change solves the cmd line issue! I compared the output of g.proj -w
and testepsg
, while not 100% identical it can be considered the same (I suppose that some EPSG laundery is going on).
I'd vote for backporting this.
comment:8 by , 5 years ago
Milestone: | → 7.8.3 |
---|
location wizard - read prj file