[postgis-users] Lines crossing longitude 180 -180

Neil Freeman neil at firststreet.org
Tue Sep 24 12:36:32 PDT 2019


Paul-

You can use a Geography type to automatically handle dateline crossing. This is a good resource on the differences between Geography and Geometry types: https://postgis.net/workshops/postgis-intro/geography.html <https://postgis.net/workshops/postgis-intro/geography.html>

Generating a line from your sample data would look something like this (decimals clipped for readability):

SELECT ST_Geographyfromtext('LINESTRING(178.9 -37.5,-179.9 -38.4,-179.7 -38.4)');

Converting the data from minutes and seconds to decimals could be done in SQL or elsewhere.

While PostGIS will correctly handle calculations with the geography, desktop GIS programs might have display glitches depending on the map projection. In QGIS I was able to correctly view your sample line when using a southern polar projection, but not when using a standard mercator projection.

-Neil

> From: <paul.malm at lfv.se <mailto:paul.malm at lfv.se>>
> Subject: [postgis-users] Lines crossing longitude 180 -180
> Date: September 24, 2019 at 3:18:22 AM EDT
> To: <postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org>>
> 
> 
> 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/20190924/73dd07f1/attachment.html>


More information about the postgis-users mailing list