[gdal-dev] GDAL Java Bindings - Convert raster from [0, 360] to [-180, 180]

Hare, Trent thare at usgs.gov
Mon Jul 13 07:09:00 PDT 2015


Jesse,
   The problem with warping is that you might incur resampling. Here is an
older thread, no longer exists beside in the wayback machine, which
explains how you can swap sides using pixel tricks in a VRT header
(pointing to your original data).
https://web.archive.org/web/20130618003511/http:/www1.eonfusion.com/manual/index.php/Manipulate_rasters_with_GDAL_VRT

It should be fairly easy to script up something to do this general also. I
use this trick to no only swap from 180 to 360 but also support WMS layers
from -180 to 360 (540 degrees total) without duplicating data. That way WMS
clients can call either ranges from -180 to 180 or 0 to 360.

Regards,
Trent

On Mon, Jul 13, 2015 at 1:21 AM, johie <jesse.hietanen at gmail.com> wrote:

> Hi!
>
> I'm processing some global GRIB2/netCDF data which have East-West
> coordinates of 0-360 degrees. I need to have the output data on typical
> -180, 180 range to process them later with some other data. When I
> reproject
> them to WGS84 and convert to GeoTiff, the output is still 0-360.
>
> I found that I can then warp that output GeoTiff using the command line
> gdal: gdalwarp -t_srs WGS84 input360.tif output180.tif --config CENTER_LONG
> 0 -wo SOURCE_EXTRA=1000
>
> This work just fine and the output is correct. But I would need to do this
> using the Java bindings. I can pass the Center Long with:
> gdal.SetConfigOption("CENTER_LONG", "0"); But not the Source_Extra, which
> is
> WarpingOptions if I understood correctly? In java there seems to be no way
> to pass these warping options when using AutoCreatedWarped and Create (see
> processing flow:
>
> http://osgeo-org.1560.x6.nabble.com/gdal-dev-GDAL-Java-Bindings-No-data-value-using-AutoCreateWarpedVRT-td5212697.html
> )
>
> Is there some workaround to this using the Java?
>
> This is how the output looks when processing with the Java (Data is lost on
> the white "stripe"). This looks the same as using the gdalwarp without
> Source_extra.
>
> <http://osgeo-org.1560.x6.nabble.com/file/n5215366/GDAL_CenterLong0.png>
>
> Thanks a lot!
>
> Jesse
>
>
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/gdal-dev-GDAL-Java-Bindings-Convert-raster-from-0-360-to-180-180-tp5215366.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150713/62cf3f20/attachment.html>


More information about the gdal-dev mailing list