<div dir="ltr"><pre><span style="font-family:arial,sans-serif"><code><span></span></code>The documentation of <span style="font-family:monospace">AssignSpatialReference</span> says:<br></span></pre><div>"Any existing spatial reference is replaced, but under no circumstances 
does this result in the object being reprojected. It is just changing 
the interpretation of the existing geometry."</div><div><br></div><div>You have to reproject the polygon coordinates to actually have the polygon in that CRS.</div><div><br></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__<br>Entre dos pensamientos racionales <br>hay infinitos pensamientos irracionales.<br><br></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 18 Sep 2020 at 06:49, Mikhail Kruk <<a href="mailto:meshko@gmail.com">meshko@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"><div>Hi!</div><div>I am a complete GIS newbie so please bear with me... <br></div><div><br></div><div>I
 am trying to get the area of a polygon specified in lon,lat pairs in 
some reasonable units, like sq kilometers.  My quest so far is 
documented here:</div><div><br></div><div><a href="https://gis.stackexchange.com/questions/374428/default-geo-spatial-reference-system-in-gdal-ogr" target="_blank">https://gis.stackexchange.com/questions/374428/default-geo-spatial-reference-system-in-gdal-ogr</a></div><div><br></div><div>but
 basically I came to the conclusion that when people talk about an area 
of something on Earth they really mean the area of a projection (am i 
right about that?) and so i need to specify a projection before getting a
 meaningful area.  So i ended up with this code:</div><div><br></div><div><pre><code><span>wkt </span><span>=</span><span> </span><span>"POLYGON ((lon1 lat1, lon2 lat2, lon3 lat3))"</span><span>
poly </span><span>=</span><span> ogr</span><span>.</span><span>CreateGeometryFromWkt</span><span>(</span><span>wkt</span><span>)</span><span>
sr </span><span>=</span><span> osr</span><span>.</span><span>SpatialReference</span><span>()</span><span>
sr</span><span>.</span><span>SetWellKnownGeogCS</span><span>(</span><span>"NAD83"</span><span>)</span><span>
sr</span><span>.</span><span>SetProjCS</span><span>(</span><span>"SRS_PT_TRANSVERSE_MERCATOR"</span><span>)</span><span>
poly</span><span>.</span><span>AssignSpatialReference</span><span>(</span><span>sr</span><span>)</span><span>
poly</span><span>.</span><span>GetArea</span><span>()<br><br></span></code></pre><pre><code><span><span style="font-family:arial,sans-serif">and yet I get back a value which seems to be calculated in square degrees</span>.<br></span></code></pre><pre><code><span><span style="font-family:arial,sans-serif">Thanks!</span></span></code></pre></div></div>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></blockquote></div>