MATLAB: How to define a Mapping Toolbox stereographic projection using the information from a projection file (.prj)

fileMapping Toolboxparseprojecctionprojectionstereographic

I want to parse a projection (.prj) file and create a stereographic projection using the parameters from the projection file.

Best Answer

The ability to automatically parse a projection file and create a projection is not available in the Mapping Toolbox.
To work around this issue, you can manually parse the projection file and use the parameters to create a stereographic projection. For example, a stereographic projection file has the following contents:
PROJCS["WGS_1984_Stereographic_South_Pole",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Stereographic_South_Pole"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",0.0],PARAMETER["Standard_Parallel_1",-71.0],UNIT["Meter",1.0]]
You can create a Mapping Toolbox stereographic projection structure from the parameters in the .prj file as follows:
mstereo = defaultm('stereo')
mstereo.geoid = [6378137.0, flat2ecc(1/298.257223563)] ;
mstereo.falseeasting = 0;
mstereo.falsenorthing = 0;
mstereo.nparallels = 1;
mstereo.mapparallels = -71;
mstereo.origin = [-90 0];
mstereo = defaultm(mstereo);
To use this projection structure to display latitude and longitude coastline vector data, you can use the following commands:
figure
axesm(mstereo)
load coast
plotm(lat, long)
To transform map coordinate data (given x,y coordinate arrays) to latitude and longitude, use:
[lat,lon] = minvtran(mstereo, x, y);
Related Question