Reprojecting raster from 0 360 to -180 180 with cutting 180 meridian using gdalwarp

You could explicitly set the output coordinate range using the target extent option to gdalwarp (ie. "-te -180 -90 180 90") but you can also use the CENTER_LONG configuration option to force rewrapping around a new central longitude. Something like this:

  gdalwarp -s_srs "+proj=longlat +ellps=WGS84" -t_srs WGS84 ~/0_360.tif 180.tif  -wo SOURCE_EXTRA=1000 \
           --config CENTER_LONG 0

Note also the "SOURCE_EXTRA=1000" warp option. When doing rewrapping the source rectangle computation will get confused around the longitude interruption and lose some imagery. This option says pull in some extra. Without it you will see a data gap near the prime meridian.

I think that setting a prime meridian of 180dW as you did is not a good idea.


Basically you need to cut the raster into two parts and piece them back together with a new offset/scale.

There's an example here of how to do that from [-180,180] to [0,360] with gdal_translate and the VRT driver: http://trac.osgeo.org/gdal/wiki/UserDocs/RasterProcTutorial

Scan down to the "5 min tutorial" and the details are under "Virtual Files". It should be simple enough to modify the example to suit.


This can be done in R with one line of code using the rotate function with the raster package.

load the raster package first.

library(raster)
your_raster <- raster("path/to/raster.tif")
rotated_raster <- rotate(your_raster)