How to change coordinate projection system of a shapfile
Show older comments
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.
Answers (5)
Craig
on 18 Oct 2014
2 votes
Chad Greene
on 17 Oct 2014
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 Comment
Alexander Audet
on 24 Aug 2022
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
on 17 Oct 2014
Edited: Chad Greene
on 17 Oct 2014
0 votes
Can you unproject the polygon data with projinv, then use projfwd to project into the Landsat projection?
Chad Greene
on 19 Oct 2014
0 votes
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.
Categories
Find more on Projected Coordinate Reference Systems in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!