3

I have the following OpenGis data, which I want to convert to a latitude/longitude coordinate (as used by Google maps).

<address xmlns:gml="http://www.opengis.net/gml">
  <gml:Point srsName="urn:ogc:def:crs:EPSG::28992">
    <gml:pos>142629.0 523546.0</gml:pos>
  </gml:Point>
</address>

On the EPSG Registry, I found the origin position of EPSG:28992.

Latitude of natural origin      52°09'22.178"N
Longitude of natural origin     5°23'15.5"E
Scale factor at natural origin  0.9999079 unity
False easting                   155000 metre
False northing                  463000 metre

I've tried to using proj4js, but I can't figure out how to put this in a projection and how to get the required output.

I've also tried calculating it myself. But I have no idea what I'm doing here and nothing really made sense :(.

Arnold Daniels
  • 16,516
  • 4
  • 53
  • 82
  • A few questions: is this a one-time batch job, or will you be receiving new data that you have to update on the fly? Also, is this for displaying on a web map, or what format will the output take? And if it's a web map, do you have a specific web mapping library you're already using? – Dave Shepard Feb 22 '17 at 23:47
  • It's a batch job, which will run once a month. How the data is used is not determined or known by me. The data should simply contain longitude/latitude coordinates. – Arnold Daniels Feb 23 '17 at 02:22

2 Answers2

6

Here's how to do it. Ordinarily, you could just transform from one projection to another if Proj4js already included the projection, like this:

proj4('EPSG:900913', 'EPSG:4326', [20.0, 30.0]);

However, EPSG:28992 isn't included in the standard library. To do it, you could add it by adding a new definition:

proj4.defs(
   "EPSG:28992", 
   "+proj=sterea +lat_0=52.15616055555555   +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000  +ellps=bessel  +towgs84=565.040,49.910,465.840,-0.40939,0.35971,-1.86849,4.0772 +units=m +no_defs"
);

Then you can just transform like so:

proj4('EPSG:28992', 'EPSG:4326', [142629.0, 523546.0]);

Which yields

[5.2041980699764325, 52.69918555556015]

On Google Maps

Arnold Daniels
  • 16,516
  • 4
  • 53
  • 82
Dave Shepard
  • 517
  • 2
  • 12
  • Thanks this was super helpful in steering me in the right direction. If anyone is looking for the projection strings to define a projection not included in the proj4 library, they can be found at https://epsg.io by searching for the name of the projection and scrolling down the page to export > PROJ.4 or Proj4js if you're using https://www.npmjs.com/package/proj4 – braitsch Mar 15 '22 at 23:01
1

proj4js is an useful library for converting different system in different output! You can also try to take a conversion online tool, like CS2S

For example, you can try to make a request on the ajax form like this:

https://mygeodata.cloud/drive/crslist?dsid=0&search=28992&limit=50&offset=0

and get back a json:

{"rows": [{"proj4": "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.4171,50.3319,465.5524,-0.398957388243134,0.343987817378283,-1.87740163998045,4.0725 +units=m +no_defs ", "sel": 2, "epsg": 28992, "dsname": "Amersfoort / RD New", "aoi": "Netherlands - onshore, including Waddenzee, Dutch Wadden Islands and 12-mile offshore coastal zone.", "ordering2": 460.0}], "total": 1}

and check, in proj4 key, your lat_0 and lon_0 values

These values are formatted like the google coordinates and maybe is more easy to put in a projection

thejoin
  • 326
  • 2
  • 8
  • I have to convert hundreds of thousands of coordinates. Using an external service is not an option. Can you please show how to use proj4 directly. – Arnold Daniels Feb 22 '17 at 12:04