27

I wish to display a map in QGIS (world country shapefiles) showing all countries but centered on the Pacific area.

I am not familiar with Proj4, so is there any way this can be done in QGIS?

1
  • After many troubles, I found out it is better to use Nr;WKT 1;POLYGON ((30.01 90, 29.99 90, 29.99 -90, 30.01 -90, 30.01 90)) Diederik
    – user26658
    Commented Feb 6, 2014 at 19:10

3 Answers 3

32

Well, not that easy, as QGIS does not come with predefined Robinson or Miller projections.

So I tried a Custom CRS and got this picture (not in first run!):

enter image description here

For a central meridian at 150° West, it is necessary to split the world boundaries shapefile at 30° East (to be precise, at 29.9 and 30.1 to avoid intersections)

So these are the steps:

  1. Download Natural Earth world boundaries shapefile and load it into QGIS
  2. Save As ... into WGS84, and add that to the canvas
  3. Delete the layer from step 1
  4. Disable On-the-fly-projection
  5. Create the following text file:
Nr;WKT
1;POLYGON((30.1 89, 29.9 89, 29.9 -89, 30.1 -89, 30.1 89))
  1. Add that file as Text delimited layer, using semicolon as separator and WGS84 as CRS (you will get a very thin polygon around 30°E)
  2. Save the layer as shapefile, add it to the canvas and delete the layer from step 6
  3. Use Vector -> Geoprocessing -> Difference with the two polygon layers
  4. Create a Custom CRS named Robinson with this proj string:

+proj=robin +lon_0=-150 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs

  1. Enable On-the-fly projection and choose Robinson as project CRS

For the Miller projection, you can use the same pre-cut shapefile. In Proj, Miller has some problems with the ellipsoid, so we take a sphere instead (you won't see a difference):

+proj=mill +lon_0=-150 +lat_0=0 +R=6371000 +units=m +no_defs

With on-the fly activated, it does not look as well, New Zealand is missing at full extent, but returns when zooming in. So we need to Save As ... the shapefile in miller projection, and show only that, without on-the-fly reprojection:

enter image description here

2
  • 4
    Is this something that QGIS should handle? I mean, it's not like the 180th meridian is anything physical... Is there a bug/feature request for it?
    – naught101
    Commented Jan 6, 2015 at 6:44
  • 3
    Because it took me an embarrassingly long time to find it, one can add a custom CRS under Settings > Custom CRS... Commented Dec 9, 2015 at 0:14
3

QGIS comes ready supplied with everything you need (i.e. it handles Proj4 for you under the hood). If your data are already in the projection you want, then right-click the layer and choose "Set Project CRS from Layer". This will put the data view into the same projection as your data. You will probably have to also right-click your layer and choose "Zoom to Layer Extent".

If your data are in some other projection, you can either reproject on the fly (in project properties) or reproject the data itself by right-clicking your layer and choosing "Save as". When the save dialog box opens, select the CRS for the output dataset and then use the new reprojected dataset.

0

In transformations of cylindrical data sources crossing 180 meridian, I would recommend using the virtual composite. It achieves the goal with a single ogr2ogr command processing a split source file. This method is very efficient and allows precise calibration of shape segmentation parameters to avoid intersection errors. Of course, a VRT file can be loaded in pipeline mode.

world.vrt:


<OGRVRTDataSource>
  <OGRVRTUnionLayer name="source">
    <OGRVRTLayer name="world-a">
      <SrcDataSource>/vsizip/world.zip</SrcDataSource>
      <SrcSQL dialect="sqlite">SELECT ST_Segmentize(ST_Intersection(geometry, BuildMBR(-179.99,-90,29.99,90)),.1) AS geometry FROM "world"</SrcSQL>
    </OGRVRTLayer>
    <OGRVRTLayer name="world-b">
      <SrcDataSource>/vsizip/world.zip</SrcDataSource>
      <SrcSQL dialect="sqlite">SELECT ST_Segmentize(ST_Intersection(geometry, BuildMBR(30.01,-90,179.99,90)),.1) AS geometry FROM "world"</SrcSQL>
    </OGRVRTLayer>
  </OGRVRTUnionLayer>
</OGRVRTDataSource>

ogr2ogr -a_srs EPSG:4326 -s_srs "+proj=latlong +pm=150" -t_srs "+proj=robin" -dialect SQLITE -sql "SELECT ST_Union(geometry) FROM source" world.shp world.vrt

or

type world.vrt | ogr2ogr -a_srs EPSG:4326 -s_srs "+proj=latlong +pm=150" -t_srs "+proj=robin" -dialect SQLITE -sql "SELECT ST_Union(geometry) FROM source" world.shp /vsistdin/

An example of a multi-layer vector composite created using the above-mentioned method

An example of a multi-layer vector composite created using the above-mentioned method with the central meridian 100W.

2
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented May 2, 2023 at 17:56
  • Thanks for pointing out the rules. Commented May 3, 2023 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.