I have a PostGIS 2.2 table that stores polygons as geography
type. The table contains several polygons that cross the antimeridian. I would like to split these polygons at the antimeridian and convert the table's topology from geography
to geometry
.
3 Answers
In the example below, thepolygon table is called poly_coverage and the output table is fixed_polygons.
Select the polygons that cross the anti-meridian, cast to geom and shift to 0-360, then split them. Select the split polys with any longitude > 180, and shift back 360 deg
Create table beams_fixed_dump4 as Select ST_Translate(foo2.thegeom, -360, 0) as newgeom from
(Select (ST_DUMP(foo.geom)).geom as thegeom from
(Select ST_Split(shift_lon.geom, line2) as geom
from ST_SetSRID(ST_MakeLine(ST_MakePoint(180, -90),ST_MakePoint(180, 90)), 4326) As line2,
(Select ST_ShiftLongitude(geog::geometry) as geom from
(SELECT ST_Intersects(poly_coverage.geog, line) as inter, poly_coverage.* from poly_coverage, ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line) as tmp where inter = TRUE) as shift_lon) as foo) as foo2 where st_xmax(foo2.thegeom) > 180
Union all
Select the polygon that cross the anti-meridian, cast to geom and shift to 0-360, then split them. Select the split polys with all longitude <= 180.
Select newgeom from
(Select (ST_DUMP(foo.geom)).geom as newgeom from
(Select ST_Split(shift_lon.geom, line2) as geom from
ST_SetSRID(ST_MakeLine(ST_MakePoint(180, -90),ST_MakePoint(180, 90)), 4326) As line2,
(Select ST_ShiftLongitude(geog::geometry) as geom from
(SELECT ST_Intersects(poly_coverage.geog, line) as inter, poly_coverage.*
from poly_coverage, ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line) as tmp where inter = TRUE) as shift_lon) as foo)as foo2 where st_xmax(newgeom) <= 180
Union all
Select the polygons that don't cross the anti-meridian and cast to geom.
SELECT foo.geog::geometry from
(Select ST_Intersects(poly_coverage.geog, line) as inter, poly_coverage.* from
poly_coverage, ST_GeogFromText('LINESTRING(180 -90, 180 0, 180 90)') As line) as foo where inter = FALSE;
-
4This query does not work correctly for polygons that surround one of the poles. Also, I am uncertain if it will process a line correctly with a point exactly at either pole. However, PostGIS seems to correctly convert such polygons from geography to geometry. You can simply exclude these polygons from the first two parts of the query and process them in the third.– jgm_GISCommented Dec 23, 2016 at 19:45
The 180th Meridian was a handy reference for me understanding this problem. I think working with Common Table Expressions (CTE) may give you better performance than all the temporary tables required for SELECT ... FROM (SELECT ... FROM ...)
. Here is a query I came up with to split multipolygons along the antimeridian/dateline for the table poly_coverage
with geometry geom
.
WITH t AS (
SELECT
ST_WrapX(
(
ST_Dump(ST_Split(ST_ShiftLongitude(geom),
ST_GeomFromText('LINESTRING(180 -90, 180 90)', 4326)))
).geom,
180, -360) AS geom
FROM poly_coverage
)
UPDATE poly_coverage
SET geom=ST_Multi(ST_Union(t.geom)))
FROM t;
Working inside-out:
- ST_Shift_Longitude maps coordinates to 0-360.
- ST_Split cuts along the antimeridian so you now have a
GEOMETRYCOLLECTION
of twoPOLYGON
s - ST_Dump(...).geom yields the polygons as rows
- ST_WrapX maps longitudes back to the range (-180, 180)
ST_Multi(ST_Union(t.geom))
takes the results from the CTE and emits a single MultiPolygon.
This does not address converting your table from geography to geometry. Maybe you could make a new table and update the CTE to insert while casting with geom::geography
and/or geog::geometry
?
Pete's answer was helpful, although I was getting an error like, aggregate function calls cannot contain set-returning function calls
. Nevertheless, I got it working using that strategy then took it a step further and turned it into a function for easy reuse. Hopefully someone finds this helpful:
-- Replace 'aaa' with whatever "namespace" you group your functions in.
CREATE OR REPLACE FUNCTION
public.aaa_split_linestring_at_meridian( _line_geom geometry )
RETURNS geometry
LANGUAGE plpgsql
AS $function$
declare
_split_line_geom geometry;
begin
WITH t AS (
SELECT
(
ST_WrapX(
(
ST_Dump(ST_Split(ST_ShiftLongitude( _line_geom ),
st_geomfromewkt('SRID=4326;LINESTRING(180 -90, 180 90)')
)
)
).geom, 180, -360)
) as geom
)
select ST_Multi(ST_Union(t.geom)) into _split_line_geom
FROM t;
return _split_line_geom;
end;
$function$;
Here's an example testing it with a LineString that needs to be split at the anti-meridian:
select aaa_split_linestring_at_meridian( st_geomfromewkt('SRID=4326;LINESTRING (-15.1095412837744 -14.43314252762616, -15.1095412837744 -14.43314252762616, -15.1095412837744 -14.43314252762616, -15.1095412837744 -14.43314252762616, -15.1095412837744 -14.43314252762616, -15.1095412837744 -14.43314252762616, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.1481711261727 -14.24454905181106, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.824122504930305 -10.91185130763078, -15.84941469542686 -10.786058859913009, -15.84941469542686 -10.786058859913009, -15.86205396048597 -10.723161355393653, -15.86205396048597 -10.723161355393653, -15.86205396048597 -10.723161355393653, -15.86205396048597 -10.723161355393653, -15.86205396048597 -10.723161355393653, -15.912580284871138 -10.471567922221649, -15.925202474457322 -10.408668710155002, -15.925202474457322 -10.408668710155002, -16.527541489435116 -7.388909743177195, -16.527541489435116 -7.388909743177195, -16.527541489435116 -7.388909743177195, -16.552505830851512 -7.2630635077197105, -16.552505830851512 -7.2630635077197105, -16.564984586465126 -7.200139536217321, -16.564984586465126 -7.200139536217321, -16.564984586465126 -7.200139536217321, -16.564984586465126 -7.200139536217321, -16.564984586465126 -7.200139536217321, -16.564984586465126 -7.200139536217321, -16.564984586465126 -7.200139536217321, -16.564984586465126 -7.200139536217321, -17.21124342535339 -3.9275337963548136, -17.21124342535339 -3.9275337963548136, -17.21124342535339 -3.9275337963548136, -17.22362997341321 -3.8645884805112685, -17.24839965443826 -3.738697848824178, -17.24839965443826 -3.738697848824178, -17.260784494950787 -3.675751679206987, -17.260784494950787 -3.675751679206987, -17.260784494950787 -3.675751679206987, -17.260784494950787 -3.675751679206987, -17.260784494950787 -3.675751679206987, -17.260784494950787 -3.675751679206987, -17.260784494950787 -3.675751679206987, -17.260784494950787 -3.675751679206987, -17.260784494950787 -3.675751679206987, -17.32268479185132 -3.3610165622527997, -17.878942228046327 -0.5280316794499308, -17.878942228046327 -0.5280316794499308, -17.903645314726973 -0.4021070568995493, -17.903645314726973 -0.4021070568995493, -17.903645314726973 -0.4021070568995493, -17.915996004293646 -0.3391442920571091, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.94069909097429 -0.2132175884334649, -17.95305148808826 -0.1502540098380181, -18.002455953902253 0.1016029592462007, -18.002455953902253 0.1016029592462007, -18.002455953902253 0.1016029592462007, -18.595762043702702 3.124193626604359, -18.595762043702702 3.124193626604359, -18.595762043702702 3.124193626604359, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.632897782220063 3.3131222085756122, -18.645279207638 3.376098900600657, -18.69481515459352 3.6280073762481284, -18.69481515459352 3.6280073762481284, -18.69481515459352 3.6280073762481284, -18.69481515459352 3.6280073762481284, -18.70720170265334 3.690984708603408, -18.70720170265334 3.690984708603408, -18.70720170265334 3.690984708603408, -19.291082131399172 6.651111001485125, -19.291082131399172 6.651111001485125, -19.291082131399172 6.651111001485125, -19.30355064172903 6.714095590916398, -19.30355064172903 6.714095590916398, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.32849107748333 6.840065196665766, -19.34096471045507 6.903050212983862, -19.390883148004104 7.154991558916715, -19.390883148004104 7.154991558916715, -19.390883148004104 7.154991558916715, -19.390883148004104 7.154991558916715, -19.40336873380689 7.21797657523481, -19.99319654977251 10.178379490777912, -20.00581873935869 10.24136749530377, -20.00581873935869 10.24136749530377, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.031075071362107 10.367344358129133, -20.043707506232046 10.430333216428636, -20.043707506232046 10.430333216428636, -20.09427139665765 10.682286942079358, -20.09427139665765 10.682286942079358, -20.09427139665765 10.682286942079358, -20.09427139665765 10.682286942079358, -20.09427139665765 10.682286942079358, -20.09427139665765 10.682286942079358, -20.106922614547805 10.745275800378863, -20.70590629909583 13.7057162819624, -20.70590629909583 13.7057162819624, -20.718753884924624 13.768702578940966, -20.718753884924624 13.768702578940966, -20.718753884924624 13.768702578940966, -20.718753884924624 13.768702578940966, -20.718753884924624 13.768702578940966, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.744464424507843 13.894676880445388, -20.75732567071498 13.957663177423953, -20.75732567071498 13.957663177423953, -20.808821881962288 14.20960921911186, -20.808821881962288 14.20960921911186, -21.433347058911576 17.23281316275229, -21.433347058911576 17.23281316275229, -21.446498588158434 17.295792629541687, -21.446498588158434 17.295792629541687, -21.446498588158434 17.295792629541687, -21.47281872212508 17.421751563120477, -21.47281872212508 17.421751563120477, -21.47281872212508 17.421751563120477, -21.47281872212508 17.421751563120477, -21.47281872212508 17.421751563120477, -21.47281872212508 17.421751563120477, -21.47281872212508 17.421751563120477, -21.47281872212508 17.421751563120477, -21.47281872212508 17.421751563120477, -21.485989034392155 17.48473102990987, -21.538731755162996 17.736645481972868, -21.551932803281336 17.79962324121497, -21.551932803281336 17.79962324121497, -21.551932803281336 17.79962324121497, -22.09905315391416 20.381526955033586, -22.112547900166813 20.44449446899193, -22.18014628238243 20.759328623689086, -22.18014628238243 20.759328623689086, -22.19368883995927 20.82229613764743, -22.19368883995927 20.82229613764743, -22.19368883995927 20.82229613764743, -22.19368883995927 20.82229613764743, -22.220797860775054 20.94822604292225, -22.220797860775054 20.94822604292225, -22.220797860775054 20.94822604292225, -22.220797860775054 20.94822604292225, -22.220797860775054 20.94822604292225, -22.220797860775054 20.94822604292225, -22.220797860775054 20.94822604292225, -22.234364324013992 21.011191849333304, -22.28871043169249 21.263048244788354, -22.28871043169249 21.263048244788354, -22.28871043169249 21.263048244788354, -22.867586039323996 23.90719888760788, -22.951600781209738 24.28487761285832, -22.951600781209738 24.28487761285832, -22.965636819954113 24.347821221154575, -22.965636819954113 24.347821221154575, -22.965636819954113 24.347821221154575, -22.965636819954113 24.347821221154575, -22.99373792574684 24.473710145294373, -22.99373792574684 24.473710145294373, -22.99373792574684 24.473710145294373, -22.99373792574684 24.473710145294373, -22.99373792574684 24.473710145294373, -22.99373792574684 24.473710145294373, -22.99373792574684 24.473710145294373, -22.99373792574684 24.473710145294373, -23.00780470034248 24.536653753590624, -23.064169128920717 24.788423064133756, -23.064169128920717 24.788423064133756, -23.064169128920717 24.788423064133756, -23.753915782254456 27.809007630227487, -23.753915782254456 27.809007630227487, -23.76856653802413 27.87192221021977, -23.76856653802413 27.87192221021977, -23.76856653802413 27.87192221021977, -23.76856653802413 27.87192221021977, -23.79790390805663 27.997749662657036, -23.81259222986674 28.060662535102022, -23.81259222986674 28.060662535102022, -23.81259222986674 28.060662535102022, -23.81259222986674 28.060662535102022, -23.81259222986674 28.060662535102022, -23.81259222986674 28.060662535102022, -23.81259222986674 28.060662535102022, -23.81259222986674 28.060662535102022, -23.87146675296496 28.312308902240094, -23.87146675296496 28.312308902240094, -23.886216546477602 28.375218359590498, -23.886216546477602 28.375218359590498, -24.502364496409868 30.95392212978296, -24.533023508046764 31.07968298787582, -24.609929730553812 31.39406293499317, -24.609929730553812 31.39406293499317, -24.609929730553812 31.39406293499317, -24.609929730553812 31.39406293499317, -24.609929730553812 31.39406293499317, -24.609929730553812 31.39406293499317, -24.656253781052133 31.582682024017654, -24.656253781052133 31.582682024017654, -24.656253781052133 31.582682024017654, -24.656253781052133 31.582682024017654, -24.656253781052133 31.582682024017654, -24.656253781052133 31.582682024017654, -24.656253781052133 31.582682024017654, -24.656253781052133 31.582682024017654, -24.733766182848022 31.897031235283738, -24.733766182848022 31.897031235283738, -24.733766182848022 31.897031235283738, -25.384751512641937 34.473829382697765, -25.41725126026015 34.59948437285849, -25.433529308599585 34.66230845284427, -25.433529308599585 34.66230845284427, -25.49882420951761 34.91360477278738, -25.49882420951761 34.91360477278738, -25.49882420951761 34.91360477278738, -25.49882420951761 34.91360477278738, -25.54799303380524 35.10206335236637, -25.54799303380524 35.10206335236637, -25.54799303380524 35.10206335236637, -25.54799303380524 35.10206335236637, -25.54799303380524 35.10206335236637, -25.54799303380524 35.10206335236637, -25.630317303871404 35.41613935606565, -25.630317303871404 35.41613935606565, -25.630317303871404 35.41613935606565, -25.630317303871404 35.41613935606565, -26.394103207808083 38.241488087376446, -26.44658808893775 38.429752006564094, -26.44658808893775 38.429752006564094, -26.44658808893775 38.429752006564094, -26.44658808893775 38.429752006564094, -26.44658808893775 38.429752006564094, -26.44658808893775 38.429752006564094, -26.44658808893775 38.429752006564094, -26.481695261271618 38.55525331746849, -26.499284705931693 38.6180022653734, -26.499284705931693 38.6180022653734, -26.499284705931693 38.6180022653734, -26.499284705931693 38.6180022653734, -26.587581976427032 38.93172651433043, -26.587581976427032 38.93172651433043, -27.335398898084218 41.50282486888208, -27.37303324041099 41.628172500530155, -27.41078369595365 41.75351671708364, -27.467622822679203 41.94151425889366, -27.467622822679203 41.94151425889366, -27.467622822679203 41.94151425889366, -27.467622822679203 41.94151425889366, -27.467622822679203 41.94151425889366, -27.467622822679203 41.94151425889366, -27.50566356126159 42.06683798487964, -27.50566356126159 42.06683798487964, -27.524726619235096 42.12949814032533, -27.524726619235096 42.12949814032533, -27.524726619235096 42.12949814032533, -27.524726619235096 42.12949814032533, -27.56294323518861 42.25481162102756, -27.56294323518861 42.25481162102756, -27.62049099404055 42.442768181702554, -27.62049099404055 42.442768181702554, -27.62049099404055 42.442768181702554, -27.62049099404055 42.442768181702554, -27.62049099404055 42.442768181702554, -28.435680901670743 45.009713781238844, -28.476906215953647 45.13483943173889, -28.518276671756414 45.25995483695518, -28.58060727057466 45.44761428440128, -28.58060727057466 45.44761428440128, -28.58060727057466 45.44761428440128, -28.58060727057466 45.44761428440128, -28.58060727057466 45.44761428440128, -28.58060727057466 45.44761428440128, -28.64326913356765 45.63524982618529, -28.64326913356765 45.63524982618529, -28.64326913356765 45.63524982618529, -28.64326913356765 45.63524982618529, -28.64326913356765 45.63524982618529, -28.64326913356765 45.63524982618529, -28.685230400733623 45.760327665361146, -28.685230400733623 45.760327665361146, -28.74845746188043 45.94792905619931, -28.74845746188043 45.94792905619931, -28.74845746188043 45.94792905619931, -28.74845746188043 45.94792905619931, -29.81029233062895 48.94636161126739, -29.81029233062895 48.94636161126739, -29.81029233062895 48.94636161126739, -29.81029233062895 48.94636161126739, -29.81029233062895 48.94636161126739, -29.81029233062895 48.94636161126739, -29.880062713000633 49.13354636056618, -29.880062713000633 49.13354636056618, -29.880062713000633 49.13354636056618, -29.880062713000633 49.13354636056618, -29.880062713000633 49.13354636056618, -29.880062713000633 49.13354636056618, -29.92681535786937 49.25832025632397, -29.92681535786937 49.25832025632397, -29.99730974029307 49.445460609393145, -29.99730974029307 49.445460609393145, -29.99730974029307 49.445460609393145, -29.99730974029307 49.445460609393145, -31.00812651103618 51.99996843445084, -31.05986519399903 52.12442131131765, -31.19028424110584 52.43548520159295, -31.19028424110584 52.43548520159295, -31.19028424110584 52.43548520159295, -31.19028424110584 52.43548520159295, -31.19028424110584 52.43548520159295, -31.269282209046207 52.62207572443394, -31.269282209046207 52.62207572443394, -31.269282209046207 52.62207572443394, -31.269282209046207 52.62207572443394, -31.269282209046207 52.62207572443394, -31.322263986437996 52.74644663903071, -31.402214765767578 52.932975690169165, -31.402214765767578 52.932975690169165, -31.402214765767578 52.932975690169165, -31.402214765767578 52.932975690169165, -31.402214765767578 52.932975690169165, -32.55743198084851 55.47810908059102, -32.61701513607312 55.60204969327007, -32.76739882612388 55.91181243250849, -32.76739882612388 55.91181243250849, -32.76739882612388 55.91181243250849, -32.76739882612388 55.91181243250849, -32.858629662867735 56.097603823216595, -32.858629662867735 56.097603823216595, -32.858629662867735 56.097603823216595, -32.858629662867735 56.097603823216595, -32.858629662867735 56.097603823216595, -32.858629662867735 56.097603823216595, -32.858629662867735 56.097603823216595, -33.01238063617931 56.4071411662124, -34.502055139442845 59.186020705505015, -34.537544802370235 59.24761535144019, -34.537544802370235 59.24761535144019, -34.60886222258892 59.37078415274303, -34.60886222258892 59.37078415274303, -34.60886222258892 59.37078415274303, -34.64469339497481 59.43235147792152, -34.71670407939425 59.55547929808934, -34.71670407939425 59.55547929808934, -34.71670407939425 59.55547929808934, -34.71670407939425 59.55547929808934, -34.75288359142781 59.617026132700325, -36.556763871984856 62.439000750561135, -36.59933302598696 62.500124113443576, -36.6849426170439 62.622336688262614, -36.81456253201782 62.80558383350489, -36.81456253201782 62.80558383350489, -36.81456253201782 62.80558383350489, -36.81456253201782 62.80558383350489, -36.85809474269289 62.86663889449563, -36.85809474269289 62.86663889449563, -36.945647522568706 62.988728525909615, -36.945647522568706 62.988728525909615, -36.945647522568706 62.988728525909615, -36.945647522568706 62.988728525909615, -37.16746474605404 63.2937374534857, -37.16746474605404 63.2937374534857, -38.95281472339284 65.54115655836503, -39.215759930965405 65.84339925932727, -39.26903199139692 65.9037986221577, -39.37627620664988 66.02455636668351, -39.53891325607163 66.2055700400672, -39.53891325607163 66.2055700400672, -39.53891325607163 66.2055700400672, -39.53891325607163 66.2055700400672, -39.59360258075593 66.26587378024924, -39.703715475460285 66.38643344928913, -43.1033806631316 69.61235228485367, -43.1033806631316 69.61235228485367, -78.11864255643087 80.93756407973268, -78.79360185021153 81.01011434909655, -101.47321083829301 82.4217983373223, -101.94985558952236 82.43498743260959, -128.82851461516594 82.34181682214145, -129.29356853537377 82.32542436813343, -135.57797094918914 82.04622672543081, -151.08370247841202 80.77399470948922, -151.72500259996286 80.6977629681627, -165.5835793693238 78.3023063432125, -165.98762603986506 78.20381501538093, 171.08072051902514 65.406369605284, 170.825968123362 65.10388101751165, 170.825968123362 65.10388101751165, 168.29413994144335 61.694578432921446, 168.29413994144335 61.694578432921446, 168.25359593853014 61.63339359833647, 168.25359593853014 61.63339359833647, 168.25359593853014 61.63339359833647, 166.22220205671996 58.25499761974057, 166.22220205671996 58.25499761974057, 166.1884882429768 58.19336882285955, 166.1884882429768 58.19336882285955, 166.1884882429768 58.19336882285955, 166.1213611438139 58.07007707815165, 166.1213611438139 58.07007707815165, 166.1213611438139 58.07007707815165, 164.476979440755 54.79426371070017, 164.476979440755 54.79426371070017, 164.476979440755 54.79426371070017, 164.4482106839709 54.73231047983357, 164.4482106839709 54.73231047983357, 164.36231422496883 54.54643029666626, 164.36231422496883 54.54643029666626, 164.36231422496883 54.54643029666626, 164.36231422496883 54.54643029666626, 164.36231422496883 54.54643029666626, 164.36231422496883 54.54643029666626, 164.22065610158276 54.23653095364444, 162.94604717981 51.25611302251226, 162.94604717981 51.25611302251226, 162.94604717981 51.25611302251226, 162.94604717981 51.25611302251226, 162.94604717981 51.25611302251226, 162.94604717981 51.25611302251226, 162.87105170272326 51.06954640533336, 162.87105170272326 51.06954640533336, 162.87105170272326 51.06954640533336, 162.87105170272326 51.06954640533336, 162.87105170272326 51.06954640533336, 162.74719305231426 50.75852691128767, 161.69001637257966 47.955813426886294, 161.69001637257966 47.955813426886294, 161.62293025455182 47.76875503608715, 161.62293025455182 47.76875503608715, 161.62293025455182 47.76875503608715, 161.62293025455182 47.76875503608715, 161.62293025455182 47.76875503608715, 161.62293025455182 47.76875503608715, 161.60065017747922 47.70639882405952, 161.5562402874958 47.581676154720505, 161.5562402874958 47.581676154720505, 161.5562402874958 47.581676154720505, 161.5562402874958 47.581676154720505, 161.5562402874958 47.581676154720505, 161.5562402874958 47.581676154720505, 160.4978205133323 44.460481194605194, 160.4978205133323 44.460481194605194, 160.43725039577262 44.27303348302336, 160.43725039577262 44.27303348302336, 160.43725039577262 44.27303348302336, 160.43725039577262 44.27303348302336, 160.43725039577262 44.27303348302336, 160.41712865847776 44.2105474974015, 160.37699446691477 44.085568695968604, 160.37699446691477 44.085568695968604, 160.37699446691477 44.085568695968604, 160.37699446691477 44.085568695968604, 160.37699446691477 44.085568695968604, 160.2971085743823 43.83558718744072, 160.2971085743823 43.83558718744072, 159.41433394491483 40.95871150903135, 159.41433394491483 40.95871150903135, 159.41433394491483 40.95871150903135, 159.358900129611 40.77096668422063, 159.358900129611 40.77096668422063, 159.358900129611 40.77096668422063, 159.3404722792303 40.7083816608558, 159.3404722792303 40.7083816608558, 159.3404722792303 40.7083816608558, 159.30369854073896 40.58320819903156, 159.30369854073896 40.58320819903156, 159.30369854073896 40.58320819903156, 159.2853526526283 40.52061976057215, 159.2304652524581 40.33284078481557, 159.2304652524581 40.33284078481557, 158.4168257977695 37.452030917444276, 158.4168257977695 37.452030917444276, 158.4168257977695 37.452030917444276, 158.36546277521097 37.26406069639094, 158.36546277521097 37.26406069639094, 158.36546277521097 37.26406069639094, 158.3483736419076 37.201400540945244, 158.3483736419076 37.201400540945244, 158.29727016653757 37.013413244418985, 158.29727016653757 37.013413244418985, 158.29727016653757 37.013413244418985, 158.29727016653757 37.013413244418985, 158.2463579364643 36.825415702608964, 158.22941906732268 36.7627487169741, 158.22941906732268 36.7627487169741, 158.22941906732268 36.7627487169741, 158.22941906732268 36.7627487169741, 158.22941906732268 36.7627487169741, 158.22941906732268 36.7627487169741, 157.4719647487466 33.878885755043804, 157.4719647487466 33.878885755043804, 157.4719647487466 33.878885755043804, 157.42392119812473 33.69073453397747, 157.42392119812473 33.69073453397747, 157.42392119812473 33.69073453397747, 157.42392119812473 33.69073453397747, 157.42392119812473 33.69073453397747, 157.37604157204294 33.50257989781654, 157.37604157204294 33.50257989781654, 157.37604157204294 33.50257989781654, 157.37604157204294 33.50257989781654, 157.3124388504918 33.25168997412904, 157.3124388504918 33.25168997412904, 156.59933978038578 30.36555938939431, 156.59933978038578 30.36555938939431, 156.59933978038578 30.36555938939431, 156.5539326827835 30.177278394733737, 156.5539326827835 30.177278394733737, 156.5539326827835 30.177278394733737, 156.5539326827835 30.177278394733737, 156.50866218896468 29.98899398497858, 156.50866218896468 29.98899398497858, 156.50866218896468 29.98899398497858, 156.50866218896468 29.98899398497858, 156.44847456199852 29.73793672165642, 156.44847456199852 29.73793672165642, 156.3436857997522 29.298560897633255, 155.77126130579177 26.850103712271057, 155.77126130579177 26.850103712271057, 155.77126130579177 26.850103712271057, 155.72798522721055 26.661728802509398, 155.72798522721055 26.661728802509398, 155.7135871884402 26.598935458374886, 155.7135871884402 26.598935458374886, 155.68480477127775 26.47334706255857, 155.68480477127775 26.47334706255857, 155.68480477127775 26.47334706255857, 155.67044771364237 26.410553718424058, 155.61307412461426 26.159370096602252, 154.97919158850206 23.333099289753505, 154.97919158850206 23.333099289753505, 154.93763671759172 23.144654370552857, 154.93763671759172 23.144654370552857, 154.92379875433326 23.08183882830354, 154.92379875433326 23.08183882830354, 154.8961638089514 22.95620603625762, 154.88235316644963 22.893390494008305, 154.88235316644963 22.893390494008305, 154.88235316644963 22.893390494008305, 154.20270836289833 19.752189909814025, 154.20270836289833 19.752189909814025, 154.16254685057865 19.563697179289182, 154.16254685057865 19.563697179289182, 154.1224536401507 19.37520444876434, 154.1224536401507 19.37520444876434, 151.28470128530714 5.42495458791079, 150.59198349968446 1.9065726016150124, 150.59198349968446 1.9065726016150124, 150.59198349968446 1.9065726016150124)') );
Using DBeaver's built-in Spatial view, here's the before..
And the after..