<HTML dir=ltr><HEAD><TITLE>Re: [gdal-dev] Building a Mercator Image from Un-projected data..Major confusion and help requested.</TITLE>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18828"></HEAD>
<BODY>
<DIV dir=ltr><FONT color=#000000 size=2 face=Arial>Thanks for the guidance. The results are correct in the sense that the transformations are correct in terms of the meters values being returned. My question is how does this convert to pixel location FROM the data set and then INTO the image.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>In the below code example the bolded values are my output. My lack of understanding comes from how do I use this information returned in Meters to navigate into my dataset and then navigate into the image? Is it as simple of determining the meters </FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>for the upper left and then meters for the lower right and then setting up a ratio based on the rows and columns in the input data set and corresponding output image? This doesn't seem like a linear problem but perhaps GDAL is taking this out of the equation.</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>The output image will be the same number of rows and columns as the source data so no interpolation of data is needed. My presumption is that the difference will be WHERE a particular pixel is located in the image. Doing a straight Platte Carre</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>image is simple because the origin in the datasource is the same as the origin in the image. The lowest right data element in the datasource will have the same i-j as the lowest right pixel. My presumption and perhaps this is where I need clarification</FONT></DIV>
<DIV dir=ltr><FONT size=2 face=Arial>is this will NOT be the case with Mercator or any other projection.</FONT><FONT size=2 face=Arial></FONT></DIV>
<DIV dir=ltr><FONT size=2>
<P>std::pair< </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> > upper_left = std::make_pair( -125.99, 49.7186 );</P>
<P>std::pair< </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> > upper_right = std::make_pair( -65.656, 49.7186 );</P>
<P>std::pair< </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> > lower_left = std::make_pair( -125.99, 24.0938 );</P>
<P>std::pair< </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> > lower_right = std::make_pair( -65.656, 24.0938 );</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>int</FONT></FONT><FONT size=2> my_points = 1;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>int</FONT></FONT><FONT size=2> result = 0;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>double</FONT></FONT><FONT size=2> x, y;</P>
<P>x = lower_right.first;</P>
<P>y = lower_right.second;</P>
<P>OCTTransform( my_transformation, my_points, &x, &y, NULL );</P>
<P>std::cout << std::fixed;</P>
<P>std::cout << result << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" "</FONT></FONT><FONT size=2> << lower_right.first << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>", "</FONT></FONT><FONT size=2> << lower_right.second << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" = "</FONT></FONT><FONT size=2> << x << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>", "</FONT></FONT><FONT size=2> << y << std::endl;</FONT></P>
<P><FONT size=2><STRONG>// 0 -65.656000, 24.093800 = -7308792.487523, 2747405.191359 --> These are correct<BR></STRONG></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2></FONT></FONT></P>
<P><FONT color=#0000ff size=2><FONT color=#0000ff size=2>char</FONT></FONT><FONT size=2> *pszDstWKT = NULL;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>char</FONT></FONT><FONT size=2> *pszSrcWKT = NULL;</P>
<P>OSRExportToWkt( mercator_proj, &pszDstWKT );</P>
<P>OSRExportToWkt( wgs84_proj, &pszSrcWKT );</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>void</FONT></FONT><FONT size=2> *hTransformArg;</P>
<P>hTransformArg = GDALCreateGenImgProjTransformer( NULL, pszSrcWKT, NULL, pszDstWKT, FALSE, 0, 1 );</P>
<P>x = upper_right.first;</P>
<P>y = upper_right.second;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>int</FONT></FONT><FONT size=2> success;</P>
<P>result = GDALGenImgProjTransform(hTransformArg, FALSE, 1, &x, &y, NULL, &success);</P>
<P>std::cout << result << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" "</FONT></FONT><FONT size=2> << upper_right.first << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>", "</FONT></FONT><FONT size=2> << upper_right.second << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" = "</FONT></FONT><FONT size=2> << x << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>", "</FONT></FONT><FONT size=2> << y << std::endl;</FONT></P>
<P><FONT size=2><STRONG>// 1 -65.656000, 49.718600 = -7308792.487523, 6365068.664114 --> This is now correct as well<BR></STRONG></P>
<P>x = lower_right.first;</P>
<P>y = lower_right.second;</P>
<P>result = GDALGenImgProjTransform(hTransformArg, FALSE, 1, &x, &y, NULL, &success);</P>
<P>std::cout << result << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" "</FONT></FONT><FONT size=2> << lower_right.first << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>", "</FONT></FONT><FONT size=2> << lower_right.second << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>" = "</FONT></FONT><FONT size=2> << x << </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>", "</FONT></FONT><FONT size=2> << y << std::endl;</FONT></P>
<P><FONT size=2><STRONG>// 1 -65.656000, 24.093800 = -7308792.487523, 2747405.191359 --> These are correct<BR></STRONG></P></FONT></DIV>
<DIV dir=ltr>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr><FONT size=2 face=Tahoma><B>From:</B> gdal-dev-bounces@lists.osgeo.org on behalf of Adam Nowacki<BR><B>Sent:</B> Mon 11/2/2009 4:49 PM<BR><B>To:</B> gdal-dev@lists.osgeo.org >> Gdal-Dev<BR><B>Subject:</B> Re: [gdal-dev] Building a Mercator Image from Un-projected data..Major confusion and help requested.<BR></FONT><BR></DIV>
<DIV>
<P><FONT size=2>Cassanova, Bill wrote:<BR>> result = GDALGenImgProjTransform(hTransformArg, TRUE, 1, &x, &y,<BR>> NULL, &success);<BR>> std::cout << std::fixed;<BR>> std::cout << result << " " << lower_right.first << ", " <<<BR>> lower_right.second << " = " << x << ", " << y << std::endl;<BR>><BR>> *//** 1 -65.656000, 49.718600 = -0.000590, 0.000450***<BR>><BR>> *// This is NOT Right** so apparently I am doing something wrong or not<BR>> understanding the concept here*<BR><BR>2nd argument to GDALGenImgProjTransform is TRUE so you are reprojecting<BR>from, not to mercator<BR>_______________________________________________<BR>gdal-dev mailing list<BR>gdal-dev@lists.osgeo.org<BR><A href="http://lists.osgeo.org/mailman/listinfo/gdal-dev">http://lists.osgeo.org/mailman/listinfo/gdal-dev</A><BR></FONT></P></DIV></BODY></HTML>