Determine if an srid refers to a geodetic CRS

Pettycash dev alphonseessomba60 at gmail.com
Tue Apr 29 14:55:04 PDT 2025


Pour répondre à vos questions sur la détection des SRID géodésiques dans
PostGIS :

### 1) Vérifier si `srtext` commence par "GEO" ?
**Non, ce n'est pas une méthode fiable.**
Les CRS géodésiques (sphère/ellipsoïde) sont représentés en WKT par
`GEOGCS` (ex: `GEOGCS["WGS 84", ...]`). Bien que "GEO" soit présent, il est
préférable de vérifier **`srtext LIKE 'GEOGCS%'`** pour éviter les faux
positifs. Cependant, cette approche reste fragile (format WKT variable,
entrées personnalisées).

---

### 2) Existe-t-il une fonction PostGIS dédiée ?
**Oui, utilisez `ST_IsGeographic(srid)`** (disponible depuis PostGIS 2.2).
Cette fonction retourne **`true`** si le SRID correspond à un CRS
géographique (géodésique), et **`false`** pour un CRS projeté ou inconnu.

**Exemple d'utilisation :**
```sql
SELECT ST_IsGeographic(4326); -- Retourne true (WGS84 géodésique)
SELECT ST_IsGeographic(3857); -- Retourne false (Web Mercator projeté)
```

---

### Solution recommandée :
```sql
-- Vérifier directement via ST_IsGeographic()
SELECT srid, auth_name, srtext
FROM spatial_ref_sys
WHERE ST_IsGeographic(srid) = true;
```

Cette méthode est **plus robuste** que l'analyse de `srtext` ou
`proj4text`, car elle s'appuie sur la logique interne de PostGIS.

Le mar. 29 avr. 2025, 22:45, Richard Huesken <richard.huesken at gmail.com> a
écrit :

> Hi,
>
> I'm wondering if there is an easy way to detect if an srid refers to a
> geodetic CRS, by checking the spatial_ref_sys table.
>
> 1) Would it be safe to assume the srid is a geodetic CRS if the value in
> the srtext column starts with 'GEO'? It almost seems to be too good to be
> true...
>
> 2) Did I overlook a Postgis function that returns this information (and if
> so, which one would that be)?
>
> Thanks in advance,
>
> Kind regards
> Richard.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20250429/18286f3d/attachment.htm>


More information about the postgis-users mailing list