projinv
Unproject x-y map coordinates to latitude-longitude coordinates
Description
[
transforms the map coordinates specified by lat,lon]
= projinv(proj,x,y)x and y in
the projected coordinate reference system specified by proj to the
latitude-longitude coordinates lat and lon. Specify
proj using a projcrs object
(since R2020b), a map projection structure, or a GeoTIFF information
structure.
Examples
Unproject x-y coordinates to latitude-longitude coordinates by specifying the projected CRS of the x-y coordinates. Then, display the latitude-longitude coordinates on geographic axes.
To do this, first import a shapefile containing the x- and y-coordinates of roads in Concord, MA. Get information about the shapefile as a structure. Find the projected CRS for the coordinates by accessing the CoordinateReferenceSystem field of the structure.
roads = shaperead("concord_roads.shp"); x = [roads.X]; y = [roads.Y]; info = shapeinfo("concord_roads.shp"); proj = info.CoordinateReferenceSystem;
Unproject the x-y coordinates to latitude-longitude coordinates.
[lat,lon] = projinv(proj,x,y);
Display the coordinates on geographic axes.
figure geoplot(lat,lon) hold on geobasemap streets

The geographic CRS of the x-y coordinates used in this example is NAD83. You can find the geographic CRS that underlies a projected CRS by querying the GeographicCRS property.
proj.GeographicCRS.Name
ans = "NAD83"
The geographic CRS underlying the 'streets' basemap is WGS84. NAD83 and WGS84 are similar, but not identical. Therefore, at high zoom levels the coordinates and basemap may appear misaligned.
Input Arguments
Map projection, specified as a projcrs object
(since R2020b), a scalar map projection structure
(mstruct), or a GeoTIFF information structure. For more information about
map projection structures, see defaultm. For more information about GeoTIFF
information structures, see geotiffinfo.
Data Types: struct
Projected x-coordinates, specified as a scalar value, vector, matrix,
or N-D array. The size of x and y must match.
Data Types: single | double
Projected y-coordinates, specified as a scalar value, vector, matrix,
or N-D array. The size of x and y must match.
Data Types: single | double
Output Arguments
Geodetic latitudes, returned as a scalar value, vector, matrix, or N-D array, in units of degrees.
The geographic CRS of lat matches the geographic CRS of
proj. If proj is a projcrs object, then
you can find its geographic CRS by querying its GeographicCRS property.
For example, this code shows how to create a projcrs object from EPSG code
32610 and find the associated geographic CRS.
proj = projcrs(32610); proj.GeographicCRS.Name
ans =
"WGS 84"Geodetic longitudes, returned as a scalar value, vector, matrix, or N-D array, in units of degrees.
The geographic CRS of lat matches the geographic CRS of
proj. If proj is a projcrs object, then
you can find its geographic CRS by querying its GeographicCRS property.
For example, this code shows how to create a projcrs object from EPSG code
32610 and find the associated geographic CRS.
proj = projcrs(32610); proj.GeographicCRS.Name
ans =
"WGS 84"Version History
Introduced before R2006aThe projinv and projfwd functions show improved
performance on Windows® when used multiple times in the same MATLAB® session with the same projcrs object or map projection structure
as input.
For example, this code is about 1.67 times faster than in the previous release. The code:
Gets the grid coordinates for a DTED file
Projects and unprojects the coordinates using a
projcrsobjectGets the grid coordinates for a different DTED file
Measures the time required to project and unproject the coordinates using the same
projcrsobject
function timingTest info1 = georasterinfo("n39_w106_3arc_v2.dt1"); R1 = info1.RasterReference; [latGrid1,lonGrid1] = geographicGrid(R1); p = projcrs(4088); [xfwd1,yfwd1] = projfwd(p,latGrid1,lonGrid1); [latinv1,loninv1] = projinv(p,xfwd1,yfwd1); info2 = georasterinfo("n40_w106_3arc_v2.dt1"); R2 = info2.RasterReference; [latGrid2,lonGrid2] = geographicGrid(R2); tic [xfwd2,yfwd2] = projfwd(p,latGrid2,lonGrid2); [latinv2,loninv2] = projinv(p,xfwd2,yfwd2); toc end
The approximate execution times are:
R2022a: 0.70 s
R2022b: 0.42 s
This code was timed on a Windows 10 Intel®
Xeon® CPU W-2133 @ 3.6 GHz test system, by calling the function
timingTest.
Unproject coordinates by specifying a projcrs object. A
projcrs object enables you to transform coordinates using projection methods
not available in earlier releases, such as Hotine Oblique Mercator.
Additionally, you can unproject coordinates by specifying a map projection structure with
any valid mapprojection field. For a list of mapprojection
field options, use the maplist or maps function.
See Also
Functions
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)