I am trying to write a method in Java that transforms from one CRS to another using GDAL's Java Bindings. Specifically from 3857 to 4326 (and a few others will be common to my use cases).

Here is my code so far (one easy to read permutation of the hundreds of things I've tried). The source and dest strings are paths to shapefiles

public static void warp(String source, String dest) {
    Vector<String> options = new Vector<>();

    WarpOptions ops = new WarpOptions(options);
    Dataset[] des = new Dataset[1];
    Dataset src = gdal.OpenEx(source);
    int Warp = gdal.Warp(src, des, ops);


This is all I get for an error/exception:

ERROR 1: Translating source or target SRS failed: 3857

  • 1
    Try epsg:3857 rather than just the number
    – Ian Turton
    Dec 17, 2022 at 13:34
  • thanks @IanTurton but no joy, same error Dec 17, 2022 at 14:36
  • 1
    I guess not exactly the same ERROR 1: Translating source or target SRS failed: 3857 but with EPSG:3857, right? Does it work with some other -s_srs? Or without -s_srs and -t_srs? What I wonder is if the Proj library is installed right. Without Proj gdalwarp cannot warp. Have you set the PROJ_LIB environment?
    – user30184
    Dec 18, 2022 at 16:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.