<div dir="ltr">All,<div><br></div><div>Thanks for the replies and confirmation (and warning about caveats). I will use the predicate suggested by <a class="gmail_plusreply" id="plusReplyChip-0">@Erik Wienhold</a></div><div><br></div><div>I'm on Postgis 3.3.3</div><div><br></div><div>"<span style="font-family:Consolas;font-size:10pt;white-space:pre;color:rgb(128,0,0);font-weight:bold">SELECT</span><span style="color:rgb(0,0,0);font-family:Consolas;font-size:10pt;white-space:pre"> </span><span style="color:rgb(0,0,0);font-family:Consolas;font-size:10pt;white-space:pre;text-decoration-line:underline;text-decoration-style:wavy;text-decoration-color:rgb(255,0,128)">ST_IsGeographic</span><span style="color:rgb(0,0,0);font-family:Consolas;font-size:10pt;white-space:pre">(</span><span style="font-family:Consolas;font-size:10pt;white-space:pre;color:rgb(0,0,255)">4326</span><span style="color:rgb(0,0,0);font-family:Consolas;font-size:10pt;white-space:pre">)</span><span style="font-family:Consolas;font-size:10pt;white-space:pre;color:rgb(255,0,0)">;</span>" returns: "SQL Error [42883]: ERROR: function st_isgeographic(integer) does not exist"</div><div><br></div><div>Kind regards,</div><div>Richard</div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">Op wo 30 apr 2025 om 00:30 schreef Erik Wienhold <<a href="mailto:ewie@ewie.name">ewie@ewie.name</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">On 2025-04-30 00:01 +0200, Pettycash dev wrote:<br>
> ### 1) **Checking if `srtext` starts with "GEOGCS"?**<br>
> While `srtext` for geodetic CRSs (e.g., WGS84) starts with `GEOGCS` in its<br>
> WKT definition (e.g., `GEOGCS["WGS 84", ...]`), this method has caveats:<br>
> - **It’s not foolproof**: The `srtext` format can vary (e.g.,<br>
> whitespace, custom definitions).<br>
> - **Not future-proof**: Relies on text parsing, which may break if WKT<br>
> conventions change.<br>
> <br>
> Example query (works in most cases, but not fully robust):<br>
> ```sql<br>
> SELECT srid, srtext<br>
> FROM spatial_ref_sys<br>
> WHERE srtext LIKE 'GEOGCS%'; -- Filters geodetic CRSs<br>
> ```<br>
<br>
According to annex C.4.1 of the standard [1] "geodetic CRS" covers both<br>
geographic and geocentric CRS. So GEOGCS and GEOCCS are relevant. Also<br>
note annex B.8 since there's also GEODCRS, GEODETICCRS, GEOGCRS,<br>
GEOGRAPHICCRS in new versions. Because those are the only ones with<br>
prefix "GEO", you might get away with just using that predicate:<br>
<br>
srtext LIKE 'GEO%'<br>
<br>
[1] <a href="https://docs.ogc.org/is/18-010r11/18-010r11.pdf" rel="noreferrer" target="_blank">https://docs.ogc.org/is/18-010r11/18-010r11.pdf</a><br>
<br>
> ### 2) **Use the built-in PostGIS function `ST_IsGeographic()`** ✅<br>
> PostGIS provides **`ST_IsGeographic(srid)`** to directly check if an SRID<br>
> is geodetic. This is the **recommended method** because:<br>
> - It uses PostGIS’s internal logic (no text parsing).<br>
> - Handles edge cases and custom definitions.<br>
<br>
PostGIS does not provide ST_IsGeographic to my knowledge. Perhaps a<br>
separate extension? Or just an AI hallucination?<br>
<br>
> > Le mar. 29 avr. 2025, 22:45, Richard Huesken <<a href="mailto:richard.huesken@gmail.com" target="_blank">richard.huesken@gmail.com</a>><br>
> > a écrit :<br>
> ><br>
> >> I'm wondering if there is an easy way to detect if an srid refers to a<br>
> >> geodetic CRS, by checking the spatial_ref_sys table.<br>
> >><br>
> >> 1) Would it be safe to assume the srid is a geodetic CRS if the value in<br>
> >> the srtext column starts with 'GEO'? It almost seems to be too good to be<br>
> >> true...<br>
> >><br>
> >> 2) Did I overlook a Postgis function that returns this information (and<br>
> >> if so, which one would that be)?<br>
<br>
-- <br>
Erik Wienhold<br>
</blockquote></div>