[gdal-dev] ogr not reading the prj file

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] ogr not reading the prj file

TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC

Hello,

 

I’m using gdal 2.3.1 that I built from source. I run the following command to inspect the contents of a shapefile…

 

ogrinfo –al circles.shp

 

When I run this command on the shapefile, I get the SRS information “Layer SRS_WKT” reporting from what is found in the “data” folder and not the SRS information defined in the circles.prj file.

 

What do I need to do to get the SRS information in the circles.prj file instead? I’m assuming my built library is missing the PROJ4 library?

 

Thanks.

 

Shayne


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: ogr not reading the prj file

Even Rouault-2
On vendredi 18 janvier 2019 23:44:48 CET TUELLER, SHAYNE R CIV USAF AFMC 519
SMXS/MXDEC wrote:

> Hello,
>
> I'm using gdal 2.3.1 that I built from source. I run the following command
> to inspect the contents of a shapefile...
>
> ogrinfo -al circles.shp
>
> When I run this command on the shapefile, I get the SRS information "Layer
> SRS_WKT" reporting from what is found in the "data" folder and not the SRS
> information defined in the circles.prj file.

For shapefiles, GDAL will try to identify the SRS information from the .prj
against one known SRS from the EPSG database. In case of a match, it will use
the later definition, in particular to get the code of the SRS, which is
practical in many uses.
Is it a case of wrong identification ?
If so, could you share the .prj file ?

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Non-DoD Source] Re: ogr not reading the prj file

TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC
Thank you for the reply.

I don't think it's a case of wrong identification because the prj file gets read in just fine with ogrinfo in gdal 1.11. When I use the gdal 2.3.1 I built from source on Windows, it no longer reads the associated prj file that is used with the shapefile. Instead, it grabs whatever is defined in the "data" folder. I think it may have something to do with the way I built the library but I'm not sure.

Here is the contents of the circles.prj associated with the circles.shp file...

GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHERIOD["WGS_1984", 6378137, 298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]

Shayne

-----Original Message-----
From: Even Rouault <[hidden email]>
Sent: Saturday, January 19, 2019 1:36 AM
To: [hidden email]
Cc: TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC <[hidden email]>
Subject: [Non-DoD Source] Re: [gdal-dev] ogr not reading the prj file

On vendredi 18 janvier 2019 23:44:48 CET TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC wrote:

> Hello,
>
> I'm using gdal 2.3.1 that I built from source. I run the following
> command to inspect the contents of a shapefile...
>
> ogrinfo -al circles.shp
>
> When I run this command on the shapefile, I get the SRS information
> "Layer SRS_WKT" reporting from what is found in the "data" folder and
> not the SRS information defined in the circles.prj file.

For shapefiles, GDAL will try to identify the SRS information from the .prj against one known SRS from the EPSG database. In case of a match, it will use the later definition, in particular to get the code of the SRS, which is practical in many uses.
Is it a case of wrong identification ?
If so, could you share the .prj file ?

Even

--
Spatialys - Geospatial professional services http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Non-DoD Source] Re: ogr not reading the prj file

Even Rouault-2
On mardi 22 janvier 2019 16:56:56 CET TUELLER, SHAYNE R CIV USAF AFMC 519
SMXS/MXDEC wrote:

> Thank you for the reply.
>
> I don't think it's a case of wrong identification because the prj file gets
> read in just fine with ogrinfo in gdal 1.11. When I use the gdal 2.3.1 I
> built from source on Windows, it no longer reads the associated prj file
> that is used with the shapefile. Instead, it grabs whatever is defined in
> the "data" folder. I think it may have something to do with the way I built
> the library but I'm not sure.
>
> Here is the contents of the circles.prj associated with the circles.shp
> file...
>
> GEOGCS["GCS_WGS_1984", DATUM["D_WGS_1984", SPHERIOD["WGS_1984", 6378137,
> 298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]

ok, so I guess ogrinfo -al -so reports

GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9122"]],
    AUTHORITY["EPSG","4326"]]

This is the expected behaviour. The content of a .prj file is WKT with the
ESRI variant formatting. Newer GDAL versions manage to retrieve the OGC WKT
definition when the ESRI WKT corresponds to a EPSG code.

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Non-DoD Source] Re: ogr not reading the prj file

TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC
In reply to this post by Even Rouault-2
I should also mention that when using gdal 1.11, I didn't have to explicitly set the GDAL_DATA environment variable in order for the SRS info to print out. With gdal 2.3.1, if I don't set the GDAL_DATA variable, I get the following error...

ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.

Not sure why I don't need this dependency in gdal 1.11. With this version it just loads the SRS info found in my prj file which is what I want.

Shayne

-----Original Message-----
From: Even Rouault <[hidden email]>
Sent: Saturday, January 19, 2019 1:36 AM
To: [hidden email]
Cc: TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC <[hidden email]>
Subject: [Non-DoD Source] Re: [gdal-dev] ogr not reading the prj file

On vendredi 18 janvier 2019 23:44:48 CET TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC wrote:

> Hello,
>
> I'm using gdal 2.3.1 that I built from source. I run the following
> command to inspect the contents of a shapefile...
>
> ogrinfo -al circles.shp
>
> When I run this command on the shapefile, I get the SRS information
> "Layer SRS_WKT" reporting from what is found in the "data" folder and
> not the SRS information defined in the circles.prj file.

For shapefiles, GDAL will try to identify the SRS information from the .prj against one known SRS from the EPSG database. In case of a match, it will use the later definition, in particular to get the code of the SRS, which is practical in many uses.
Is it a case of wrong identification ?
If so, could you share the .prj file ?

Even

--
Spatialys - Geospatial professional services http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] ogr not reading the prj file

TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC
In reply to this post by Even Rouault-2

Yes, that is correct. So, I guess it is working as designed with the newer version of gdal?

 

Is there any way of forcing it to use the SRS info in my prj file with this newer version or am I stuck?

 

Shayne

 

--------------------------------------------------------------------------------------------------

 

ok, so I guess ogrinfo -al -so reports

 

GEOGCS["WGS 84",

    DATUM["WGS_1984",

        SPHEROID["WGS 84",6378137,298.257223563,

            AUTHORITY["EPSG","7030"]],

        AUTHORITY["EPSG","6326"]],

    PRIMEM["Greenwich",0,

        AUTHORITY["EPSG","8901"]],

    UNIT["degree",0.0174532925199433,

        AUTHORITY["EPSG","9122"]],

    AUTHORITY["EPSG","4326"]]

 

This is the expected behaviour. The content of a .prj file is WKT with the ESRI variant formatting. Newer GDAL versions manage to retrieve the OGC WKT definition when the ESRI WKT corresponds to a EPSG code.

 

--

Spatialys - Geospatial professional services http://www.spatialys.com

 


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Non-DoD Source] Re: ogr not reading the prj file

jratike80
In reply to this post by TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC
TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC wrote

> I should also mention that when using gdal 1.11, I didn't have to
> explicitly set the GDAL_DATA environment variable in order for the SRS
> info to print out. With gdal 2.3.1, if I don't set the GDAL_DATA variable,
> I get the following error...
>
> ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the
> GDAL_DATA environment variable to point to the directory containing EPSG
> csv files.
>
> Not sure why I don't need this dependency in gdal 1.11. With this version
> it just loads the SRS info found in my prj file which is what I want.
>
> Shayne

Hi,

Please read the previous answers and try to understand what happens.
- ESRI is using its own version of WKT that is slightly different from the
OGC version. With your .prj the main difference is in the name of the DATUM:
"D_WGS_1984".
- GDAL reads the ESRI variant and if it finds corresponding OGC WKT it
prints that by default.
- The older GDAL version probably did not find the hit. You should
experiense the same with GDAL 2.3.1 if you edit your .prj file a bit so that
it will not find corresponding definitions from the EPSG data in GDAL_DATA
directory

