[GIS] GeoTools Oblique Mercator Example

coordinate systemgeotools

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?

Best Answer

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.

Related Question