[postgis-users] Lines crossing longitude 180 -180

mark wynter mark at dimensionaledge.com
Tue Sep 24 19:32:14 PDT 2019


Simple example..

DROP TABLE
engine2=# create table test (id INTEGER, split_line
geometry(linestring,4326));
CREATE TABLE
engine2=# insert into test SELECT 1,
ST_SetSRID(ST_MakeLine(ST_MakePoint(0,0),ST_MakePoint(0,-180)),4326);
INSERT 0 1
engine2=# insert into test SELECT 1,
ST_SetSRID(ST_MakeLine(ST_MakePoint(0,0),ST_MakePoint(0,180)),4326);
INSERT 0 1
engine2=# SELECT id, ST_AsTEXT(ST_Multi(ST_Union(split_line))) FROM test
GROUP BY 1;
 id |                 st_astext
----+-------------------------------------------
  1 | MULTILINESTRING((0 0,0 -180),(0 0,0 180))
(1 row)


On Wed, Sep 25, 2019 at 11:43 AM mark wynter <mark at dimensionaledge.com>
wrote:

> Hi Paul, in the past I've solved this type of problem using some plpgsql.
> Create two polygon geometries covering longitudes 0 to180, and 0 to -180.
> For polygon_geom, use ST_Intersection(polygon_geom, line_string_geom) to
> split and keep the linestring contained by each polygon.  Then stitch the
> two linestring geoms back to form a single multi-linestring feature using...
> ST_Multi(ST_Union(wkb_geometry)
>
> I've done something similar here...
>
> http://dimensionaledge.com/bezier-curves-a-more-flexible-alternative-to-great-circles/
>
> The related github code is here
>
> https://github.com/dimensionaledge/cf_public/blob/master/tutorials/bezier_curve_flight_paths.sh
>
>
> HTH
> Mark
>
>
>
>> Message: 1
>> Date: Tue, 24 Sep 2019 07:18:22 +0000
>> From: <paul.malm at lfv.se>
>> To: <postgis-users at lists.osgeo.org>
>> Subject: [postgis-users] Lines crossing longitude 180 -180
>> Message-ID: <785199B14156764C8EB14EF96CEDC44EE3FAB7 at xw-exch03.lfv.se>
>> Content-Type: text/plain; charset="utf-8"
>>
>> Hi,
>> I'm creating a table with LineStrings in SRID 4326 from lines with
>> coordinates like this:
>> S37323578E178560795
>> S38161687W179595994
>> S38270000W179440000
>> S38414463E179595994
>> S39394800E178553000
>> S40224800E178060600
>> S41504422E176164722
>> S42513000E175030000
>> S43372622E174062536
>> S45135100E172134000
>> S48090000E168160000
>> S45550000E165180000
>> S42254200E169201800
>> S41580000E169501800
>> S41253091E170232389
>> As you can see the crosses 180/-180 longitude several times which results
>> in long line segments all over the map from east to west.
>> Is there anyone who have solved this problem in a fairly easy way?
>> I appreciate all help I can get.
>>
>> Kind regards,
>> Paul Malm
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20190925/ff7179bc/attachment.html>


More information about the postgis-users mailing list