How to plot polygon from shapefile in Matlab

78 ビュー (過去 30 日間)
Yoni Verhaegen -WE-1718-
Yoni Verhaegen -WE-1718- 2021 年 1 月 23 日
回答済み: MathWorks Support Team 2023 年 7 月 11 日
Hi all,
I have the following polygon, which should represent the borders of Belgium, The Netherlands and Luxemburg.
I am however not able to plot these using Matlab on top of an imagesc. Can anyone help me? The file is in attachment.
T=shaperead('BENELUX_POLYGON.shp','usegeo', true);
Thanks already

回答 (2 件)

Deepak Meena
Deepak Meena 2021 年 1 月 29 日
Hi Yoni ,
shaperead only Read vector features and attributes from shapefile, it won't plot those data.
To plot those shapefile you need to use mapshow. I tried this on my end :
T=shaperead('BENELUX_POLYGON.shp','usegeo', true);
mapshow(T)
and I got the following result :

MathWorks Support Team
MathWorks Support Team 2023 年 7 月 11 日
As of R2021b, you can read the shapefile with readgeotable and plot the data with geoshow:
T = readgeotable('BENELUX_POLYGON.shp');
geoshow(T)
In addition, you can plot the image data as a raster object using geoshow, provided you have a raster reference object.

Community Treasure Hunt

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

Start Hunting!

Translated by