1

The other company that has worked with the exact same map as I use, used to do this with GDAL in C++, but I need to do this in Java and I didn't really want to use GDAL for Java because it is a lot of work to set up and I don't really have the time for this while I have GeoTools which looks like a good option.

They told me they did it like this:

We use the GDAL/OGR libraries to handle the mapping between lat/lon, projected x/y and screen x/y coordinates

Each map is tuned to the exact location of each home-point, to limit distortion. All map projections use some sort of flat surface, which means they all have some sort of distortion, because it does not match the Earth's curvature everywhere.

Abers' Conical Equal Area uses a cone that touches the Earth's surface at 2 latitudes, which we set by default to be 1 degree north and south of the radar. This gives the region near the home-point the least amount of distortion. We do this for virtually all our home-point sites for all customers.

We could create one map projection for both. However, we would have to deliver a new set of topography maps. If you want to combine data from both home-points, you will need to define 3 OGRSpatialReferences; one for lon/lat, one for the first point site, and one for the second point site. Then you can convert all points on both images to lon/lat. Alternatively, you can define the first OGRSpatialReference as any destination projection you like.

Now, how can I do the same thing with GeoTools? Is there a way to do this?

This is their OGC WKT they use to project X/Y:

PROJCS["unnamed",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.2572235629972,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Albers_Conic_Equal_Area"],
    PARAMETER["standard_parallel_1",31.996308],
    PARAMETER["standard_parallel_2",33.996308],
    PARAMETER["latitude_of_center",32.996308],
    PARAMETER["longitude_of_center",35.415901],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,AUTHORITY["EPSG","9001"]]]

What I have tried is loading the WKT and creating a default reference and then doing a MathTransform:

    CoordinateReferenceSystem defaultCrs = org.geotools.referencing.crs.DefaultGeographicCRS.WGS84;
    CoordinateReferenceSystem crs = CRS.parseWKT("PROJCS[\"unnamed\", GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\",6378137,298.2572235629972, AUTHORITY[\"EPSG\",\"7030\"]], AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\",0], UNIT[\"degree\",0.0174532925199433], AUTHORITY[\"EPSG\",\"4326\"]], PROJECTION[\"Albers_Conic_Equal_Area\"], PARAMETER[\"standard_parallel_1\",31.996308], PARAMETER[\"standard_parallel_2\",33.996308], PARAMETER[\"latitude_of_center\",32.996308], PARAMETER[\"longitude_of_center\",35.415901], PARAMETER[\"false_easting\",0], PARAMETER[\"false_northing\",0], UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]]]");
    MathTransform transform = CRS.findMathTransform(defaultCrs, crs, false);

    double[] dest = new double[2];
    transform.transform(new double[] {34.0, 35.0}, 0, dest,  0, 1);

    System.out.println(dest[0] + " " + dest[1]);

But then I get an error:

Exception in thread "main" org.opengis.referencing.operation.OperationNotFoundException: Bursa wolf parameters required.
    at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1082)
    at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:1146)
    at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:891)
    at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperationStep(DefaultCoordinateOperationFactory.java:975)
    at org.geotools.referencing.operation.DefaultCoordinateOperationFactory.createOperation(DefaultCoordinateOperationFactory.java:262)
    at org.geotools.referencing.operation.BufferedCoordinateOperationFactory.createOperation(BufferedCoordinateOperationFactory.java:258)
    at org.geotools.referencing.CRS.findMathTransform(CRS.java:1205)
    at org.geotools.App.main(App.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
  • Welcome to GIS SE! As a new user be sure to take the Tour. You have told us what the other company does, but haven't told us what you've tried. Please edit your question to include what you've tried and what you're stuck with. – Midavalo Oct 1 '16 at 20:52
  • 2
    Please think of merging your accounts: gis.stackexchange.com/help/merging-accounts – AndreJ Oct 2 '16 at 6:03
2

The important part of the error message is Bursa wolf parameters required.

So searching for that on the web will lead you to http://docs.geotools.org/stable/userguide/faq.html#q-bursa-wolf-parameters-required with this solution:

MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, true);

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.