I have a geotiff raster image that has a coordinate system with longitudes from 0 to 360. The horizontal center of the image is 180 longitude. See image below:

enter image description here

I want to transform it to EPSG:4326 SRS with -180 180 longtitude range. And I want the center of the image to be at Greenwich meridian (0). I guess this srs is very widely used. I expect the result look like this:

enter image description here

So I use a gdalwarp command to reproject:

gdalwarp -s_srs '+proj=latlong +datum=WGS84 +pm=180dW' -t_srs EPSG:4326 test_col.tif test_4326.tif

But I only get a tiff with bigger dimensions (more pixels) and EPSG:4326 metadata. The image itself looks the same, as the initial one. But I expect it to swap the hemispheres.

How do I gdalwarp an image to be strictly -180 180 EPSG:4326 with the center in 0 longitude?

This is gdalinfo of my initial file:

Origin = (-0.102272598067084,89.946211604095552)
Pixel Size = (0.204545196134167,-0.204423208191126)
Image Structure Metadata:
Corner Coordinates:
Upper Left  (  -0.1022726,  89.9462116) (  0d 6' 8.18"W, 89d56'46.36"N)
Lower Left  (  -0.1022726, -89.9462116) (  0d 6' 8.18"W, 89d56'46.36"S)
Upper Right (     359.897,      89.946) (359d53'50.18"E, 89d56'46.36"N)
Lower Right (     359.897,     -89.946) (359d53'50.18"E, 89d56'46.36"S)
Center      ( 179.8975000,  -0.0000000) (179d53'51.00"E,  0d 0' 0.00"S)

This is gdalinfo after gdalwarp

Origin = (-180.102727401932952,89.946211604095552)
Pixel Size = (0.091397622896436,-0.091420837939082)
Image Structure Metadata:
Corner Coordinates:
Upper Left  (-180.1027274,  89.9462116) (180d 6' 9.82"W, 89d56'46.36"N)
Lower Left  (-180.1027274, -89.9699975) (180d 6' 9.82"W, 89d58'11.99"S)
Upper Right ( 179.8211116,  89.9462116) (179d49'16.00"E, 89d56'46.36"N)
Lower Right ( 179.8211116, -89.9699975) (179d49'16.00"E, 89d58'11.99"S)
Center      (  -0.1408079,  -0.0118929) (  0d 8'26.91"W,  0d 0'42.81"S)

5 Answers 5


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.

  • 2
    hmm, --config CENTER_LONG 0 does nothing, the result is the same raster. Anything I miss here? Running on GDAL version 2.2.3.
    – jurajb
    Jul 8, 2019 at 9:56
  • @jurajb it does change the center longitude with GDAL 3.3.0
    – mckbrd
    Jun 14, 2021 at 13:24

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.


If you just want to view the raster in QGIS, you can set a custom projection with the parameter +lon_wrap=180.

My understanding of this is that, by default, proj4 wraps latitudes from 0 -> 360 to -180 -> 180. +lon_wrap=180 will effectively cancel out this wrapping, and display latitudes between 180 and 360 in the Western hemisphere.

The option +over should disable the wrapping altogether, but - at least in my case - the raster didn't display properly when that option was used.

See http://proj4.org/parameters.html#lon-wrap-over-longitude-wrapping for more information.

  • 3
    This gdalwarp with lon_wrap works for me: gdalwarp -s_srs '+proj=longlat +datum=WGS84 +lon_wrap=180' -t_srs '+proj=longlat +datum=WGS84'
    – zakjan
    Aug 21, 2021 at 22:12
  • Windows users: use " instead of '. ie.: gdalwarp -s_srs "+proj=longlat +datum=WGS84 +lon_wrap=180" -t_srs "+proj=longlat +datum=WGS84"
    – Almaniac
    May 4, 2022 at 17:29

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

load the raster package first.

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

Here is a function that I built to reproject a single dim array of grid values using JavaScript from 0-360 to -180-180.

  let xstart = 180 / xres //xres is the number of values per 1 degree
  for (let y = 0; y < data.height; y++) {
    let index = (y * data.width) + 1,
    start = index + xstart,
    end = index + data.width
    array.splice(index, 0, ...array.splice(start, (end - start)))

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.