View a shapefile, then plot points with lat/long?
20 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a shapefile of the San Francisco Bay Area, which I am reading into Matlab using the following:
S = shaperead('bayarea_general.shp');
I can then view a map of the shapefile using:
mapshow(S)
That all works fine, however, my map is not in lat/long degrees. I would like it to be, since I have a list of points with associated lat/long coordinates. I thought the map might be in UTM, so I converted my data to UTM but that doesn't plot correctly.
My questions are:
1) How do I figure out the coordinate system that my shapefile is in?
2) How do I convert either the shapefile, or my own lat/long data to be in the same format/coordinate system?
Thanks!
0 件のコメント
回答 (1 件)
Harsh Mahalwar
2023 年 6 月 14 日
Hey Niky,
You can figure out the coordinate system of a shapefile using the shapeinfo function!
sInfo= shapeinfo('bayarea_general.shp');
sInfo.CoordinateReferenceSystem
For more information on shapeinfo function you can checkout the following documentation.
https://in.mathworks.com/help/map/ref/shapeinfo.html
In order to convert the shapefile and your lat, long data in the same format, you can read the shapefile using the readgeotable function (which copies your shapefile into a MATLAB structure variable).
saveGeoTable = readgeotable('bayarea_general.shp');
For more information on readgeotable function you can checkout the following documentation.
https://in.mathworks.com/help/map/ref/readgeotable.html
If your lat, long are stored in a csv file, you can read a csv file using readtable function (which copies your csv file into a MATLAB structure variable).
saveTable = readtable("lat_long.csv")
For more information on readtable function you can checkout the following documentation.
https://in.mathworks.com/help/matlab/ref/readtable.html?searchHighlight=readtable&s_tid=srchtitle_readtable_1
This is one of the ways in which you can have these 2 types of data in the same format.
Thanks and regards,
Harsh Mahalwar
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!