[gdal-dev] trying to get lat/lon out of sdts dem
Frank Warmerdam
warmerdam at p...
Tue Oct 23 16:29:06 EDT 2001
nakiya123 at y... wrote:
> Howdy,
>
> I am trying to extract the lat/lon coordinates out of sdts dem's. I
> have looked into and tried to used the OGRSpatialReference class but
> have not seen any clear way to do this. How is this done?
>
> Thanks in advance
Hi,
Are the DEMs in lat/long already, or UTM? If they are in lat/long you
can just ignore the OGRSpatialReference. Determine the georeferenced
coordinate of the top left corner of a pixel as follows:
dfGeorefX = padfGeoTransform[0] + padfGeoTransform[1] * nPixel
+ padfGeoTransform[2] * nLine;
dfGeorefY = padfGeoTransform[3] + padfGeoTransform[4] * nPixel;
+ padfGeoTransform[5] * nLine;
If the DEM is in UTM, the above will give you the corner in UTM coordinates.
You can then translate this to LatLong using something like the following
to create a reprojector:
#include "gdal_priv.h"
#include "ogr_spatialref.h"
OGRSpatialReference *poUTM = new OGRSpatialReference();
const char *pszUTM_WKT = poDS->GetProjectionRef();
poUTM->importFromWkt( (char **) &pszUTM_WKT );
OGRSpatialReference *poLL = poUTM->CloneGeogCS();
OGRCoordinateTransform *poTransform;
poTransform = OGRCreateCoordinateTransformation( poUTM, poLL );
Then invoke it on points like this:
poTransform->Transform( 1, &dfGeorefX, &dfGeoref );
I hope this helps. Let me know if you need more details.
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at p...
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