[GIS] Proj4js – no transformation for epsg2056

proj

I have a script which converts local coordinates to WGS84.
The script works fine if source data and source CS is epsg:21781. The CS for the data has changed now to epsg:2056. When I use epsg:2056 as source the point coordinate is not transformed at all and the transformation output equals transformation input. Here is the script where the transformation takes place:

var src = new Proj4js.Proj("EPSG:21781"); //<-- EPSG:2056 does not transform 
var dst = new Proj4js.Proj("WGS84"); 
var point = new Proj4js.Point(center.lon, center.lat); 
Proj4js.transform(src, dst, point) 

I don't know anything about Proj4js and I'm just stuck here.

Best Answer

You must just use version that is new enough for having support for EPSG:2056. For example, the development versions from http://www.gisinternals.com/ are built with proj.4 version "proj-4.8" and they know your projection.

gdalinfo --version
GDAL 2.1.0dev, released 2015/99/99

Check if EPSG:2056 is recognized:

gdalsrsinfo epsg:2056

PROJ.4 : '+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0
+units=m +no_defs '

OGC WKT :
PROJCS["CH1903+ / LV95",
    GEOGCS["CH1903+",
        DATUM["CH1903+",
            SPHEROID["Bessel 1841",6377397.155,299.1528128,
                AUTHORITY["EPSG","7004"]],
            TOWGS84[674.374,15.056,405.346,0,0,0,0],
            AUTHORITY["EPSG","6150"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4150"]],
    PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],
    PARAMETER["latitude_of_center",46.95240555555556],
    PARAMETER["longitude_of_center",7.439583333333333],
    PARAMETER["azimuth",90],
    PARAMETER["rectified_grid_angle",90],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",2600000],
    PARAMETER["false_northing",1200000],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]],
    AXIS["Easting",EAST],
    AXIS["Northing",NORTH],
    AUTHORITY["EPSG","2056"]]

The definitions of the new and old seem to be:

# CH1903 / LV03
<21781> +proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs  <>

# CH1903+ / LV95
<2056> +proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs  <>

Changes seem to be in false easting and northing and in towgs84 parameters.

If you can't update your Proj.4 you can always define the projection with the proj string instead of the EPSG:code. Thus use this as projection and you will be fine:

+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs