File Exchange

image thumbnail

Rotated grid transform

version 1.0.0.0 (1.81 KB) by Simon Funder
Transforms coordinates from regular to rotated grid and vice versa.

5 Downloads

Updated 10 Sep 2013

View License

This functions transforms a set of coordinates in regular lon/lat degrees, grid_in = [lon, lat], to a set of coordinates in rotated lon/lat degrees, grid_out = [lon', lat'], and vice versa:

[grid_out] = rotated_grid_transform(grid_in, option, SP_coor)

where option is the 'direction' of the transform (1: regular -> rotated and 2: rotated -> regular) and SP_coor are the coordinates of the South Pole in the rotated grid [SP_lon, SP_lat]

Example:
SP_coor = [18 -39.3];
grid_in = [[12; 12; 12],[55; 54; 53]];
[grid_out] = rotated_grid_transform(grid_in, 1, SP_coor)

grid_out =

-3.4476 4.4397
-3.5289 3.4430
-3.6100 2.4463

grid_in = grid_out;
[grid_out] = rotated_grid_transform(grid_in, 2, SP_coor)

grid_out =

12.0000 55.0000
12.0000 54.0000
12.0000 53.0000

Reference:
http://gis.stackexchange.com/questions/10808/lon-lat-transformation/14445

Cite As

Simon Funder (2020). Rotated grid transform (https://www.mathworks.com/matlabcentral/fileexchange/43435-rotated-grid-transform), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (14)

skanwal

Hi Simon,
The problem I need help with is if I need to transforms this my data grid (60 by 60) in the northern hemisphere which seems to be defined in the rotated lat-lon coordinates into the regular lat-lon coordinates in matlab, how can I find the the location coordinates of the pole specifically the SP_coor option. When I plot my data grid lat (on y-axis) and the lon (x-axis) using
fastscatter(ds(:,2),ds(:,1),ds(:,3),'markersize',10);
it does the reverse. Data is plotted correctly but lon on y-axis and lat on x-axis. Thank you for your help in advance!

Sheldon

Somayeh Hejabi

Simon Funder

Hi Szabó-Takács Beáta,
notice that have to give the coordinates (both lat and lon) for each cell in your matrix, not just a lat-vector and a lon-vector.

Szabó-Takács Beáta

Dear Simon,
How can I use rotated_grid_transform function if the size of latitude and longitude vectors are different? I mean the size of rotated latitude is 424 and the size of rotated longitude is 412 and grid_in would be [412, 424].
Thank you for your help in advance!

Simon Funder

SP_lon = NP_lon - 180, SP_lat = -NP_lat.

So for your case it will be SP (lon,lat) = (18,-39.25)

judy

Hello Simon,
I have *.nc file with the following coordinate details. How do I convert the rotated grid to WGS84 given the north pole lat and long instead of the south pole?

grid_mapping_name: rotated_latitude_longitude"
grid_north_pole_latitude: 39.25"
grid_north_pole_longitude: -162"

thank you very much for your help

judy

Hello Simon,
I have *.nc file with the following coordinate details. How do I convert the rotated grid to WGS84 given the north pole lat and long instead of the south pole?

grid_mapping_name: rotated_latitude_longitude"
grid_north_pole_latitude: 39.25"
grid_north_pole_longitude: -162"

thank you very much for your help

Simon Funder

Hi Rani, SP_long/lat are the coordinates of the pole that you are rotating your grid around. grid_in are the data points toy want to rotate, it is not (x,y,z), but (x,y).

Rani

Hi Simon, I am new to MATLAB and I have climate data in rotated polar grid which I need to convert into lat/long. How can I use your script with just SP_long/lat coords? I have no grid_in data (i'm assuming that is x,y,z?).
Many thanks.

Simon Funder

Hi Nam, you should be able to use the same script by simple using the corresponding South Pole (to your North Pole) in the rotated grid. So, for instance, if you are working with a rotated grid with NP located in (lon, lat) = (120, 40), then use SP_coor = (-60, -40).

Chad Greene

Users with the Mapping Toolbox may also want to check out the rotatem function.

Nam

This function is working good with rotating is Southern Pole. How can I make with rotating with Norther Pole (i.e.
the rotated pole located in the real Northern Hemisphere)? Thanks for your helping!!

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux