# modifying vertices of geopolyshape

2 views (last 30 days)
Murat Panayirci on 8 Nov 2022
Answered: Murat Panayirci on 11 Nov 2022
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

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"; You can also refer to Geographic polygon appearance and behavior - MATLAB (mathworks.com) for further information regarding polygon properties.
Thank you.

Murat Panayirci on 11 Nov 2022
Hi Geetla,
my problem is that the object pg you created with geoplot does not have a "Vertices" field (as in the regular polyshape plot) which I can modify. see below
shape = geopolyshape([1 10 1 1],[1 1 10 1] );
pg = geoplot(shape);
>> pg.ShapeData
ans =
geopolyshape with properties:
NumRegions: 1
NumHoles: 0
Geometry: "polygon"
CoordinateSystemType: "geographic"
GeographicCRS: []
>> pgon = polyshape([0 0 2 2],[2 0 0 2]);
>> p = plot(pgon,'FaceColor','red','FaceAlpha',0.1);
>> p.Shape
ans =
polyshape with properties:
Vertices: [4×2 double]
NumRegions: 1
NumHoles: 0
as you can see pg.ShapeData or any other field that I checked does not enable me to easily update the geoplot by updating the coords of vertices. Whereas for polyshape, I can do that as I have mentioned in my original post.
So my question is: how can I modify the geoplot of a geopolyshape, without replotting it?
thanks,
Murat

### Categories

Find more on Vector Data in Help Center and File Exchange

R2022b

### Community Treasure Hunt

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

Start Hunting!