Label Polygons in Mapshow

9 views (last 30 days)
CMatlabWold
CMatlabWold on 24 May 2020
Commented: CMatlabWold on 28 May 2020
Hi
I have a shapefile of zip codes of NYC. When I use the code, I get this pic and a structure is created, where zip codes are listed in column 5 of the structure. How can I label these zip codes on the map, where it shows?
Thanks,
Candace
%S = shaperead('ZipCode1.shp','UseGeoCoords',true);
S = shaperead('ZipCode1.shp')
mapshow(S)
  1 Comment
CMatlabWold
CMatlabWold on 27 May 2020
Thank you! It works. Is there a way to reduce the text size?

Sign in to comment.

Accepted Answer

Sai Sri Pathuri
Sai Sri Pathuri on 26 May 2020
Edited: Sai Sri Pathuri on 26 May 2020
You may find internal point of bounding boxes and use text function.
for i=1:263
meanValue = mean(S(i).BoundingBox);
text(meanValue(1),meanValue(2),num2str(S(i).ZIPCODE))
end
  2 Comments
Sai Sri Pathuri
Sai Sri Pathuri on 27 May 2020
To reduce text size, you may use FontSize name-value pair of text funtion
text(meanValue(1),meanValue(2),num2str(S(i).ZIPCODE),'FontSize',fontsize)
CMatlabWold
CMatlabWold on 28 May 2020
Thank you!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!