0

I'm trying to convert GRS 1980 (ellipsoid) to WGS84 using Proj4js. The code that I'm currently using is:

proj4('GRS1980','WGS84'[184058,674431]);

The problem is that Proj4js does not accept GRS1980 (getting uncaught GRS1980).

How can I properly put GRS 1980 as an input for Proj4js?

1

proj4() expects a projection definition, not just an ellipsoid.

From http://proj4js.org/ you might read that WGS84 is the only named projection defined in proj4js. You have to use the listed EPSG codes or define the projection in full.

So your command might be:

var firstProjection = "+proj=longlat +ellps=GRS80 +no_defs";
var secondProjection = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
proj4(firstProjection,secondProjection,[2,5]);

Apart from that, your coordinates are not in the range of proper WGS84, that is +/- 180/90 degrees. From the comments, it seems you are looking for

var firstProjection = "+proj=tmerc +lat_0=31.73439361111111 +lon_0=35.20451694444445 +k=1.0000067 +x_0=219529.584 +y_0=626907.39 +ellps=GRS80 +towgs84=-48,55,52,0,0,0,0 +units=m +no_defs" 
var secondProjection = "+proj=longlat +ellps=WGS84 +datum=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs";

Note that proj4js does not have all EPSG code numbers stored internally, like Proj.4 and GDAL have.

4
  • Seems like the above code you provide outputs the same coordination as you input. I tried looking for its ESPG here: spatialreference.org/ref/epsg but even after adding Proj4js.defs["EPSG:2039"] it's still not giving the same result as in twcc.fr/en/… Jan 24 '17 at 16:25
  • As far as I know, for proj.4 they are synonyms.
    – user30184
    Jan 24 '17 at 16:32
  • 1
    @user30184 from proj -le I see that the rf value differs slightly.
    – AndreJ
    Jan 24 '17 at 17:00
  • Confirmed by Frank Warmermdam in this mail thread osgeo-org.1560.x6.nabble.com/… rf=298.257223563 WGS 84 vs. rf=298.257222101 GRS 1980(IUGG, 1980). I suppose that difference is so small that conversion from WGS84 into GRS80 is usually unnecessary.
    – user30184
    Jan 24 '17 at 17:31

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.