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
projcrs
objectGets the grid coordinates for a different DTED file
Measures the time required to project and unproject the coordinates using the same
projcrs
object
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)