modifying vertices of geopolyshape
Show older comments
Hi,
I can modify an existing polyshape plot as follows:
Vertices = [0 0 2 2; 2 0 0 2]';
NewVertices = [0 0 2 2; 2 0 0 3]';
pgon = polyshape(Vertices);
p = plot(pgon,'FaceColor','red','FaceAlpha',0.1);
p.Shape.Vertices = NewVertices;
however I can't do the same thing with geopolyshape, since I could not find any properties of it which stores the lat,lon coords. Essentially, I want to enable moving a geopolyshape incrementally with user commands. I would be glad if you anybody could advise.
Thank you,
Murat
Answers (2)
Geetla Sindhu
on 11 Nov 2022
Hello Murat,
I understand that you are trying to use geopolyshape with geographic coordinates.
You can try the following workaround to solve the issue:
- A geopolyshape object represents a polygon or multipolygon in geographic coordinates. Use the geopolyshape function.
shape = geopolyshape(lat,lon)
This function creates a polygon with vertices at the specified latitude and longitude coordinates.
- Then geoplot is used to plot the point, line, or polygon shape objects in shape on a geographic axes.
pg = geoplot(shape)
Now pg is a polygon object with different properties and they be accessed using dot notation.
For example:
shape = geopolyshape([1 10 1 1],[1 1 10 1] );
pg = geoplot(shape);
pg.FaceColor = "r";

Hope this resolves your issue.
You can also refer to Geographic polygon appearance and behavior - MATLAB (mathworks.com) for further information regarding polygon properties.
Thank you.
1 Comment
Murat Panayirci
on 11 Nov 2022
Moved: Walter Roberson
on 16 Aug 2025
Kelly Kearney
on 16 Aug 2025
Edited: Kelly Kearney
on 16 Aug 2025
Old question, but I was working through this same problem when needing to reproject a mappolyshape. It appears that the vertex coordinates are hidden in the undocumented object properties InternalData.VertexCoordinateData1 and InternalData.VertexCoordinateData2. They appear to be modifiable*.
shape = geopolyshape([1 10 1 1],[1 1 10 1]);
geoplot(shape);
hold on
shape.InternalData.VertexCoordinate2 = [1 1 5 1];
geoplot(shape, 'r')
*usual disclaimer that undocumented stuff is liable to change and thus break code. I tested this to R2023a and the Answers site used 2024b to render this.
Categories
Find more on Vector Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!