[postgis-users] TR: strange behavior of ST_Area(geography)
Regina Obe
lr at pcorp.us
Mon Oct 16 08:35:12 PDT 2017
That is very strange. I tested on 2.4.0 PostgreSQL 10 Windows 64-bit
POSTGIS="2.4.0 r15853" PGSQL="100" GEOS="3.6.2-CAPI-1.10.2 4d2925d" PROJ="Rel. 4.9.3, 15 August 2016" GDAL="GDAL 2.2.2, released 2017/09/15 GDAL_DATA not found" LIBXML="2.7.8" LIBJSON="0.12" LIBPROTOBUF="1.2.1" RASTER PostgreSQL 10.0, compiled by Visual C++ build 1800, 64-bit
WITH poly AS (
SELECT
ST_SetSRID(ST_GeomFromText(
'POLYGON((138.002 37.001, 138.003 37.0010, 138.003 37.0013, 138.002 37.001))'
),4326) g1,
ST_SetSRID(ST_GeomFromText(
'POLYGON((138.002 37.001, 138.003 37.0013, 138.003 37.0010, 138.002 37.001))'
),4326) g2
)
SELECT ST_Equals(g1,g2),
ST_Area(g1) = ST_Area(g2) AS eq_area,
ST_Area(g1::geography) = ST_Area(g2::geography) AS geog1,
ST_Area(g1::geography, false) = ST_Area(g2::geography, false) AS geog2,
ST_Area(g1::geography) = ST_Area(ST_Reverse(g2)::geography) AS geog3,
ST_Area(ST_Transform(g1,32654)) = ST_Area(ST_Transform(g2,32654)) AS geom
FROM poly;
And get all trues as expected.
st_equals | eq_area | geog1 | geog2 | geog3 | geom
-----------+---------+-------+-------+-------+------
t | t | t | t | t | t
(1 row)
What does this query return you
WITH poly AS (
SELECT
ST_SetSRID(ST_GeomFromText(
'POLYGON((138.002 37.001, 138.003 37.0010, 138.003 37.0013, 138.002 37.001))'
),4326) g1,
ST_SetSRID(ST_GeomFromText(
'POLYGON((138.002 37.001, 138.003 37.0013, 138.003 37.0010, 138.002 37.001))'
),4326) g2
)
SELECT ST_Equals(g1,g2),
ST_Area(g1) - ST_Area(g2) AS eq_area,
ST_Area(g1::geography) - ST_Area(g2::geography) AS geog1,
ST_Area(g1::geography, false) - ST_Area(g2::geography, false) AS geog2,
ST_Area(g1::geography) - ST_Area(ST_Reverse(g2)::geography) AS geog3,
ST_Area(ST_Transform(g1,32654)) - ST_Area(ST_Transform(g2,32654)) AS geom
FROM poly;
I get
st_equals | eq_area | geog1 | geog2 | geog3 | geom
-----------+---------+-------+-------+-------+------
t | 0 | 0 | 0 | 0 | 0
(1 row)
-----Original Message-----
From: postgis-users [mailto:postgis-users-bounces at lists.osgeo.org] On Behalf Of IIDA Tetsushi
Sent: Monday, October 16, 2017 9:58 AM
To: PostGIS Users Discussion <postgis-users at lists.osgeo.org>
Subject: Re: [postgis-users] TR: strange behavior of ST_Area(geography)
Thanks all.
I tested on another PostGIS 2.4 environment (CentOS7.4 + EPEL repo.) but it returned same bad result.
-------
POSTGIS="2.4.0 r15853" PGSQL="96" GEOS="3.5.0-CAPI-1.9.0 r4084" SFCGAL="1.2.2"
PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.11.4, released 2016/01/25"
LIBXML="2.9.1" LIBJSON="0.11" RASTER
-------
I have not enough time to build full environment from source now.
probably this behavor is not caused by PostGIS itself.
anyway, I wrote it as a record for those using the same environment.
--
hogeman
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users
More information about the postgis-users
mailing list