2

I need to know how to create a proj4.js and proj4leaflet.js which requires me to convert coordinates from EPSG:31700 to wgs84.

Both scripts I will load in leaflet script.

1 Answer 1

2

If you go to SpatialReference.org they maintain a list of spatial references. Through this website you can search spatial references by different criteria. On the page of each specific spatial reference they provide the spatial references in a number of formats, one of which is proj4.js.

See here for EPSG:31700 of which the proj4.js format is:

Proj4js.defs["EPSG:31700"] = "+proj=sterea +lat_0=46 +lon_0=25 +k=0.99975 +x_0=500000 +y_0=500000 +ellps=krass +units=m +no_defs";

See here for EPSG:4326 of which the proj4.js format is:

Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";

Each of the different formats of representing the spatial references for the individual references are there own url and the naming of the urls are quite straight forward so you could consume the spatial reference/format url into your javascript and do it that way. For example, the url to the EPSG:31700 proj4.js (above) is:

http://spatialreference.org/ref/epsg/31700/proj4js/

And for EPSG:4326, is:

http://spatialreference.org/ref/epsg/4326/proj4js/

The urls have a set structure and are consistent.

SpatialReference.org is a wonderful resource for finding spatial references and becoming familiar with different formats to represent them.

In terms of using this in Proj4Leaflet, if you go their documentation here the first example on that page will show you have to use the proj4.js information obtained from SpatialReference.org and create an L.Proj.CRS with Proj4Leaflet.

4
  • Great, but where to find proj4leaflet?
    – user87349
    Commented Dec 1, 2016 at 17:28
  • @user87349 see updated answer.
    – GeoSharp
    Commented Dec 1, 2016 at 17:31
  • That is it. Great.
    – user87349
    Commented Dec 1, 2016 at 17:31
  • 1
    Note that the proj4 string for 31700 doesn't have a towgs84 parameter for the datum transformation. To get between Dealul Piscului 1970 AKA Pulkovo 1942(58), add +towgs84=2.329,-147.042,92.08,-0.309,0.325,0.497,5.69 AKA EPSG::15995 (rotation sign values are reversed to switch from coordinate frame method to proj4's position vector method.
    – mkennedy
    Commented Dec 1, 2016 at 18:41

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.