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

40 visualizaciones (últimos 30 días)
Niky Taylor
Niky Taylor el 13 de Mzo. de 2019
Respondida: Harsh Mahalwar el 14 de Jun. de 2023
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!

Respuestas (1)

Harsh Mahalwar
Harsh Mahalwar el 14 de Jun. de 2023
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

Categorías

Más información sobre Mapping Toolbox en Help Center y File Exchange.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by