[Gdal-dev] Can gdal help get proj4 string from geotiff?
Frank Warmerdam
warmerdam at pobox.com
Fri Oct 22 11:01:12 EDT 2004
Fu Chen wrote:
> Hi!
> I am designing a program to show a lot of raster images on webgis mapserver. And I try to set the map projection as the projection of the raster file.
> My idea is to dynamicly generate a map file or dynamicly change some part of mapfile by php mapscript.
> But they all need to get a PROJ4 PROJECTION description like
>
> "proj=tmerc"
> "ellps=WGS84"
> "lon_0=117"
> "x_0=500000"
>
> from the information inside raster images such like geotiff.
> Can GDAL api help me?
Fu Chen,
The OGRSpatialReference class can be used to convert OpenGIS WKT
coordinate system definitions into PROJ.4 format. OGC WKT is what
is returned by the GDALDataset::GetProjectionRef() method. Briefly,
you would call importFromWkt() to apply the WKT definition from the
dataset to an OGRSpatialReference, and then exportToProj4() to convert
into a proj.4 string.
Note that this would result in something like "+proj=utm +zone=11 +datum=WGS84"
which you can use directly in MapServer. You don't need to split things into
a bunch of subentries.
PROJECTION
"+proj=utm +zone=11 +datum=WGS84"
END
is how I always define projections in MapServer.
Note that while there is a PHP OGR API, I don't *think* it includes all the
OGRSpatialReference stuff, and it doesn't include GDAL, so you will need to
do this from C, C++ or Python.
Best regards,
--
---------------------------------------+--------------------------------------
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 Programmer for Rent
More information about the Gdal-dev
mailing list