GEOGCS["GCS_WGS_FOO", DATUM["FOO_WGS_1984", SPHEROID["WGS_1984", 6378137,
298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]

You did not explain yet what real problem you have due to gdalinfo reporting
OGC WKT instead of ESRI WKT. Both mean just the same for GDAL.

If you want to see the ESRI WKT you can use gdalsrsinfo. I saved your .prj
as test.prj and here is the result. Even "SPHERIOD" is remained.

gdalsrsinfo test.prj -o wkt_esri
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHERIOD["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]

-Jukka Rahkonen-



--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Non-DoD Source] Re: ogr not reading the prj file

TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC
Thanks for the reply. However, this didn't address my question regarding why I don't need GDAL_DATA defined in gdal 1.11 in order for SRS info to print out...

Shayne

-----Original Message-----
From: gdal-dev <[hidden email]> On Behalf Of jratike80
Sent: Tuesday, January 22, 2019 10:59 AM
To: [hidden email]
Subject: Re: [gdal-dev] [Non-DoD Source] Re: ogr not reading the prj file

TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC wrote

> I should also mention that when using gdal 1.11, I didn't have to
> explicitly set the GDAL_DATA environment variable in order for the SRS
> info to print out. With gdal 2.3.1, if I don't set the GDAL_DATA
> variable, I get the following error...
>
> ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the
> GDAL_DATA environment variable to point to the directory containing
> EPSG csv files.
>
> Not sure why I don't need this dependency in gdal 1.11. With this
> version it just loads the SRS info found in my prj file which is what I want.
>
> Shayne

Hi,

Please read the previous answers and try to understand what happens.
- ESRI is using its own version of WKT that is slightly different from the OGC version. With your .prj the main difference is in the name of the DATUM:
"D_WGS_1984".
- GDAL reads the ESRI variant and if it finds corresponding OGC WKT it prints that by default.
- The older GDAL version probably did not find the hit. You should experiense the same with GDAL 2.3.1 if you edit your .prj file a bit so that it will not find corresponding definitions from the EPSG data in GDAL_DATA directory


You did not explain yet what real problem you have due to gdalinfo reporting OGC WKT instead of ESRI WKT. Both mean just the same for GDAL.

If you want to see the ESRI WKT you can use gdalsrsinfo. I saved your .prj as test.prj and here is the result. Even "SPHERIOD" is remained.

-Jukka Rahkonen-



--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Non-DoD Source] Re: ogr not reading the prj file

Even Rouault-2
On mardi 22 janvier 2019 18:20:46 CET TUELLER, SHAYNE R CIV USAF AFMC 519
SMXS/MXDEC wrote:
> Thanks for the reply. However, this didn't address my question regarding why
> I don't need GDAL_DATA defined in gdal 1.11 in order for SRS info to print
> out...

If software didn't change between versions, there would be no point in
releasing new versions :-)

So yes since GDAL 2.3, the shapefile driver now needs to access to the GDAL
resource .csv files for nominal behaviour. (Actually if they are absent, you
should still get the same, or similar, result as in 1.11)

Even

--
Spatialys - Geospatial professional services
http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: [Non-DoD Source] Re: ogr not reading the prj file

TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC
I think your first point is obvious...lol.

I was just trying to understand why GDAL_DATA wasn't required in my older version in order for SRS info to display in the ogrinfo app. You have answered that question. Thank you.

Shayne

-----Original Message-----
From: Even Rouault <[hidden email]>
Sent: Tuesday, January 22, 2019 11:51 AM
To: [hidden email]
Cc: TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC <[hidden email]>; jratike80 <[hidden email]>
Subject: Re: [gdal-dev] [Non-DoD Source] Re: ogr not reading the prj file

On mardi 22 janvier 2019 18:20:46 CET TUELLER, SHAYNE R CIV USAF AFMC 519 SMXS/MXDEC wrote:
> Thanks for the reply. However, this didn't address my question
> regarding why I don't need GDAL_DATA defined in gdal 1.11 in order for
> SRS info to print out...

If software didn't change between versions, there would be no point in releasing new versions :-)

So yes since GDAL 2.3, the shapefile driver now needs to access to the GDAL resource .csv files for nominal behaviour. (Actually if they are absent, you should still get the same, or similar, result as in 1.11)

Even

--
Spatialys - Geospatial professional services http://www.spatialys.com
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev