Announcement

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

  • Spmap question

    Hello,

    I am working with regional data and I want to create a regional map that shows how the values of the index change over time. However, I have an issue: for the later periods (Periods 2 and 3), Stata does not draw certain regions on the map, and I haven’t been able to figure out why this happens. For the benchmark period, the code works fine. These are the data:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str21 region_final float(period index_cat1 COD_REG) byte stid float(x_cc y_cc) str28 NOME_REG float(SHAPE_Leng SHAPE_Area)
    "Piedmont"              1 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
    "Piedmont"              3 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
    "Piedmont"              2 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
    "Valle d'Aosta"         3 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
    "Valle d'Aosta"         2 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
    "Valle d'Aosta"         1 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
    "Lombardy"              2 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
    "Lombardy"              1 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
    "Lombardy"              3 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
    "Trentino"              1 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
    "Trentino"              3 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
    "Trentino"              2 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
    "Veneto"                2 2  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
    "Veneto"                3 3  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
    "Veneto"                1 3  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
    "Friuli-Venezia Giulia" 2 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
    "Friuli-Venezia Giulia" 1 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
    "Friuli-Venezia Giulia" 3 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
    "Liguria"               1 3  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
    "Liguria"               2 4  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
    "Liguria"               3 2  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
    "Emilia-Romagna"        2 3  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
    "Emilia-Romagna"        1 3  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
    "Emilia-Romagna"        3 2  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
    "Tuscany"               2 3  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
    "Tuscany"               1 4  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
    "Tuscany"               3 4  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
    "Umbria"                1 3 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
    "Umbria"                2 3 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
    "Umbria"                3 4 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
    "Marche"                2 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
    "Marche"                3 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
    "Marche"                1 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
    "Lazio"                 1 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
    "Lazio"                 3 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
    "Lazio"                 2 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
    "Abruzzo"               3 3 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
    "Abruzzo"               2 2 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
    "Abruzzo"               1 2 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
    "Molise"                3 2 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
    "Molise"                2 2 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
    "Molise"                1 1 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
    "Campania"              1 1 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
    "Campania"              2 1 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
    "Campania"              3 2 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
    "Puglia"                3 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
    "Puglia"                1 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
    "Puglia"                2 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
    "Basilicata"            1 3 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
    "Basilicata"            3 2 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
    "Basilicata"            2 3 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
    "Calabria"              2 2 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
    "Calabria"              1 1 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
    "Calabria"              3 3 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
    "Sicily"                2 3 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
    "Sicily"                1 2 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
    "Sicily"                3 3 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
    "Sardinia"              1 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
    "Sardinia"              2 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
    "Sardinia"              3 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
    end
    And the code:

    Code:
    /*
    ssc install shp2dta
    ssc install spmap
    ssc install mergepoly
    
    *1. Get shapefiles
    copy "http://www.istat.it/it/files/2011/04/reg2011.zip" "reg.zip" unzipfile "reg.zip", replace
    * Convert shapefile to Stata attribute and coordinate datasets
    shp2dta using reg2011, data("reg--‐attr.dta") coord("reg--‐coord.dta") ///
    genid(stid) gencentroids(cc) replace
    */
    
    foreach value in 1 2 3 {
    
    preserve
    keep if period==`value'
    
    spmap index_cat1 using "reg-‐-coord.dta", id(stid) fcolor(Blues) ///
    ocolor(white ..) osize(thin ..) legend(position(2)) legtitle("GE(1)")
    
    graph export "RegionalMap_period`value'.pdf", replace
    
    restore
    }
    Thank you in advance for your help!
    Last edited by Pete Huckelba (StataCorp); 18 Nov 2025, 12:48. Reason: fix CODE blocks

  • #2
    Thanks for the reproducible example. The issue has to do with the distribution of regions across periods and spmap's defaults.

    Code:
    . tab index_cat1 period
    
               |              period
    index_cat1 |         1          2          3 |     Total
    -----------+---------------------------------+----------
             1 |         5          3          2 |        10 
             2 |         5          7          8 |        20 
             3 |         5          5          4 |        14 
             4 |         5          5          6 |        16 
    -----------+---------------------------------+----------
         Total |        20         20         20 |        60
    By default, spmap divides index_cat1 into groups that are based on quartiles. The defaults work fine for period 1 and period 2, but not period 3. But you can resolve this by increasing the number of groups from the default 4 using the option -clnumber()-.


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str21 region_final float(period index_cat1 COD_REG) byte stid float(x_cc y_cc) str28 NOME_REG float(SHAPE_Leng SHAPE_Area)
    "Piedmont"              1 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
    "Piedmont"              3 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
    "Piedmont"              2 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
    "Valle d'Aosta"         3 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
    "Valle d'Aosta"         2 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
    "Valle d'Aosta"         1 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
    "Lombardy"              2 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
    "Lombardy"              1 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
    "Lombardy"              3 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
    "Trentino"              1 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
    "Trentino"              3 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
    "Trentino"              2 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
    "Veneto"                2 2  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
    "Veneto"                3 3  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
    "Veneto"                1 3  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
    "Friuli-Venezia Giulia" 2 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
    "Friuli-Venezia Giulia" 1 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
    "Friuli-Venezia Giulia" 3 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
    "Liguria"               1 3  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
    "Liguria"               2 4  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
    "Liguria"               3 2  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
    "Emilia-Romagna"        2 3  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
    "Emilia-Romagna"        1 3  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
    "Emilia-Romagna"        3 2  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
    "Tuscany"               2 3  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
    "Tuscany"               1 4  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
    "Tuscany"               3 4  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
    "Umbria"                1 3 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
    "Umbria"                2 3 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
    "Umbria"                3 4 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
    "Marche"                2 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
    "Marche"                3 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
    "Marche"                1 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
    "Lazio"                 1 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
    "Lazio"                 3 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
    "Lazio"                 2 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
    "Abruzzo"               3 3 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
    "Abruzzo"               2 2 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
    "Abruzzo"               1 2 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
    "Molise"                3 2 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
    "Molise"                2 2 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
    "Molise"                1 1 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
    "Campania"              1 1 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
    "Campania"              2 1 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
    "Campania"              3 2 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
    "Puglia"                3 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
    "Puglia"                1 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
    "Puglia"                2 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
    "Basilicata"            1 3 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
    "Basilicata"            3 2 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
    "Basilicata"            2 3 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
    "Calabria"              2 2 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
    "Calabria"              1 1 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
    "Calabria"              3 3 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
    "Sicily"                2 3 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
    "Sicily"                1 2 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
    "Sicily"                3 3 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
    "Sardinia"              1 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
    "Sardinia"              2 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
    "Sardinia"              3 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
    end
    
    /*
    ssc install shp2dta, replace
    ssc install spmap, replace
    ssc install mergepoly, replace
    
    *1. Get shapefiles
    copy "http://www.istat.it/it/files/2011/04/reg2011.zip" "reg.zip" 
    unzipfile "reg.zip", replace
    */
    * Convert shapefile to Stata attribute and coordinate datasets
    shp2dta using reg2011, data("reg_attr.dta") coord("reg_coord.dta") ///
    genid(stid) gencentroids(cc) replace
    */
    
    spmap index_cat1 using "reg_coord.dta" if period==3, id(stid) fcolor(Blues) ///
    ocolor(white ..) osize(thin ..) legend(position(2)) legtitle("GE(1)") clnumber(5)

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	38.2 KB
ID:	1783214

    Comment


    • #3
      For comparability across graphs (so that you have the same scale), use clnumber(3) for periods 1 and 2, and clnumber(5) for period 3 (or some other configuration if you want to increase the number of groups). The option -legcount()- will give you the item count, as in my figure in #2, to verify that all regions are included.


      Code:
      spmap index_cat1 using "reg_coord.dta" if period==3, id(stid) fcolor(Blues) ///
      ocolor(white ..) osize(thin ..) legend(position(2)) legtitle("GE(1)") clnumber(5) legcount
      Last edited by Andrew Musau; 16 Nov 2025, 16:43.

      Comment


      • #4
        Thank you very much, Andrew! That is very helpful.

        I created index_cat1 based on the values of the index in the benchmark period so that I could compare changes across regions over time. Would setting the number of clusters using clnumber() affect my initial groupings?

        Comment


        • #5
          Originally posted by Ema Davies View Post
          I created index_cat1 based on the values of the index in the benchmark period so that I could compare changes across regions over time. Would setting the number of clusters using clnumber() affect my initial groupings?
          Specifying the option -cnumber()- just amounts to manually standardizing the scale of your graphs, nothing more. You do need to standardize the scale if you are comparing across graphs, otherwise light blue and dark blue mean different things in graphs with different scales. Otherwise, it has no effect on the data. Look at the legends of the graphs first without adjstments and then with adjustments below.


          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input str21 region_final float(period index_cat1 COD_REG) byte stid float(x_cc y_cc) str28 NOME_REG float(SHAPE_Leng SHAPE_Area)
          "Piedmont"              1 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
          "Piedmont"              3 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
          "Piedmont"              2 2  1  1  415050.4 4990052.5 "PIEMONTE"                       1333368 25387077632
          "Valle d'Aosta"         3 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
          "Valle d'Aosta"         2 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
          "Valle d'Aosta"         1 4  2  2    374586   5065546 "VALLE D'AOSTA/VALL�E D'AOSTE"  325841.8  3260902144
          "Lombardy"              2 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
          "Lombardy"              1 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
          "Lombardy"              3 1  3  3 560041.06   5052221 "LOMBARDIA"                    1511138.6 23863373824
          "Trentino"              1 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
          "Trentino"              3 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
          "Trentino"              2 4  4  4  675212.7   5145719 "TRENTINO-ALTO ADIGE/SUDTIROL"  859832.4 13604646912
          "Veneto"                2 2  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
          "Veneto"                3 3  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
          "Veneto"                1 3  5  5  722609.9   5059266 "VENETO"                       1141613.6 18407165952
          "Friuli-Venezia Giulia" 2 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
          "Friuli-Venezia Giulia" 1 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
          "Friuli-Venezia Giulia" 3 2  6  6  813301.1   5119012 "FRIULI VENEZIA GIULIA"         764140.7  7862283264
          "Liguria"               1 3  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
          "Liguria"               2 4  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
          "Liguria"               3 2  7  7  476283.1 4901665.5 "LIGURIA"                      1066676.4  5416171520
          "Emilia-Romagna"        2 3  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
          "Emilia-Romagna"        1 3  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
          "Emilia-Romagna"        3 2  8  8  662469.1   4932689 "EMILIA-ROMAGNA"               1259933.8 22452443136
          "Tuscany"               2 3  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
          "Tuscany"               1 4  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
          "Tuscany"               3 4  9  9  672386.5   4813007 "TOSCANA"                        1541173 22986952704
          "Umbria"                1 3 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
          "Umbria"                2 3 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
          "Umbria"                3 4 10 10  784790.6   4763041 "UMBRIA"                        671080.7  8464247808
          "Marche"                2 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
          "Marche"                3 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
          "Marche"                1 4 11 11  835669.3 4807900.5 "MARCHE"                        708821.8  9401304064
          "Lazio"                 1 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
          "Lazio"                 3 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
          "Lazio"                 2 1 12 12    812598   4654510 "LAZIO"                        1193848.5 17232072704
          "Abruzzo"               3 3 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
          "Abruzzo"               2 2 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
          "Abruzzo"               1 2 13 13  900851.3 4686592.5 "ABRUZZO"                       662279.5 10831672320
          "Molise"                3 2 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
          "Molise"                2 2 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
          "Molise"                1 1 14 14  965814.9   4630075 "MOLISE"                        471201.6  4460510720
          "Campania"              1 1 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
          "Campania"              2 1 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
          "Campania"              3 2 15 15  992767.6 4539701.5 "CAMPANIA"                     1085218.1 13670827008
          "Puglia"                3 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
          "Puglia"                1 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
          "Puglia"                2 2 16 16 1142802.5   4565211 "PUGLIA"                       1501574.3 19540824064
          "Basilicata"            1 3 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
          "Basilicata"            3 2 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
          "Basilicata"            2 3 17 17 1100506.4   4507499 "BASILICATA"                    675616.4 10073287680
          "Calabria"              2 2 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
          "Calabria"              1 1 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
          "Calabria"              3 3 18 18 1135967.8   4349828 "CALABRIA"                      933013.4 15221893120
          "Sicily"                2 3 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
          "Sicily"                1 2 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
          "Sicily"                3 3 19 19  954868.5   4172912 "SICILIA"                        1725060 25832380416
          "Sardinia"              1 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
          "Sardinia"              2 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
          "Sardinia"              3 4 20 20  502635.9 4437219.5 "SARDEGNA"                       2113775 24100057088
          end
          
          /*
          ssc install shp2dta, replace
          ssc install spmap, replace
          ssc install mergepoly, replace
          
          *1. Get shapefiles
          copy "http://www.istat.it/it/files/2011/04/reg2011.zip" "reg.zip"
          unzipfile "reg.zip", replace
          */
          * Convert shapefile to Stata attribute and coordinate datasets
          shp2dta using reg2011, data("reg_attr.dta") coord("reg_coord.dta") ///
          genid(stid) gencentroids(cc) replace
          */
          
          *NO ADJUSTMENTS
          forval i=1/3{
              spmap index_cat1 using "reg_coord.dta" if period==`i', id(stid) fcolor(Blues) ///
              ocolor(white ..) osize(thin ..) legend(position(2)) legtitle("GE(1)") saving(gr`i', replace)
          }
          gr combine gr1.gph gr2.gph gr3.gph, row(1) title(NO ADJUSTMENTS TO SCALES)
          
          *WITH ADJUSTMENTS
          forval i=1/3{
           local g= cond(`i'==3, 5, 3)
              spmap index_cat1 using "reg_coord.dta" if period==`i', id(stid) fcolor(Blues) clnumber(`g') ///
              ocolor(white ..) osize(thin ..) legend(position(2)) legtitle("GE(1)") saving(gr`i', replace)
          }
          gr combine gr1.gph gr2.gph gr3.gph, row(1) title(WITH ADJUSTMENTS TO SCALES)
          Click image for larger version

Name:	Graph.png
Views:	1
Size:	60.5 KB
ID:	1783239


          Click image for larger version

Name:	Graph2.png
Views:	1
Size:	68.8 KB
ID:	1783240


          As you can see, only in the latter case are the legends (scales) consistent, and thus comparable.

          Comment


          • #6
            Thank you, Andrew, for the clarification!

            Comment

            Working...
            X