I'm trying to transform this shapefile from EPSG:3338 (Alaska Albers) to EPSG:4326.

When I display the file in EPSG:3338 in QGIS it looks as you'd expect:

enter image description here

But when I display it in EPSG:4326 I see all kinds of problems:

enter image description here

And when I export it as EPSG:4326 I see the same problem. This happens both whether I export it in QGIS, or use ogr2ogr:

ogr2ogr -f GeoJSON -s_srs EPSG:3338 -t_srs EPSG:4326 .   
  mv_oil_and_gas_basin_py.geojson mv_oil_and_gas_basin_py.shp

How can I transform this file to EPSG:4326 without getting problems around the international dateline?


You can use -wrapdateline in ogr2ogr to split the polygons at the anti meridian (as the dateline in fact misses Alaska).

ogr2ogr -s_srs EPSG:3338 -t_srs epsg:4326 -wrapdateline output.shp mv_oil_and_gas_basin_py.shp 

Once I fixed the 4 invalid polygons I get this: enter image description here

  • Unfortunately that hasn't solved the problem - still looks the same in QGIS. (I tried: ogr2ogr -s_srs EPSG:3338 -t_srs EPSG:4326 -wrapdateline output_file.shp mv_oil_and_gas_basin_py.shp. Trying without the t_srs option produced a warning.) – Richard May 22 '17 at 11:08
  • It would work if all the polygons were valid. – Ian Turton May 22 '17 at 12:23
  • It doesn't, sorry - I just tried importing the shapefile to PostGIS and running ST_MakeValid on all the polygons, and I get the same result. – Richard May 22 '17 at 12:58
  • Thanks! What worked for me in the end was to import it to PostGIS without reprojecting, then run ST_MakeValid, then export it using ogr2ogr to reproject to 4326 on the fly, with the -wrapdateline option. – Richard May 22 '17 at 14:34
  • I guess that wrapdateline produces the invalid geometries during cutting, while my workaround from the linked question does not. – AndreJ May 23 '17 at 5:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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