How to change coordinate projection system of a shapfile
이전 댓글 표시
Using the MATLAB Mapping Toolbox, I am working with raster (Landsat GeoTIFF) and vector data (externally provided shapefiles) that have different coordinate projection systems. The GeoTIFFs are in WGS84_UTM_zone_50S (PCS = 32750) while the shapefiles are in AGD84_AMG_zone_50 (PCS = 20350). Hence, when overlaying the shapefile polygons on the raster image they are out by about 200m.
One way to fix this could be to rewrite the GeoTIFFs and alter their PCS to AGD84_AMG_zone_50 and work in that PCS, but I'd prefer to alter the PCS of the shapefile. I've read about mapstruct and mstruct but the fog hasn't cleared - if there's a way of using these (or other functions) to achieve my goal then I'd really appreciate a simple explanation.
ARCGIS can project data sources with differing PCS 'on-the-fly' but I guess the Mapping Toolbox can't do this?
Kind regards, Craig.
답변 (5개)
Chad Greene
2014년 10월 17일
I've never mixed coordinate systems, but it doesn't seem like it'd be a problem to plot one dataset using geoshow or mapshow with its proper spatial referencing object R, then overlay some other data set that may or may not have the same spatial referencing object.
Another thought: I have not worked with shapefiles, but shaperead has a UseGeoCoords options, which returns data in lat/lon format, independent of any projection information. This seems like it should work:
[A, R] = geotiffread('someLandsatImage.TIF'); % loads image
worldmap('world') % initializes map
geoshow(A,R) % projects Landsat image
S = shaperead('worldcities.shp', 'UseGeoCoords', true); % imports lat/lon data
textm(S.Lat,S.Lon,S.Name) % puts lat/lon data on map
댓글 수: 1
Alexander Audet
2022년 8월 24일
As the Asker mentioned,
'UseGeoCoords', true
does not convert your coordinates to GeoCoordinates, it just tells Matlab (mistakenly in this case) that they are GeoCoordinates. This answer is misleading and should be changed.
Chad Greene
2014년 10월 17일
편집: Chad Greene
2014년 10월 17일
0 개 추천
Can you unproject the polygon data with projinv, then use projfwd to project into the Landsat projection?
Chad Greene
2014년 10월 19일
0 개 추천
There's no magic to coordinate transformations. If you have to perform the transformation more than once, it might be worth it to create some simple conversion functions. And if they help you, they'll probably help someone else, so share them on the File Exchange :) I find that when I share my functions on FEX, my code ends up being more efficient and better documented than when I write one-time-use scripts. Also, the process of documenting code creates a much deeper understanding of the formulas and your own code. Of course you can do the ArcGIS conversions, but then you'd have to use ArcGIS. Personally, I'd rather spend an hour writing a Matlab function than spend a minute using ArcGIS.
카테고리
도움말 센터 및 File Exchange에서 Projected Coordinate Reference Systems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!