<div dir="ltr"><div dir="ltr">Regarding:<br><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If my conclusion is right, then I either need: </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">1. ST_Segmentatize like method to add points onto rhumb edges in case a polygon was drawn on the merkator plane.</blockquote><div><br></div>and<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">3. Some tricky transformations</blockquote></div><br>At least I found a way to do that:<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">SELECT ST_Area(<br> ST_Transform(<br> ST_Segmentize(<br> ST_Transform(<br> ST_GeometryFromText('POLYGON ((-0.780387531 -79.736894381,<br> 170.375361283 -79.736894381,<br> 170.375361283 -79.692508368,<br> -0.780387531 -79.692508368,<br> -0.780387531 -79.736894381))'<br> , 4326) -- set wgs84 srid to geometry<br> , 3857) -- wgs84 to web-mercator<br> , 1000) -- segmentation max 1 km by rhumb edges<br> , 4326) -- web-mercator to wgs84<br>::geography) / 1e+6 -- in km^2</blockquote><div><br></div><div>The result is ~16915 km^2 </div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">вс, 30 мар. 2025 г. в 13:22, Alexander Trufanov <<a href="mailto:trufanovan@gmail.com">trufanovan@gmail.com</a>>:<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 dir="ltr">Hi,<div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The area is 899078042.2 m2 as verified using:<br><a href="https://geographiclib.sourceforge.io/cgi-bin/Planimeter?type=polygon&rhumb=geodesic&radius=6378137&flattening=1%2F298.257223563&input=-79.736894381+-0.780387531%0D%0A-79.736894381+170.375361283%0D%0A-79.692508368+170.375361283%0D%0A-79.692508368+-0.780387531%0D%0A-79.736894381+-0.780387531&option=Submit" rel="noreferrer" target="_blank">https://geographiclib.sourceforge.io/cgi-bin/Planimeter?type=polygon&rhumb=geodesic&radius=6378137&flattening=1%2F298.257223563&input=-79.736894381+-0.780387531%0D%0A-79.736894381+170.375361283%0D%0A-79.692508368+170.375361283%0D%0A-79.692508368+-0.780387531%0D%0A-79.736894381+-0.780387531&option=Submit</a></blockquote></div><div><br></div><div>But there is also an option to switch Edge type to Rhumb line which would give you the following result:<br><span style="font-size:large;color:rgb(0,0,0)">area (m^2) = 16914914491.4</span> </div>that's much closer to the expected 16700 km^2.<div>From Planimeter <a href="https://geographiclib.sourceforge.io/C++/doc/Planimeter.1.html" target="_blank">docs</a>: <br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">The algorithm for the area of a rhumb polygon is given in Section 3 of C. F. F. Karney, </span><i style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">The area of rhumb polygons</i><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">, Stud. Geophys. Geod. 68(3--4), 99--120 (2024); DOI </span><a href="https://doi.org/10.1007/s11200-024-0709-z" style="font-family:"Times New Roman";font-size:medium" target="_blank">https://doi.org/10.1007/s11200-024-0709-z</a><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">.</span></blockquote><div><br></div><div>The original polygon was drawn in Merkator Web projection, so I expect it to looks like:</div><div><br></div><div><img src="cid:ii_m8vgyldv0" alt="image.png" width="362" height="280" style="margin-right: 0px;"><br><br>instead of<br><br><img src="cid:ii_m8vgzdwt1" alt="image.png" width="360" height="361" style="margin-right: 0px;"></div><div>which is drawn at <a href="http://www.gcmap.com/mapui?P=79.736894381S+0.780387531W-79.736894381S+170.375361283E-79.692508368S+170.375361283E-79.692508368S+0.780387531W-79.736894381S+0.780387531W&MS=wls&DU=km" rel="noreferrer" target="_blank">http://www.gcmap.com/mapui?P=79.736894381S+0.780387531W-79.736894381S+170.375361283E-79.692508368S+170.375361283E-79.692508368S+0.780387531W-79.736894381S+0.780387531W&MS=wls&DU=km</a><br><br>Unfortunately, there is no rhumb option in ST_Area or ST_Perimeter.</div><div>Also it seems I could workaround this by adding additional points along latitudes manually. But I can't do this automatically (maybe I didn't find the proper function?) with ST_Segmentize.</div><div>And I couldn't think out any SRID trick to make Postgis process this polygon in a Merkator-expected way.</div><div><br></div><div>If my conclusion is right, then I either need:</div><div>1. ST_Segmentatize like method to add points onto rhumb edges in case a polygon was drawn on the merkator plane.</div><div>2. ST_Area and ST_Perimeter with rhumb option</div><div>3. Some tricky transformations</div><div><br></div><div>Are there any ideas for one of these?</div><div><br></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">вт, 25 мар. 2025 г. в 23:44, Mike Taves <<a href="mailto:mwtoews@gmail.com" target="_blank">mwtoews@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Note this is a tricky polygon in Antarctica:<br>
<a href="http://www.gcmap.com/mapui?P=79.736894381S+0.780387531W-79.736894381S+170.375361283E-79.692508368S+170.375361283E-79.692508368S+0.780387531W-79.736894381S+0.780387531W&MS=wls&DU=km" rel="noreferrer" target="_blank">http://www.gcmap.com/mapui?P=79.736894381S+0.780387531W-79.736894381S+170.375361283E-79.692508368S+170.375361283E-79.692508368S+0.780387531W-79.736894381S+0.780387531W&MS=wls&DU=km</a><br>
<br>
The area is 899078042.2 m2 as verified using:<br>
<a href="https://geographiclib.sourceforge.io/cgi-bin/Planimeter?type=polygon&rhumb=geodesic&radius=6378137&flattening=1%2F298.257223563&input=-79.736894381+-0.780387531%0D%0A-79.736894381+170.375361283%0D%0A-79.692508368+170.375361283%0D%0A-79.692508368+-0.780387531%0D%0A-79.736894381+-0.780387531&option=Submit" rel="noreferrer" target="_blank">https://geographiclib.sourceforge.io/cgi-bin/Planimeter?type=polygon&rhumb=geodesic&radius=6378137&flattening=1%2F298.257223563&input=-79.736894381+-0.780387531%0D%0A-79.736894381+170.375361283%0D%0A-79.692508368+170.375361283%0D%0A-79.692508368+-0.780387531%0D%0A-79.736894381+-0.780387531&option=Submit</a><br>
<br>
PostGIS uses GeoGraphicLib's method<br>
(<a href="https://doi.org/10.1007/s00190-012-0578-z" rel="noreferrer" target="_blank">https://doi.org/10.1007/s00190-012-0578-z</a>) which has high accuracy.<br>
The bug is likely with other resources.<br>
<br>
<br>
On Wed, 26 Mar 2025 at 05:58, Alexander Trufanov <<a href="mailto:trufanovan@gmail.com" target="_blank">trufanovan@gmail.com</a>> wrote:<br>
><br>
> Hello,<br>
><br>
> I've a following area calculation:<br>
><br>
> select ST_Area(<br>
> ST_GeometryFromText('POLYGON ((-0.780387531 -79.736894381,<br>
> 170.375361283 -79.736894381,<br>
> 170.375361283 -79.692508368,<br>
> -0.780387531 -79.692508368,<br>
> -0.780387531 -79.736894381))', 4326)::geography) /1000000<br>
><br>
> which returns ~900 km^2<br>
><br>
> while ST_Perimeter() for the same geography is ~4600km<br>
> and If I open ST_AsGeoJson() of this geometry in google earth pro and some websites I'm getting ~ 16700 km^2.<br>
> It seems it's a correct result and ST_Area() result is wrong.<br>
><br>
> Is this a known problem?<br>
><br>
> My versions:<br>
> PostgreSQL 15.10 (Debian 15.10-astra.se1) on x86_64-pc-linux-gnu, compiled by gcc (Astra 12.2.0-14.astra3+b1) 12.2.0, 64-bit<br>
> POSTGIS="3.3.2 68f4434" [EXTENSION] PGSQL="150" GEOS="3.11.1-CAPI-1.17.1" PROJ="9.1.1" GDAL="GDAL 3.6.2, released 2023/01/02" LIBXML="2.9.14" LIBJSON="0.16" LIBPROTOBUF="1.4.1" WAGYU="0.5.0 (Internal)" RASTER<br>
><br>
> --<br>
> With best regards,<br>
> Truf<br>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">With best regards,<br>Alexander Trufanov</div></div></div></div>
</blockquote></div><div><br clear="all"></div><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">With best regards,<br>Alexander Trufanov</div></div>