Extract coordinates from a geopolyshape
Mostra commenti meno recenti
Given a geographic shape object of type geopolyshape:
us_states = readgeotable("usastatehi.shp")
montana = us_states.Shape(us_states.Name == "Montana")
class(montana)
ans =
'geopolyshape'
How could I extract a list of Lat/Lon coordinates of the given shape object (mo_lat, mo_lon)?
% montana
mo_lat = ??? % list of latitudes of Montana polygon edges
mo_lon = ??? % list of longitudes of Montana polygon edges
I know it's possible when loading data using shaperead function instead:
us_states = shaperead("usastatehi.shp")
montana = us_states(26); % 26 is Montana
mo_lat = montana.Y; % list of latitudes of Montana edges
mo_lon = montana.X; % list of longitudes of Montana edges
But I'm curious if it's possible to extract data from existing geopolyshape?
Risposta accettata
Più risposte (3)
Edmund Pickering
il 25 Ago 2025
1 voto
I have found a working solution. The secret is exportShapeData. This appears to be a hidden method. Not sure why this is so.

The present version is much easier. Note that the class of us_states is a table. You can extract the column using:
us_states = readgeotable("usastatehi.shp") ;
class(us_states)
us_states.(1) % first column
us_states.LabelLat % third column
us_states.(4) % 4th column
7 Commenti
Sergey Kostrukov
il 12 Ott 2022
Spostato: KSSV
il 12 Ott 2022
us_states = readgeotable("usastatehi.shp") ;
plot(us_states.LabelLat,us_states.LabelLon,'.r')
What you want to extract from here?
Sergey Kostrukov
il 12 Ott 2022
Sergey Kostrukov
il 12 Ott 2022
Chad Greene
il 1 Nov 2022
I have the exact same question.
The geopolyshape documentation shows how to convert lat,lon coordinates into a geopolyshape:
but then offers no guidance on how to get the lat,lon coordinates back out of shape.
I know the coordinates are in there somewhere, I just don't know how to get them back out!
Sergey Kostrukov
il 1 Nov 2022
Chad Greene
il 2 Nov 2022
This is so frustrating. I don't understand why these new functions have been designed to prevent users from accessing the data we're trying to analyze.
Chad Greene
il 8 Nov 2022
0 voti
@Sergey Kostrukov I think I found a working solution. The m_shaperead function in M_Map can handle PolygonZ and PolyLineZ data.
1 Commento
Sergey Kostrukov
il 11 Nov 2022
Categorie
Scopri di più su Vector Data in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
