Geometry / geography woes
Paul Ramsey
pramsey at cleverelephant.ca
Tue Sep 9 12:20:21 PDT 2025
You're subdividing in a planar space and then applying a geodetic
calculation. The subdivision in planar space is the same as the input, but
not in the geodetic space. If you st_segmentize your original before
subdividing, you can reduce the effect, but you cannot get rid of it. Or
apply st_subdivide on your geometry in a local gnomonic projection, where
great circles are straight lines, rather than in a plate carre.
P.
On Tue, Sep 9, 2025 at 12:00 PM nikolai.berkoff via postgis-users <
postgis-users at lists.osgeo.org> wrote:
> Thank you very much,
>
> I guess my toy example was too much of a toy but I still think the problem
> exists with the suggestion to use ST_Subdivide as it will chop up a
> geometries long "straight lines" into smaller "straight lines".
>
> https://postgis.net/documentation/faq/big-objects-performance/
> seems to suggest to use ST_Subdivide to work with large geometries but
> https://postgis.net/documentation/faq/geography-inside/
> and the responses here make it clear that it doesn't work if I want to
> then use any geographical calculation.
>
> A better toy example is getting the distance of the geom to a point:
>
> SELECT ST_Distance(geography('POINT(-77 48)'), geometry('POLYGON((-71.37
> 55.8,-63.96 54.61,-72.49 51.77,-81.32 46.47,-81.89 46.09,-81.95
> 46.09,-81.97 46.09,-82 46.09,-82.01 46.09,-82.02 46.1,-82.03 46.1,-82.04
> 46.1,-82.05 46.1,-82.07 46.11,-82.09 46.11,-82.12 46.11,-82.12 46.1,-82.13
> 46.1,-82.14 46.11,-82.14 46.1,-82.15 46.1,-82.15 46.11,-82.16 46.11,-82.19
> 46.12,-82.19 46.13,-82.2 46.13,-82.21 46.14,-82.21 46.13,-82.22
> 46.13,-82.22 46.14,-82.23 46.14,-82.24 46.14,-82.26 46.14,-82.28
> 46.14,-82.3 46.15,-82.3 46.14,-82.33 46.15,-82.34 46.15,-82.35 46.15,-82.35
> 46.16,-82.36 46.16,-82.36 46.17,-82.35 46.17,-82.32 46.16,-82.32
> 46.17,-82.32 46.18,-82.34 46.18,-82.37 46.18,-82.38 46.18,-82.39
> 46.18,-82.4 46.18,-82.42 46.18,-82.43 46.18,-82.44 46.17,-82.45
> 46.17,-82.45 46.19,-82.46 46.2,-82.47 46.19,-82.48 46.18,-82.49 46.18,-82.5
> 46.18,-82.52 46.17,-82.53 46.17,-82.54 46.16,-82.55 46.17,-82.56
> 46.17,-82.58 46.17,-82.59 46.16,-82.6 46.16,-82.62 46.16,-82.62
> 46.15,-82.63 46.15,-82.64 46.15,-82.67 46.15,-82.68 46.16,-82.67
> 46.17,-82.68 46.17,-82.68 46.18,-82.67 46.19,-82.66 46.19,-82.64
> 46.19,-82.62 46.2,-82.65 46.2,-82.67 46.2,-82.71 46.19,-82.74 46.19,-82.76
> 46.18,-82.78 46.18,-82.79 46.18,-82.8 46.17,-82.81 46.17,-82.82
> 46.17,-82.84 46.17,-82.86 46.17,-82.87 46.17,-82.88 46.17,-82.91
> 46.18,-82.92 46.18,-82.93 46.17,-82.94 46.18,-82.96 46.17,-83 46.16,-83.01
> 46.17,-83.03 46.16,-83.05 46.16,-83.06 46.16,-83.09 46.16,-83.1 46.16,-83.1
> 46.17,-83.06 46.17,-83.05 46.18,-83.07 46.18,-83.08 46.19,-83.09
> 46.19,-83.1 46.19,-83.12 46.18,-83.13 46.18,-83.14 46.18,-83.15
> 46.18,-83.15 46.19,-83.17 46.2,-83.18 46.2,-83.19 46.19,-83.2 46.19,-83.22
> 46.2,-83.25 46.2,-83.26 46.21,-83.27 46.21,-83.28 46.21,-83.29 46.21,-83.3
> 46.21,-83.31 46.21,-83.32 46.22,-83.33 46.22,-83.34 46.22,-83.35
> 46.23,-83.38 46.23,-83.41 46.24,-83.43 46.24,-83.45 46.24,-83.47
> 46.24,-84.51 46.82,-84.5 46.82,-84.49 46.84,-84.48 46.84,-84.47
> 46.84,-84.46 46.84,-84.44 46.84,-84.43 46.83,-84.42 46.82,-84.42
> 46.81,-84.4 46.81,-84.4 46.82,-84.39 46.83,-84.38 46.83,-84.38 46.84,-84.37
> 46.84,-84.37 46.85,-84.37 46.86,-84.36 46.87,-84.36 46.88,-84.36
> 46.89,-84.38 46.89,-84.39 46.9,-84.4 46.91,-84.42 46.91,-84.43 46.91,-84.43
> 46.92,-84.44 46.92,-84.47 46.93,-84.48 46.93,-84.49 46.93,-84.51
> 46.92,-84.52 46.92,-84.53 46.93,-84.54 46.93,-84.55 46.94,-84.57
> 46.94,-84.58 46.93,-84.59 46.93,-84.6 46.93,-84.6 46.92,-84.6 46.91,-84.6
> 46.9,-84.61 46.89,-84.65 46.91,-84.65 46.92,-84.66 46.95,-84.67
> 46.96,-84.69 46.96,-84.7 46.96,-84.72 46.95,-84.73 46.95,-84.75
> 46.96,-84.76 46.97,-84.78 46.97,-84.78 46.98,-84.79 46.99,-84.79 47,-84.78
> 47,-84.78 47.01,-84.77 47.01,-84.78 47.02,-84.78 47.03,-84.78 47.04,-84.77
> 47.04,-84.77 47.05,-84.76 47.05,-84.75 47.06,-84.74 47.07,-84.73
> 47.07,-84.72 47.09,-84.71 47.1,-84.71 47.11,-84.72 47.11,-84.73
> 47.12,-84.73 47.13,-84.74 47.13,-84.74 47.14,-84.73 47.14,-84.72
> 47.14,-84.71 47.15,-84.7 47.15,-84.69 47.17,-84.71 47.17,-84.71 47.18,-84.7
> 47.18,-84.69 47.19,-84.68 47.19,-84.68 47.2,-84.67 47.2,-84.67 47.21,-84.66
> 47.21,-84.66 47.22,-84.65 47.22,-84.65 47.23,-84.65 47.24,-84.64
> 47.24,-84.64 47.25,-84.63 47.25,-84.62 47.26,-84.61 47.26,-84.6 47.27,-84.6
> 47.28,-84.59 47.28,-84.59 47.29,-84.58 47.29,-84.58 47.3,-84.59 47.3,-84.6
> 47.3,-84.61 47.34,-84.62 47.34,-84.63 47.34,-84.63 47.35,-84.64
> 47.35,-84.64 47.36,-84.65 47.36,-84.66 47.36,-84.67 47.35,-84.68
> 47.36,-84.69 47.36,-84.7 47.37,-84.7 47.38,-84.7 47.39,-84.7 47.4,-84.71
> 47.41,-84.71 47.42,-84.72 47.42,-84.73 47.43,-84.74 47.43,-84.75
> 47.44,-84.76 47.44,-84.76 47.45,-84.78 47.46,-84.79 47.47,-84.82
> 47.48,-84.83 47.48,-84.83 47.49,-84.87 47.49,-84.87 47.5,-84.88 47.5,-84.89
> 47.5,-84.9 47.51,-80.86 49.7,-79.08 51.52,-79.06 51.51,-79.04 51.51,-79.03
> 51.49,-79 51.47,-78.99 51.47,-78.98 51.46,-78.98 51.45,-78.98 51.43,-78.98
> 51.42,-78.98 51.41,-78.97 51.4,-78.97 51.38,-78.96 51.35,-78.95
> 51.34,-78.95 51.33,-78.96 51.32,-78.96 51.31,-78.95 51.3,-78.95
> 51.29,-78.94 51.28,-78.94 51.27,-78.95 51.26,-78.96 51.25,-78.96
> 51.24,-78.96 51.23,-78.95 51.21,-78.95 51.2,-78.94 51.19,-78.93
> 51.18,-78.92 51.18,-78.91 51.18,-78.9 51.17,-78.88 51.17,-78.87
> 51.17,-78.86 51.17,-78.86 51.18,-78.87 51.18,-78.87 51.19,-78.87
> 51.2,-78.89 51.2,-78.89 51.21,-78.9 51.21,-78.91 51.21,-78.92 51.22,-78.92
> 51.23,-78.93 51.25,-78.92 51.26,-78.91 51.28,-78.91 51.3,-78.91 51.31,-78.9
> 51.31,-78.89 51.32,-78.88 51.32,-78.88 51.33,-78.87 51.34,-78.87
> 51.35,-78.86 51.35,-78.85 51.35,-78.84 51.35,-78.84 51.36,-78.85
> 51.36,-78.86 51.36,-78.87 51.36,-78.89 51.37,-78.9 51.37,-78.9 51.38,-78.9
> 51.39,-78.9 51.4,-78.89 51.4,-78.87 51.41,-78.86 51.42,-78.84 51.43,-78.83
> 51.44,-78.82 51.45,-78.81 51.45,-78.81 51.46,-78.8 51.46,-78.79
> 51.48,-78.77 51.49,-78.76 51.49,-78.73 51.49,-78.72 51.49,-78.71
> 51.49,-78.7 51.49,-78.69 51.48,-78.68 51.49,-78.69 51.5,-78.7 51.5,-78.71
> 51.51,-78.72 51.51,-78.73 51.5,-78.75 51.5,-78.76 51.5,-78.77 51.5,-78.78
> 51.5,-78.79 51.5,-78.81 51.5,-78.83 51.51,-78.83 51.52,-78.82 51.53,-78.82
> 51.54,-78.82 51.55,-78.83 51.57,-78.83 51.58,-78.82 51.59,-78.82
> 51.6,-78.82 51.61,-78.83 51.61,-78.84 51.61,-78.85 51.61,-78.85
> 51.62,-78.86 51.63,-78.87 51.64,-78.89 51.64,-78.9 51.65,-78.91
> 51.65,-78.93 51.65,-78.94 51.66,-77.83 52.8,-71.37 55.8))'));
>
> st_distance
> -----------------
> 105664.41899567
> (1 row)
>
>
> and then getting the distance after having pre-conditioning my data via
> ST_Subdivide gives a shorter result. Thanks to your answers I now
> understand why but it feels like this is a large caveat in using
> ST_Subdivide.
>
> SELECT ST_Distance(geography('POINT(-77 48)'),
> ST_Subdivide(geometry('POLYGON((-71.37 55.8,-63.96 54.61,-72.49
> 51.77,-81.32 46.47,-81.89 46.09,-81.95 46.09,-81.97 46.09,-82 46.09,-82.01
> 46.09,-82.02 46.1,-82.03 46.1,-82.04 46.1,-82.05 46.1,-82.07 46.11,-82.09
> 46.11,-82.12 46.11,-82.12 46.1,-82.13 46.1,-82.14 46.11,-82.14 46.1,-82.15
> 46.1,-82.15 46.11,-82.16 46.11,-82.19 46.12,-82.19 46.13,-82.2 46.13,-82.21
> 46.14,-82.21 46.13,-82.22 46.13,-82.22 46.14,-82.23 46.14,-82.24
> 46.14,-82.26 46.14,-82.28 46.14,-82.3 46.15,-82.3 46.14,-82.33 46.15,-82.34
> 46.15,-82.35 46.15,-82.35 46.16,-82.36 46.16,-82.36 46.17,-82.35
> 46.17,-82.32 46.16,-82.32 46.17,-82.32 46.18,-82.34 46.18,-82.37
> 46.18,-82.38 46.18,-82.39 46.18,-82.4 46.18,-82.42 46.18,-82.43
> 46.18,-82.44 46.17,-82.45 46.17,-82.45 46.19,-82.46 46.2,-82.47
> 46.19,-82.48 46.18,-82.49 46.18,-82.5 46.18,-82.52 46.17,-82.53
> 46.17,-82.54 46.16,-82.55 46.17,-82.56 46.17,-82.58 46.17,-82.59
> 46.16,-82.6 46.16,-82.62 46.16,-82.62 46.15,-82.63 46.15,-82.64
> 46.15,-82.67 46.15,-82.68 46.16,-82.67 46.17,-82.68 46.17,-82.68
> 46.18,-82.67 46.19,-82.66 46.19,-82.64 46.19,-82.62 46.2,-82.65 46.2,-82.67
> 46.2,-82.71 46.19,-82.74 46.19,-82.76 46.18,-82.78 46.18,-82.79 46.18,-82.8
> 46.17,-82.81 46.17,-82.82 46.17,-82.84 46.17,-82.86 46.17,-82.87
> 46.17,-82.88 46.17,-82.91 46.18,-82.92 46.18,-82.93 46.17,-82.94
> 46.18,-82.96 46.17,-83 46.16,-83.01 46.17,-83.03 46.16,-83.05 46.16,-83.06
> 46.16,-83.09 46.16,-83.1 46.16,-83.1 46.17,-83.06 46.17,-83.05 46.18,-83.07
> 46.18,-83.08 46.19,-83.09 46.19,-83.1 46.19,-83.12 46.18,-83.13
> 46.18,-83.14 46.18,-83.15 46.18,-83.15 46.19,-83.17 46.2,-83.18 46.2,-83.19
> 46.19,-83.2 46.19,-83.22 46.2,-83.25 46.2,-83.26 46.21,-83.27 46.21,-83.28
> 46.21,-83.29 46.21,-83.3 46.21,-83.31 46.21,-83.32 46.22,-83.33
> 46.22,-83.34 46.22,-83.35 46.23,-83.38 46.23,-83.41 46.24,-83.43
> 46.24,-83.45 46.24,-83.47 46.24,-84.51 46.82,-84.5 46.82,-84.49
> 46.84,-84.48 46.84,-84.47 46.84,-84.46 46.84,-84.44 46.84,-84.43
> 46.83,-84.42 46.82,-84.42 46.81,-84.4 46.81,-84.4 46.82,-84.39 46.83,-84.38
> 46.83,-84.38 46.84,-84.37 46.84,-84.37 46.85,-84.37 46.86,-84.36
> 46.87,-84.36 46.88,-84.36 46.89,-84.38 46.89,-84.39 46.9,-84.4 46.91,-84.42
> 46.91,-84.43 46.91,-84.43 46.92,-84.44 46.92,-84.47 46.93,-84.48
> 46.93,-84.49 46.93,-84.51 46.92,-84.52 46.92,-84.53 46.93,-84.54
> 46.93,-84.55 46.94,-84.57 46.94,-84.58 46.93,-84.59 46.93,-84.6 46.93,-84.6
> 46.92,-84.6 46.91,-84.6 46.9,-84.61 46.89,-84.65 46.91,-84.65 46.92,-84.66
> 46.95,-84.67 46.96,-84.69 46.96,-84.7 46.96,-84.72 46.95,-84.73
> 46.95,-84.75 46.96,-84.76 46.97,-84.78 46.97,-84.78 46.98,-84.79
> 46.99,-84.79 47,-84.78 47,-84.78 47.01,-84.77 47.01,-84.78 47.02,-84.78
> 47.03,-84.78 47.04,-84.77 47.04,-84.77 47.05,-84.76 47.05,-84.75
> 47.06,-84.74 47.07,-84.73 47.07,-84.72 47.09,-84.71 47.1,-84.71
> 47.11,-84.72 47.11,-84.73 47.12,-84.73 47.13,-84.74 47.13,-84.74
> 47.14,-84.73 47.14,-84.72 47.14,-84.71 47.15,-84.7 47.15,-84.69
> 47.17,-84.71 47.17,-84.71 47.18,-84.7 47.18,-84.69 47.19,-84.68
> 47.19,-84.68 47.2,-84.67 47.2,-84.67 47.21,-84.66 47.21,-84.66 47.22,-84.65
> 47.22,-84.65 47.23,-84.65 47.24,-84.64 47.24,-84.64 47.25,-84.63
> 47.25,-84.62 47.26,-84.61 47.26,-84.6 47.27,-84.6 47.28,-84.59 47.28,-84.59
> 47.29,-84.58 47.29,-84.58 47.3,-84.59 47.3,-84.6 47.3,-84.61 47.34,-84.62
> 47.34,-84.63 47.34,-84.63 47.35,-84.64 47.35,-84.64 47.36,-84.65
> 47.36,-84.66 47.36,-84.67 47.35,-84.68 47.36,-84.69 47.36,-84.7 47.37,-84.7
> 47.38,-84.7 47.39,-84.7 47.4,-84.71 47.41,-84.71 47.42,-84.72 47.42,-84.73
> 47.43,-84.74 47.43,-84.75 47.44,-84.76 47.44,-84.76 47.45,-84.78
> 47.46,-84.79 47.47,-84.82 47.48,-84.83 47.48,-84.83 47.49,-84.87
> 47.49,-84.87 47.5,-84.88 47.5,-84.89 47.5,-84.9 47.51,-80.86 49.7,-79.08
> 51.52,-79.06 51.51,-79.04 51.51,-79.03 51.49,-79 51.47,-78.99 51.47,-78.98
> 51.46,-78.98 51.45,-78.98 51.43,-78.98 51.42,-78.98 51.41,-78.97
> 51.4,-78.97 51.38,-78.96 51.35,-78.95 51.34,-78.95 51.33,-78.96
> 51.32,-78.96 51.31,-78.95 51.3,-78.95 51.29,-78.94 51.28,-78.94
> 51.27,-78.95 51.26,-78.96 51.25,-78.96 51.24,-78.96 51.23,-78.95
> 51.21,-78.95 51.2,-78.94 51.19,-78.93 51.18,-78.92 51.18,-78.91 51.18,-78.9
> 51.17,-78.88 51.17,-78.87 51.17,-78.86 51.17,-78.86 51.18,-78.87
> 51.18,-78.87 51.19,-78.87 51.2,-78.89 51.2,-78.89 51.21,-78.9 51.21,-78.91
> 51.21,-78.92 51.22,-78.92 51.23,-78.93 51.25,-78.92 51.26,-78.91
> 51.28,-78.91 51.3,-78.91 51.31,-78.9 51.31,-78.89 51.32,-78.88 51.32,-78.88
> 51.33,-78.87 51.34,-78.87 51.35,-78.86 51.35,-78.85 51.35,-78.84
> 51.35,-78.84 51.36,-78.85 51.36,-78.86 51.36,-78.87 51.36,-78.89
> 51.37,-78.9 51.37,-78.9 51.38,-78.9 51.39,-78.9 51.4,-78.89 51.4,-78.87
> 51.41,-78.86 51.42,-78.84 51.43,-78.83 51.44,-78.82 51.45,-78.81
> 51.45,-78.81 51.46,-78.8 51.46,-78.79 51.48,-78.77 51.49,-78.76
> 51.49,-78.73 51.49,-78.72 51.49,-78.71 51.49,-78.7 51.49,-78.69
> 51.48,-78.68 51.49,-78.69 51.5,-78.7 51.5,-78.71 51.51,-78.72 51.51,-78.73
> 51.5,-78.75 51.5,-78.76 51.5,-78.77 51.5,-78.78 51.5,-78.79 51.5,-78.81
> 51.5,-78.83 51.51,-78.83 51.52,-78.82 51.53,-78.82 51.54,-78.82
> 51.55,-78.83 51.57,-78.83 51.58,-78.82 51.59,-78.82 51.6,-78.82
> 51.61,-78.83 51.61,-78.84 51.61,-78.85 51.61,-78.85 51.62,-78.86
> 51.63,-78.87 51.64,-78.89 51.64,-78.9 51.65,-78.91 51.65,-78.93
> 51.65,-78.94 51.66,-77.83 52.8,-71.37 55.8))'))) order by 1;
> st_distance
> -----------------
> 92373.36598847
> 126170.82808402
> 364673.04933925
> 407862.08030654
> 529769.79532574
>
>
> On Tuesday, 9 September 2025 at 18:05, Regina Obe <lr at pcorp.us> wrote:
>
> > Your smaller polygon is not within the larger one. If it was then this
> would return true
> >
>
> > SELECT ST_Intersects(ST_GeomFromText('POLYGON((-77.933927810506
> 48.584377886263184,-77.74471476703403 48.69534746901027,-77.69284285304693
> 48.71525447165988,-77.99039086603969 48.53485501013662,-77.933927810506
> 48.584377886263184))', 4326)::geography,
> ST_GeomFromText('POLYGON((-81.1755551313531
> 46.64525933571578,-81.50518756520556 47.21802525065504,-81.6706742747649
> 47.82323694299835,-81.6602226284047 48.438637358868554,-81.46784223247613
> 49.04081439308046,-81.09452004412593 49.60598066574395,-80.54928811996326
> 50.110912115887594,-79.84994871352842 50.53403375725974,-79.02318022750863
> 50.85659915226637,-78.10377843647761 51.06386274945413,-77.13291403765557
> 51.14610652092342,-76.15549659681517 51.09937193283258,-75.21696581007667
> 50.925776760111056,-74.42324583717638 50.655006343959805,-81.12758032107652
> 46.593233077736336,-81.1755551313531 46.64525933571578))',4326)::geography);
> >
>
> > And it returns false. Your ST_Within compare in planar space is invalid
> as it's treating the surfaces as planar.
> >
>
> > If you segmentize your geographies you will see the smaller is not
> within the larger.
> >
>
> > Here is what you get segmentizing in spheroidal space
> >
>
> > SELECT ST_Segmentize(ST_GeomFromText('POLYGON((-77.933927810506
> 48.584377886263184,-77.74471476703403 48.69534746901027,-77.69284285304693
> 48.71525447165988,-77.99039086603969 48.53485501013662,-77.933927810506
> 48.584377886263184))', 4326)::geography, 1000)
> >
>
> > UNION ALL
> >
>
> > SELECT ST_Segmentize(ST_GeomFromText('POLYGON((-81.1755551313531
> 46.64525933571578,-81.50518756520556 47.21802525065504,-81.6706742747649
> 47.82323694299835,-81.6602226284047 48.438637358868554,-81.46784223247613
> 49.04081439308046,-81.09452004412593 49.60598066574395,-80.54928811996326
> 50.110912115887594,-79.84994871352842 50.53403375725974,-79.02318022750863
> 50.85659915226637,-78.10377843647761 51.06386274945413,-77.13291403765557
> 51.14610652092342,-76.15549659681517 51.09937193283258,-75.21696581007667
> 50.925776760111056,-74.42324583717638 50.655006343959805,-81.12758032107652
> 46.593233077736336,-81.1755551313531 46.64525933571578))',4326)::geography,
> 1000);
> >
>
> > Here is your planar:
> >
>
> > SELECT ST_GeomFromText('POLYGON((-77.933927810506
> 48.584377886263184,-77.74471476703403 48.69534746901027,-77.69284285304693
> 48.71525447165988,-77.99039086603969 48.53485501013662,-77.933927810506
> 48.584377886263184))', 4326)::geography
> >
>
> > UNION ALL
> >
>
> > SELECT ST_GeomFromText('POLYGON((-81.1755551313531
> 46.64525933571578,-81.50518756520556 47.21802525065504,-81.6706742747649
> 47.82323694299835,-81.6602226284047 48.438637358868554,-81.46784223247613
> 49.04081439308046,-81.09452004412593 49.60598066574395,-80.54928811996326
> 50.110912115887594,-79.84994871352842 50.53403375725974,-79.02318022750863
> 50.85659915226637,-78.10377843647761 51.06386274945413,-77.13291403765557
> 51.14610652092342,-76.15549659681517 51.09937193283258,-75.21696581007667
> 50.925776760111056,-74.42324583717638 50.655006343959805,-81.12758032107652
> 46.593233077736336,-81.1755551313531 46.64525933571578))',4326)::geography;
> >
>
> > > -----Original Message-----
> >
>
> > > From: nikolai.berkoff via postgis-users <postgis-users at lists.osgeo.org
> >
> >
>
> > > Sent: Tuesday, September 9, 2025 7:36 AM
> >
>
> > > To: postgis-users at lists.osgeo.org
> >
>
> > > Subject: Geometry / geography woes
> >
>
> > >
> >
>
> > > Hi,
> >
>
> > >
> >
>
> > > I work for a conservation NGO and we deal with lots of species ranges.
> >
>
> > >
> >
>
> > > We have a complicated full geometry (SRID 4326)
> >
>
> > > https://www.iucnredlist.org/species/22733619/139214707 that we have
> >
>
> > > ST_Subdivided. We notice a large difference between the geographical
> >
>
> > > distance from a point (-77 48) to the full geometry and to nearest
> subdiveded
> >
>
> > > geometry.
> >
>
> > >
> >
>
> > > Here is a toy example with two polygon geometries, one large and the
> other
> >
>
> > > small and a point https://wktmap.com/?771d2fc9 . First the
> geographical
> >
>
> > > distance from the point to the large geometry:
> >
>
> > >
> >
>
> > > SELECT ST_Distance(ST_SetSRID(ST_MakePoint(-77, 48),4326)::geography,
> >
>
> > > ST_GeomFromText('POLYGON((-81.1755551313531 46.64525933571578,-
> >
>
> > > 81.50518756520556 47.21802525065504,-81.6706742747649
> >
>
> > > 47.82323694299835,-81.6602226284047 48.438637358868554,-
> >
>
> > > 81.46784223247613 49.04081439308046,-81.09452004412593
> >
>
> > > 49.60598066574395,-80.54928811996326 50.110912115887594,-
> >
>
> > > 79.84994871352842 50.53403375725974,-79.02318022750863
> >
>
> > > 50.85659915226637,-78.10377843647761 51.06386274945413,-
> >
>
> > > 77.13291403765557 51.14610652092342,-76.15549659681517
> >
>
> > > 51.09937193283258,-75.21696581007667 50.925776760111056,-
> >
>
> > > 74.42324583717638 50.655006343959805,-81.12758032107652
> >
>
> > > 46.593233077736336,-81.1755551313531
> >
>
> > > 46.64525933571578))',4326)::geography);
> >
>
> > >
> >
>
> > > st_distance
> >
>
> > >
> >
>
> > > -----------------
> >
>
> > > 100757.06933552
> >
>
> > >
> >
>
> > >
> >
>
> > > next the geographical distance from the point to the small geometry
> >
>
> > >
> >
>
> > > SELECT ST_Distance(ST_SetSRID(ST_MakePoint(-77, 48),4326)::geography,
> >
>
> > > ST_GeomFromText('POLYGON((-77.933927810506 48.584377886263184,-
> >
>
> > > 77.74471476703403 48.69534746901027,-77.69284285304693
> >
>
> > > 48.71525447165988,-77.99039086603969 48.53485501013662,-
> >
>
> > > 77.933927810506 48.584377886263184))', 4326)::geography);
> >
>
> > > st_distance
> >
>
> > >
> >
>
> > > ----------------
> >
>
> > > 93442.14463111
> >
>
> > >
> >
>
> > >
> >
>
> > > finally, showing the the small geometry is fully within the large
> geometry
> >
>
> > >
> >
>
> > > SELECT ST_Within(ST_GeomFromText('POLYGON((-77.933927810506
> >
>
> > > 48.584377886263184,-77.74471476703403 48.69534746901027,-
> >
>
> > > 77.69284285304693 48.71525447165988,-77.99039086603969
> >
>
> > > 48.53485501013662,-77.933927810506 48.584377886263184))', 4326),
> >
>
> > > ST_GeomFromText('POLYGON((-81.1755551313531 46.64525933571578,-
> >
>
> > > 81.50518756520556 47.21802525065504,-81.6706742747649
> >
>
> > > 47.82323694299835,-81.6602226284047 48.438637358868554,-
> >
>
> > > 81.46784223247613 49.04081439308046,-81.09452004412593
> >
>
> > > 49.60598066574395,-80.54928811996326 50.110912115887594,-
> >
>
> > > 79.84994871352842 50.53403375725974,-79.02318022750863
> >
>
> > > 50.85659915226637,-78.10377843647761 51.06386274945413,-
> >
>
> > > 77.13291403765557 51.14610652092342,-76.15549659681517
> >
>
> > > 51.09937193283258,-75.21696581007667 50.925776760111056,-
> >
>
> > > 74.42324583717638 50.655006343959805,-81.12758032107652
> >
>
> > > 46.593233077736336,-81.1755551313531 46.64525933571578))',4326));
> >
>
> > > st_within
> >
>
> > >
> >
>
> > > -----------
> >
>
> > > t
> >
>
> > >
> >
>
> > >
> >
>
> > > Why is the geographical distance to the point and the geometry
> increasing
> >
>
> > > when we are only making the geometry bigger? Surely as the geometry
> gets
> >
>
> > > bigger it should get nearer to the point?
> >
>
> > >
> >
>
> > > Thank you very much!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20250909/f7154fef/attachment.htm>
More information about the postgis-users
mailing list