[gdal-dev] TransformPoint returning Infinity
Henneke, Amanda M
amanda.m.henneke at boeing.com
Tue Oct 20 11:02:37 EDT 2009
Thanks Frank! Don't I feel dumb now! Although, I'm glad it was that simple!
Amanda M. Henneke
When One tugs at a single thing in Nature, he finds it attached to the rest of the world. -John Muir
Please consider the environment before printing this e-mail.
-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com]
Sent: Tuesday, October 20, 2009 9:36 AM
To: Henneke, Amanda M
Cc: gdal-dev at lists.osgeo.org
Subject: Re: [gdal-dev] TransformPoint returning Infinity
Henneke, Amanda M wrote:
> Hello all-
>
> I've been running into a problem where I'm trying to transform points into UTM NAD83 and occasionally (does not seem to be repeatable, more random) the TransformPoint method returns Infinity for the x and y coordinate. Just for your info, the coordinate system I'm converting from is UTM NAD27. Anyone else seen this? I've included my code below...am I doing something wrong or is there some sort of an issue with the TransformPont method?
>
> // Get the input layer's spatial reference information
> OSGeo.OSR.SpatialReference sr = lyrOriginal.GetSpatialRef(); string
> sSpRefWKT = "";
>
> // If this is a valid spatial reference, then export the data to a
> string and return it if (Validator.IsValid_SpatialRef(sr))
> {
> sr.ExportToPrettyWkt(out sSpRefWKT, 1); } sr.Dispose();
>
> OSGeo.OSR.SpatialReference srOld = new
> OSGeo.OSR.SpatialReference(sSpRefParams);
> OSGeo.OSR.SpatialReference srNew = new OSGeo.OSR.SpatialReference("");
>
> srNew.SetUTM(11, 1);
> srNew.SetWellKnownGeogCS("NAD83");
>
> ctTransform = new OSGeo.OSR.CoordinateTransformation(srOld, srNew);
>
> double[] dLnSegPt1 = { dX1, dY1 };
> ctTransform.TransformPoint(dLnSegPt1);
>
Amanda,
TransformPoint() takes a three entry array, try it with:
double [] dLnSegPt1 = { dX1, dY1, 0.0 };
ctTransform.TransformPoint(dLnSegPt1);
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