modifying vertices of geopolyshape
이전 댓글 표시
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
답변 (2개)
Geetla Sindhu
2022년 11월 11일
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
Murat Panayirci
2022년 11월 11일
이동: Walter Roberson
2025년 8월 16일
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.
카테고리
도움말 센터 및 File Exchange에서 Create Plots on Maps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
