Announcement

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

  • Generating centroids for regions' names on a map

    Hello everyone;

    I have this data:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(Shape_Leng Shape_Area) str12 Governorate_Name str4 ADM_PCODE str11 Region byte id0 float(consecutivedrydays1990 consecutivedrydays2000 consecutivedrydays2010 consecutivedrydays2020)
     1.665691 .04211232 "Ariana"      "TN12" "North East"   2  55.416  55.303  57.847  61.141
    4.3867736  .3681952 "Beja"        "TN21" "North West"   8  52.289  52.076  53.308  55.618
    1.7179574 .06661047 "Ben Arous"   "TN13" "North East"   3   53.46  53.599  56.039  58.461
     5.343521  .3661806 "Bizerte"     "TN17" "North East"   7  58.769  58.522  60.158    63.1
    4.5108953  .7290807 "Gabes"       "TN51" "South East"  19  93.529  93.583  95.072  98.462
     4.548769  .7402925 "Gafsa"       "TN61" "South West"  22  68.808  69.555  71.168  74.621
     3.647018  .3133408 "Jendouba"    "TN22" "North West"   9  50.708  50.376  51.369  53.909
     4.946872  .6479417 "Kairouan"    "TN41" "Centre West" 16   46.65  47.658  49.138  50.673
     4.989357  .8122157 "Kasserine"   "TN42" "Centre West" 17   46.81  48.063  48.924  50.276
     7.504424 2.1741836 "Kebili"      "TN63" "South West"  24 103.039 103.911  106.19 109.212
    4.1811414 .51084507 "Le Kef"      "TN23" "North West"  10  44.333  44.501  44.524  45.407
     4.073021 .28655812 "Mahdia"      "TN33" "Centre East" 14  62.175  62.873  63.675  65.765
    2.2618155  .1153453 "Manouba"     "TN14" "North East"   4  51.491  51.687  53.117   55.12
     9.757171  .8966198 "Medenine"    "TN52" "South East"  20 118.817 119.937 120.046 119.505
    2.2377114 .10218735 "Monastir"    "TN32" "Centre East" 13  65.619  66.063  67.581  69.789
      3.30774  .2840685 "Nabeul"      "TN15" "North East"   5  61.922  61.725  63.524  65.868
     7.548694  .6909879 "Sfax"        "TN34" "Centre East" 15  69.883  70.526  71.592  73.779
     5.466782  .7327916 "Sidi Bouzid" "TN43" "Centre West" 18  56.814  58.176  60.042  62.447
     5.552421  .4684452 "Siliana"     "TN24" "North West"  11  45.615  45.986  46.558  47.553
     3.156125  .2278667 "Sousse"      "TN31" "Centre East" 12  53.631  54.136  55.859  58.171
    11.073194 3.6204395 "Tataouine"   "TN53" "South East"  21 132.807 135.468 137.765 138.191
     3.798989  .5907553 "Tozeur"      "TN62" "South West"  23  87.197  87.746  89.903  92.967
    1.6094854 .02651095 "Tunis"       "TN11" "North East"   1  54.158  54.579  57.917  60.592
    3.2403774 .28479052 "Zaghouan"    "TN16" "North East"   6  49.008  49.187   50.23  51.743
    end
    As you can see, it is some mapping data for Tunisia, the third variable "Governorate_name" is the name of each region, and I have some climate data "concecutivedrydays" that I'm working with.

    The problem is that I really do need to have the regions's names on the map, I have the variable with those names available ("Governorate_name"), yet which transforming the map data into a .dta format, I forgot to generate the centroids using the gencenroid option back then, so I don't have the data about the centers of polygons or regions available.

    I'am using this spmap command: spmap consecutivedrydays1990 using tngouvcoord, id(id0) clbreaks(44.333 51.0995 56.115 69.3455 132.807) fcolor(OrRd) and it does give me the wanted map, yet without the regions's names, but I want to have those on the map, even more so when the variable for that is available, I just couldn't know how to generate the centroids in order to use the option << label(data("data\basemap_part.dta") xcoord( x_) ycoord(y_) label(Governorate_name) >>.

    Attached to this, you can find the generated map without the regions' names.

    Any help please? I would be greatful!
    Attached Files
Working...
X