[postgis-users] Lines crossing longitude 180 -180

Brent Wood pcreso at yahoo.com
Fri Sep 27 20:18:25 PDT 2019


 Yep, 

Either use a Geography datatype as Neil describes here, or create the line with longitudes in the 0-360 space instead of +-180... so 170W = 190 instead of -170.
You can use the ST_ShiftLongitude() function to switch between 0-360 & +-180 longitude spaces (EPSG supports both for 4326), but proj only supports +-180 for reprojection.

Brent Wood

    On Wednesday, September 25, 2019, 7:36:46 AM GMT+12, Neil Freeman <neil at firststreet.org> wrote:  
 
 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
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>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>


Hi,I’m creating a table with LineStrings in SRID 4326 from lines with coordinates like this:S37323578E178560795S38161687W179595994S38270000W179440000S38414463E179595994S39394800E178553000S40224800E178060600S41504422E176164722S42513000E175030000S43372622E174062536S45135100E172134000S48090000E168160000S45550000E165180000S42254200E169201800S41580000E169501800S41253091E170232389As 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 

_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/postgis-users  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20190928/4a937ba1/attachment.html>


More information about the postgis-users mailing list