Saturday, 11 May 2019

qgis - Fixing artifacts in rendered ocean polygons


I am trying to build a base map for North America with political boundaries, lakes&rivers, ecoregions, and oceans in QGIS. I can retrieve shapefiles from opensource websites that provide the data that I want but they are in different projections and aren't displayed correctly (below is the image of the map when the files are imported directly as is to the map).



The North American data are in US National equal area (ESPG 2163) and the ocean shapefile is in WSG 84. The current map projection is ESPG 2163 (which is better than WSG 84 at my map extent).


enter image description here


Attempts: I tried to reproject the ocean shapefile with "Save as... " and setting CRS to ESPG 2163 to the ocean shapefile but it still displays the oceans backwards in parts of the map at different scales (the polygon covers the landmass instead of the ocean).


Is there a reprojection that I can use to make the ocean shapefile "fit" properly? Or is it a problem with the ocean shapefile itself that can't handle other projections in which case any suggestions for open ocean shapefiles?


Details on files:


Ocean shapefile: WSG 84 (+proj=longlat +datum=WGS84 +no_defs) http://www.naturalearthdata.com/downloads/10m-physical-vectors/10m-ocean/ (note: the ne_10m_lakes file from the same source does not have a wonky projection in the map)


North America Spatial data (shapefiles with political boundaries, lakes&rivers, ecoregions): ESPG 2163 (+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs) https://www.sciencebase.gov/catalog/item/4fb545b6e4b04cb937751d3d



Answer



I think iant touched on the problem... artifacts like this are often down to features crossing the "dateline" (or more correctly, the antimeridian, 180W/E). I find this is the case in some (but not all) of the Natural Earth shapefiles, for instance. When a line crosses this meridian, the end result is usually a line that cuts across the map.


I'd suggest using ogr2ogr with the -wrapdateline option to create new shapefiles clipped to the bounding box of WGS84. Then try projecting (or using OTF projection) to your new projection, and see if that improves things.



ogr2ogr is a command line tool. As far as i know it's installed alongside QGIS. You should be able to run it from a terminal window (linux/mac) or osgeo4w shell (windows). The manual page includes an example (near the bottom)


something like this should work. Confusingly, you put the output filename first. Gets me every time ;-)


ogr2ogr -wrapdateline -t_srs EPSG:4326 output.shp input.shp

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...