# Angular rotation using Proj4, for local coordinate system

I have a polygon feature on map to which I need to transform the coordinates to local coordinate system with respect to new origin while keeping the same datum.

So far using the Proj4 library and by defining the custom map origin I could able to re-project/transform my global coordinates to local as follows

`+proj=etmerc +lat_0=52.481392 +lon_0=13.355795 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs` --Using this Proj4 definition

Here in the image you can see the marker with name "New Origin" is the one I want to keep at center and transform the coordinates of highlighted polygons to local coordinate system

These are the original coordinates of selected polygons

These are the transformed coordinates of same polygon w.r.t. new map origin

What I am looking forward now is the case of rotated map origin, as of now the current map origin is facing northwards i.e. to north pole, which I need to be rotated by around 90 degrees. Ideally this rotation should effect coordinates of the polygon (as those -ve now may get positive and vice versa).

`+proj=omerc +lat_0=52.481392 +lonc=13.355795 +alpha=90.0 +k=1.0 +x_0=0 +y_0=0 +no_uoff +gamma=90.0 +ellps=WGS84 +units=m +no_defs` --New definition I am trying

Regarding the same, I found this question helpful and thought to try the Oblique Mercator projection, however the results are not changing when I did the 90 degree rotation for alpha and gamma

• Try using only alpha or only gamma, not both. Commented Jul 23, 2018 at 16:44
• @mkennedy I tried those combination, but the results are still the same i.e. I am still getting the same coordinates as if no rotation is applied. Commented Jul 24, 2018 at 7:33
• After setting +alpha to 90 degree I am getting following changes in coordinates [-7.6953274440020305, -34.018725226408954] [-2.501843264326451, -38.56306296658011] [12.448381118476393, -19.840427535785217] [5.318901741877199, -14.513489642501089] So the coordinates are changed but (noticeably on X axis), but it doesn't seems like it changed to the effect of 90 degree. Commented Jul 24, 2018 at 15:05
• Try omitting +no_uoff which should convert the definition from a natural origin case to a center version so the rotation may make more sense. Commented Jul 24, 2018 at 16:46
• If you don't specify both `alpha` and `gamma` it sets the missing one to the explicitly defined one. Set the `+gamma=0` to work in the rotated coordinates, otherwise, gamma=alpha will keep your coordinates aligned with the original azimuth Commented Oct 29, 2020 at 14:33

Finally achieved this by referring this answer which have the rotation method for passed coordinates with respect to the origin. So in above case I had to transform the map origin to local coordinate system, and then pass the respective polygon coordinates as follow,

``````let transformedOrigin = proj4(localProjection, [originY, originX]);
let rotatedLocalCoords = this.rotate(transformedOrigin[0], transformedOrigin[1], polygonCoord[x], polygonCoord[y], -90);
``````

And the rotated method is as follows,

``````rotate: function (cx, cy, x, y, angle) {
let radians = (Math.PI / 180) * angle;