2

I would like to use the Oblique Mercator projection in GeoTools.

I'm currently using a WGS84 Mercator projection like this:

        final CoordinateReferenceSystem wgs84CoordSystem = CRS
                .decode(LATLON_EPSG_CODE);
        final CoordinateReferenceSystem worldMercatorCoordSystem = CRS
                .decode(MERCATOR_EPSG_CODE);
        final MathTransform latLonToMercator = CRS.findMathTransform(wgs84CoordSystem,
                worldMercatorCoordSystem);
        final MathTransform mercatorToLatLon = CRS.findMathTransform(worldMercatorCoordSystem,
                wgs84CoordSystem);

The Oblique Mercator EPSG code doesn't appear to be supported (and I want to be able to specify the latitude of centre and azimuth anyway).

Could anyone give me an example of how to create a WGS84 Oblique Mercator projection and MathTransform to allow me to convert to/from Lat/Lon please?

2 Answers 2

2

Here is the solution I used:

    // Define WGS84 Oblique Mercator WKT
private static final String MERCATOR_WKT = "PROJCS[\"OBLIQUE MERCATOR\","
        + "GEOGCS[\"WGS 84\","
        + "DATUM[\"WGS_1984\","
        + "SPHEROID[\"WGS 84\",6378137,298.257223563]],"
        + "PRIMEM[\"Greenwich\",0],"
        + "UNIT[\"degree\",0.01745329251994328]],"
        + "PROJECTION[\"Hotine_Oblique_Mercator\"],"
        // Centre location tags added to be replaced
        + "PARAMETER[\"latitude_of_center\",LATITUDE_OF_CENTRE],"
        + "PARAMETER[\"longitude_of_center\",LONGITUDE_OF_CENTRE],"
        // Azimuth and rectified grid angle set slightly below 90 to avoid
        // precision errors
        + "PARAMETER[\"azimuth\",89.999999],"
        + "PARAMETER[\"rectified_grid_angle\",89.999999],"
        + "PARAMETER[\"scale_factor\",1],"
        + "PARAMETER[\"false_easting\",0],"
        + "PARAMETER[\"false_northing\",0]," + "UNIT[\"metre\",1]]";

final CoordinateReferenceSystem obliqueMercatorCoordSystem = CRS
                .parseWKT(MERCATOR_WKT.replace("LATITUDE_OF_CENTRE",
                        Double.toString(centre.getLat())).replace(
                        "LONGITUDE_OF_CENTRE",
                        Double.toString(centre.getLon())));

This allows me to set the longitude and latitude of centre.

1

Have you tried to define the Mercator projection using a WKT string?

http://spatialreference.org/ref/epsg/3395/prettywkt/

and a org.gdal.osr.SpatialReference object calling the method SetWellKnownGeogCS:

String wkt = "PROJCS["WGS 84 / World Mercator",GEOGCS["WGS ...";

CoordinateReferenceSystem worldMercatorCoordSystem = CRS.parseWKT(wkt);
1
  • Yes - sorry I forgot to post my solution. See below...
    – user8204
    Commented Sep 12, 2012 at 8:09

Your Answer

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