Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compute the Center of a Polygon with SpMap

    Dear All,

    I'm using the spmap command on a shape file on Italy. I need to use the option label which requires xcoordinates and ycoordinates to put labels over the Italian region polygons. I would like to put each label in the center of each polygon (=italian region). Is there a way to compute the centroid of each region polygon in Stata, whose coordinates I can use to center these labels?

    Here's the command I'm using so far

    spmap unemployment using italy_region.dta, id(_ID) clmethod(custom) clnumber(7) clbreaks(0 1 5 10 15 20 25) legend(label(2 "Less than 1%") label(3 "2%-5%") label(4 "5%-10%") label(5 "10%-15%") label(6 "15%-20%") label(7 "More than 20%")) label(data("`label.dta") x(xcoord) y(ycoord) label(unemployment) color(red))

    If you know other options that do not compute the centroid, but would center the label in the polygon, that would be very very useful as well.

    Thanks a lot!

  • #2
    Joshua Smith if you used the -shp2dta- (available from the SSC archives) command it contains an option to generate the centroids when it parses the contents of the geometry files.

    Comment


    • #3
      Dear Joshua,

      If you want the center, follow William's advice above. But note that the center is not always the best place for the labels. For many irregular shapes the center will not be the best location for the label. In the extreme (donut case) it will be even wrong.

      ADePT Maps positions the labels strategically, trying to fit them "properly" into the polygons. Note in the following example positions of some labels circled in yellow. They are definitely not in the center of the corresponding polygons.

      Note also, that the optimal placement is (generally) dependent on the label as well as the polygon, not just the polygon (as, it seems, you assume).

      Afaik spmap doesn't have an option for such (automatic) strategic placement of labels.

      Best, Sergiy Radyakin





      Comment

      Working...
      X