Convert values from one geographical projection to another

Today I came across a task to convert longitude and latitude values to 

SWEREF 99 TM projection which is commonly used in Sweden.

I asked from several senior developers work in the company and following those information I found out a javascript library Proj4js to get the job done.

You can easily transform coordinates just by downloading the proj4.js file, refering and try as in the example code.

my code for latlong to 

SWEREF 99 TM as follows:

function transformCoordinates(lat, lng) {
       [‘EPSG:4326’, ’+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs’],
       ['EPSG:3006’, ’+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs’]
   return proj4(proj4.defs('EPSG:4326’), proj4.defs('EPSG:3006’), [lat, lng]);

As you can see you need to define the projection you are going to use. You can find the projection definition strings at . Click on the link “Proj4js format” for specific projection to find out the projection definition string.


Author: Harshani Nawarathna

Sri Lankan woman in Computing

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s