# How to build a minimum convex hull crossing the 180 degrees line?

I've been building convex hulls for species that inhabit the Indo-Pacific (~ from 20 to -65 degrees of longitude). The problem I've encountered is that for the species that can be found on both sides of the 180 degrees longitude line the reconstructed hull expands across the whole layer rather than including the points in a much smaller polygon comprising both ends of the layer. The cause for this behaviour is that this line represents the edge of the layer, and QGIS doesn't wrap vector maps (see image below...my 'reputation' is now 'good enough to include it, thank you).

After some thinking and googling these are some of the possible approaches to the problem I have come across; however, I'm not too sure of their merit or implementation:

1. Change the central meridian from the 0 (i.e. Greenwich) to let’s say 150 degrees. How can this be done? Would this merely change the map display (useful per se), or would it also contribute to the construction of the correct convex hull?

2. Change the coordinate system from a +/- 180 degrees format to a 0 to 360 degrees format. Apparently, something along these lines can be achieved using the 'ST_Shift_Longitude' function in PostGIS, which adds 360 degrees to the negative longitudes. Is there a simpler way to do this? Also this function produces a 180 degrees centric map, which wouldn't be the end of the world but a 150 degrees centric map would be better (~ the centre of the Indo-Pacific).

Thank for your time and help, and sorry for the lengthy post.

• Convex hulls only make sense when a projected coordinate system is used – user681 Nov 22 '12 at 23:03
• Although you are correct in general, @Dan, there are many cases where the convex hull does make sense--and this is likely one of them. We can define the convex hull of any set of points on the sphere by constructing their cone (which is the union of rays originating at the earth's center and passing through the points) and intersecting the convex hull of those rays (considered as a subset of space) with the sphere. – whuber Nov 24 '12 at 23:55
• A related question at gis.stackexchange.com/questions/17788 asks to compute bounding boxes of points that might cross the +-180 degree meridian. In the present case, though, either a solution in projected coordinates (as suggested by @Dan Patterson) or the 3D solution look like the best bets. Beware, though: most GISes still have problems coping with data that span this meridian. Conduct tests with simple datasets before committing to any solution. – whuber Nov 25 '12 at 0:06

You may use GRASS GIS (in QGIS available via GRASS toolbox or better, Sextante plugin) which is able to handle the global wrap-around at the date line.

Here an example with random points in that zone with convex hull polygon generated with v.hull:

If you want to move the central meridian of the world map from Greenwich to something other, you get the same misplacements you encountered, but with the Map background, if it is built up by vector polygons.

See this Q&A for a workaround on it:

Reprojecting Natural Earth dataset to World Eckert I

Although written for Eckert projection, it should work for all worldwide views centered on meridians different from Greenwich.

Using a raster background like Blue Marble would avoid this problem.