View a shapefile, then plot points with lat/long?

조회 수: 19 (최근 30일)
Niky Taylor
Niky Taylor 2019년 3월 13일
답변: Harsh Mahalwar 2023년 6월 14일
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!

답변 (1개)

Harsh Mahalwar
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

제품


릴리스

R2017a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by