[gdal-dev] proposal for a new GDAL/OGR utility app: gdalsrsinfo

Etienne Tourigny etourigny.dev at gmail.com
Sun Oct 16 21:02:41 EDT 2011


Frank,

Getting srs from the commandline is already supported, and it would
not make sense without it.  I also added support for getting it from
an existing file as an afterthought.
The reason I think this should be separate from gdalinfo is because I
want to be able to get the srs from a commandline and not worry about
using a file.

Your suggestion to add a -srsformat to gdalinfo is nice, and it could
replace the -proj4 option I checked in this week.  With that option,
output would be in one of the supported flavors, instead of the
default OGC WKT.

I'll look into testepsg, I thought it was only for EPSG codes (guess I
was wrong). I also overlooked it because it is not in the GDAL
utilities page.

Perhaps I can combine testepsg with gdalsrsinfo ?

Again some examples without needing any files:

./gdalsrsinfo  -o wkt -s  "EPSG:32722"
./gdalsrsinfo '+proj=stere +lat_0=-37 +lon_0=145 +x_0=0 +y_0=0
+ellps=WGS84 +datum=WGS84 +units=m +no_defs'

Thanks,
Etienne

On Sun, Oct 16, 2011 at 10:45 PM, Frank Warmerdam <warmerdam at pobox.com> wrote:
> Etienne,
>
> Potentially something similar could be accomplished with an
> -srsformat option to gdalinfo.  I will also note that the existing
> *unsupported* "testepsg" utility will report an SRS in all known
> formats and has a few other options.
>
> If you did check in a gdalsrsinfo utility, I'd suggest you have a
> way of taking the input SRS definition from the commandline
> instead of from a file.
>
> Best regards,
>
>
> On Sun, Oct 16, 2011 at 5:38 PM, Etienne Tourigny
> <etourigny.dev at gmail.com> wrote:
>> I have written a small utility app that I think would make a nice
>> addition to the GDAL Utilities.
>>
>> gdalsrsinfo (provisional name) processes an input SRS definition (or
>> dataset) and outputs the SRS definition in one or all of the formats
>> which GDAL can export to (WKT, PROJ.4, ESRI WKT, mapserver, xml).
>>
>> It accepts a valid GDAL dataset or any of the usual GDAL/OGR forms. It
>> could be extended to accept OGR datasets (already supports .prj
>> files).
>>
>> In my opinion it is useful because it allows easy access to the
>> different SRS forms supported by GDAL and conversions between those
>> forms.
>>
>>> gdalsrsinfo -h
>>
>> Usage: gdalsrsinfo [options] srs_def
>>
>> srs_def may be the filename of a dataset from which to extract SRS information
>> OR any of the usual GDAL/OGR forms
>> (complete WKT, PROJ.4, EPSG:n or a file containing the SRS)
>>
>> Options:
>>   [--help-general] [-h]  Show help and exit
>>   [-p]                         Pretty-print where applicable (e.g. WKT)
>>   [-s]                         Be as silent as possible
>>   [-o out_type]           Output type {all,proj4,wkt,esri,mapinfo,xml}
>>
>>
>> Please give me your opinion on this, and if I should go ahead and
>> commit it to svn trunk.  Also what name it should have.
>>
>> Attaching source code and modified GNUMakefile to build. It is written
>> in c to make it easily available to all GDAL installations.
>>
>> Regards, Etienne
>>
>> Posting some examples:
>>
>>>  ./gdalsrsinfo  -o all  landsat.tif
>>
>> PROJ.4 : '+proj=utm +zone=19 +south +datum=WGS84 +units=m +no_defs '
>>
>> OGC WKT :
>> PROJCS["WGS 84 / UTM zone 19S",GEOGCS["WGS
>> 84",DATUM["WGS_1984",SPHEROID["WGS
>> 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-69],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32719"]]
>>
>> ESRI WKT :
>> PROJCS["WGS_1984_UTM_Zone_19S",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-69],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
>>
>> MAPINFO : 'Earth Projection 8, 104, "m", -69, 0, 0.9996, 500000, 10000000'
>>
>>
>>> ./gdalsrsinfo  -o proj4 "EPSG:32722"
>>
>> PROJ.4 : '+proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs '
>>
>>> ./gdalsrsinfo  -o wkt -s  "EPSG:32722"
>>
>> PROJCS["WGS 84 / UTM zone 22S",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"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-51],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32722"]]
>>
>>
>>> ./gdalsrsinfo  -o wkt -p "EPSG:4326"
>>
>> OGC WKT :
>> 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"]]
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>
>
>
> --
> ---------------------------------------+--------------------------------------
> I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
> light and sound - activate the windows | http://pobox.com/~warmerdam
> and watch the world go round - Rush    | Geospatial Software Developer
>


More information about the gdal-dev mailing list