Opened 13 years ago

Closed 13 years ago

#4283 closed enhancement (fixed)

add -proj4 option to gdalinfo to report a PROJ.4 string for the CRS

Reported by: etourigny Owned by: etourigny
Priority: normal Milestone:
Component: Utilities Version: unspecified
Severity: normal Keywords:
Cc:

Description

Add a new option -proj4 to output the PROJ.4 string for the file's CRS. Having a PROJ.4 representation of a file is nice for debugging and comparing WKT and PROJ.4 representations for a file's CRS.

For example:

$ gdalinfo -proj4 data/utm.tif 
Driver: GTiff/GeoTIFF
Files: data/utm.tif
Size is 512, 512
Coordinate System is:
PROJCS["NAD27 / UTM zone 11N",
    GEOGCS["NAD27",
        DATUM["North_American_Datum_1927",
            SPHEROID["Clarke 1866",6378206.4,294.9786982139006,
                AUTHORITY["EPSG","7008"]],
            AUTHORITY["EPSG","6267"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4267"]],
    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["metre",1,
        AUTHORITY["EPSG","9001"]],
    AUTHORITY["EPSG","26711"]]
PROJ.4 string is:
'+proj=utm +zone=11 +datum=NAD27 +units=m +no_defs '
Origin = (440720.000000000000000,3751320.000000000000000)
Pixel Size = (60.000000000000000,-60.000000000000000)
...

Change History (4)

comment:1 by etourigny, 13 years ago

Committed to trunk (r23216).

I modified apps/gdalinfo.c and apps/gdal_utilities.dox for the docs.

How can one generate the html files from gdal_utilities.dox ?

comment:2 by Even Rouault, 13 years ago

Note: not sure if the patch was necessary if it is only for debugging purposes. You should already be able to see the proj4 string when running "gdalinfo --debug on ..."

"make docs" will regenerate the docs in the "html" directory of your tree. gdal.org is regenerated daily by a cron job from latest trunk.

comment:3 by etourigny, 13 years ago

Thanks for the info.

I thought it would be a nice addition, as the fact that we can get the proj4 string with --debug is not really documented (even I had forgotten/overlooked that!). With --debug on it's really a side effect that you see the "source" and "target" PROJ.4 strings (because of the request for lat/lon coordinates).

If you prefer I will revert the change, if not I will change the docs to read

(GDAL >= 1.9.0) Report a PROJ.4 string corresponding to the file's coordinate system

comment:4 by etourigny, 13 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.