<div dir="ltr">I took a cursory glance at the calculator you used and the description you've given, and I think there's a possibility you're simply using an easting value in the calculator. You could try multiplying your input longitude by -1 for a quick fix (although I haven't tested this will work at all).</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 1 Sep 2020 at 03:31, Miguel-Ángel Fas-Millán <<a href="mailto:fas.millan@gmail.com" target="_blank">fas.millan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks for your reply. Well, let me provide more details to explain why I was asking that. <div>I have a DSM, with its xllcenter/yllcenter coordinates and I need to know the coordinates of the (in this case) center of any of the squares/cells (which, maybe wrongly, I called pixels) represented by this dataset. To that I've been using a function equivalent to the provided by this calculator: <a href="https://geodesy.noaa.gov/cgi-bin/Inv_Fwd/forward2.prl" style="background-color:transparent;color:rgb(0,0,128)" target="_blank">https://geodesy.noaa.gov/cgi-bin/Inv_Fwd/forward2.prl</a> , which takes as parameters the starting point, azimuth, distance, and returns the ending coordinates. </div><div><br></div><div>For instance, I want to calculate the coordinates of the first cell of the dataset (top left of the matrix). So I do:<br></div><div>
        
        

<p style="margin-bottom:0cm;line-height:100%;background:transparent">
<font style="font-size:11pt"><font color="#080808"><font face="JetBrains Mono, serif">calculateEndingGlobalCoordinates(</font></font><font color="#000000"><font face="JetBrains Mono, serif">Ellipsoid</font></font><font color="#080808"><font face="JetBrains Mono, serif">.</font></font><font color="#871094"><font face="JetBrains Mono, serif"><i>WGS84</i></font></font><font color="#080808"><font face="JetBrains Mono, serif">,
</font></font><font color="#000000"><font face="JetBrains Mono, serif">start_coords</font></font><font color="#080808"><font face="JetBrains Mono, serif">,
</font></font><font color="#1750eb"><font face="JetBrains Mono, serif">0.0</font></font><font color="#080808"><font face="JetBrains Mono, serif">, nrows*cellsize</font></font><font color="#080808"><font face="JetBrains Mono, serif">) //0.0 for north</font></font></font></p><p style="margin-bottom:0cm;line-height:100%;background:transparent">The problem is that it returns a value with a latitude that seems ok, but a wrong longitude. When I place that coordinate in QGIS, it is out of the image, quite at left of the top left corner. </p><p style="margin-bottom:0cm;line-height:100%;background:transparent"><font style="font-size:11pt"><font color="#080808"><font face="JetBrains Mono, serif">Unsurprisingly, if I place the coordinates obtained with this method (or with the online calculator mentioned) in google maps, to check if it makes sense looking at what's there in the</font></font></font><span style="font-family:"JetBrains Mono",serif;color:rgb(8,8,8);font-size:11pt;background-color:transparent"> satellite images, they make no sense at all. </span></p><p style="margin-bottom:0cm;line-height:100%;background:transparent"><font style="font-size:11pt"><font color="#080808"><font face="JetBrains Mono, serif">However, if I take the coordinates appearing in QGIS when I hover one of the cells, and place them in google maps, it makes perfect sense. With a few meters of difference, but well, at least it is on the right track. (I am that sure because I took as reference a ATC tower, which is the highest element in a wide area). </font></font></font></p><p style="margin-bottom:0cm;line-height:100%;background:transparent"><font color="#080808" face="JetBrains Mono, serif"><span style="font-size:14.6667px">That's why I wanted to check what's the difference between the mentioned method I was using and whatever is made in the code to return those quite correct coordinates. </span></font></p><p style="margin-bottom:0cm;line-height:100%;background:transparent"><font style="font-size:11pt"><font color="#080808"><font face="JetBrains Mono, serif"><br></font></font></font></p><p style="margin-bottom:0cm;line-height:100%;background:transparent"><font style="font-size:11pt"><font color="#080808"><font face="JetBrains Mono, serif"><br></font></font></font></p></div>
        
        

</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El mar., 1 sept. 2020 a las 0:01, Charles Dixon-Paver (<<a href="mailto:charles@kartoza.com" target="_blank">charles@kartoza.com</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Someone can correct me if I'm wrong, but I think there's a misunderstanding here of how this raster data is handled in a GIS. From my understanding of the question, I don't know that what you're asking for is available "in the code" the way you expect.<div><br></div><div>The coordinates are showing the position of the cursor relative to the origin of the assigned coordinate reference system. The raster data is "projected" onto that reference system, which assigns positions to some points on the image and stretches, rotates or distorts the image in accordance with the images affine parameters that ensure all the different parts of the image remain spatially correct. How the GIS knows where to get these parameters varies between data types and file formats.</div><div><br></div><div>Playing around with the georeferencer tool in QGIS should give you a pretty clear understanding of how this "projection" works.</div><div><br></div><div>There are ways to get the coordinates of a position or pixel within an image programmatically, the easiest of which that I can think of is using values from a world file [1] with an xy position (in pixels) of the pixel of interest. The code required for achieving this, however, is probably going to be <span>dependant</span> on a wide variety of factors (not least of all the CRS units and pixel size). Alternatively, you could likely grab the coordinate position of a pixel from within a QGIS project, but that doesn't seem to be what you're after. Perhaps a developer familiar with the GDAL or QGIS code bases can point you in the direction of some wizardry that will achieve what it is you are looking for without a clearer understanding of your use case though.</div><div><br></div><div>[1] <a href="https://en.wikipedia.org/wiki/World_file" target="_blank">https://en.wikipedia.org/wiki/World_file</a>  </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 31 Aug 2020 at 19:57, Miguel-Ángel Fas-Millán <<a href="mailto:fas.millan@gmail.com" target="_blank">fas.millan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all, <div>New around here and as a QGIS user. I need to find something in the code, I hope you can help me. </div><div>When you open a DSM and place the mouse on any pixel, you can see the coordinates of that point. Could someone tell me where in the code is made the calculation of those coordinates? </div><div><br></div><div>Regards,</div><div><br></div><div>Angel</div><div><br></div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a></blockquote></div>
</blockquote></div>
</blockquote></div>