Professional Documents
Culture Documents
► January (1)
► 2011 (11)
► 2010 (13)
► 2009 (15)
► 2008 (31)
► 2007 (22)
► 2006 (20)
► 2005 (34)
A second map without Antarctica, with a blue palette, five classes, and with a bigger legend with values arranged from low to high (Figure 2) can
Labels
be drawn with this command:
spmap length using worldcoor.dta if admin!="Antarctica", id(id) fcolor(Blues) clnumber(5) legend(symy(*2) symx(*2) size(*2)) legorder(lohi) Africa (62)
Darker colors on the map indicate longer country names, ranging from 4 (for example Cuba and Fiji) to 35 characters (French Southern and
Antarctic Lands). Asia (63)
Please read the Stata help file for spmap to learn about the many additional options for customization of maps. attainment (10)
Figure 2: Length of country names (small scale map, blue palette) blog (8)
Bolivia (4)
Brazil (4)
Burkina Faso (1)
child labor (4)
conflict (1)
DHS (35)
disparity (21)
education (143)
EFA (11)
Europe (4)
Click image to enlarge.
gender (48)
Alternative maps with more detail
India (13)
The shapefile that was used for Figures 1 and 2 was designed for small maps. It contains the borders for 177 countries and territories and does not Indonesia (2)
include smaller geographic units like Hong Kong, Monaco, or St. Vincent and the Grenadines. As an alternative to the small scale map in Figures 1 and
2, Natural Earth offers shapefiles with more detail that were designed for larger maps. Japan (1)
To create the map in Figure 3, download this shapefile from Natural Earth, which has information for 241 countries and territories: Latin America (49)
ne_50m_admin_0_countries.zip (799 KB, world map with country borders, scale 1:50,000,000) Liberia (2)
Unzip ne_50m_admin_0_countries.zip to a folder that is visible to Stata.
Run this Stata command to convert the shapefile to Stata format: literacy (21)
shp2dta using ne_50m_admin_0_countries, data(worlddata2) coor(worldcoor2) genid(id)
map (35)
If you need Stata files with centroids, run this command instead:
shp2dta using ne_50m_admin_0_countries, data(worlddata2) coor(worldcoor2) genid(id) genc(c) MDG (55)
Open worlddata2.dta in Stata.
MICS (25)
Create a variable with the length of each country's name:
generate length = length(admin) Nepal (8)
Draw the map in Figure 3:
Nigeria (9)
spmap length using worldcoor2.dta if admin!="Antarctica", id(id) fcolor(Blues) clnumber(5) legend(symy(*2) symx(*2) size(*2)) legorder(lohi)
The map takes longer to draw than the map in Figures 1 and 2 because it is more detailed and shows more geographic units. The names of the poverty (25)
countries and territories on the map have a length up to 40 characters (South Georgia and South Sandwich Islands).
preschool (8)
Figure 3: Length of country names (medium scale map) primary (70)
publication (33)
quality (4)
SDG (2)
secondary (47)
software (24)
Stata (24)
statistics (136)
survey (56)
tertiary (5)
UNESCO (86)
Click image to enlarge.
UNICEF (30)
To create the map in Figure 4, download this shapefile from Natural Earth, which has information for 255 countries and territories, including
USA (4)
small islands like the Ashmore and Cartier Islands:
ne_10m_admin_0_countries.zip (5.1 MB, world map with country borders, scale 1:10,000,000) world (89)
Unzip ne_10m_admin_0_countries.zip to a folder that is visible to Stata.
Run this Stata command to convert the shapefile to Stata format:
shp2dta using ne_10m_admin_0_countries, data(worlddata3) coor(worldcoor3) genid(id) Links
If you need Stata files with centroids, run this command instead:
shp2dta using ne_10m_admin_0_countries, data(worlddata3) coor(worldcoor3) genid(id) genc(c) UNESCO Institute for Statistics
Open worlddata3.dta in Stata. (UIS)
Create a variable with the length of each country's name:
UIS Data Centre
generate length = length(ADMIN)
Draw the map in Figure 4: UNESCO
spmap length using worldcoor3.dta if ADMIN!="Antarctica", id(id) fcolor(Blues) clnumber(5) legend(symy(*2) symx(*2) size(*2)) legorder(lohi)
UNICEF
The map takes longer to draw than the maps in Figures 1, 2 and 3 because it has the largest amount of detail. The differences between the maps
in Figures 3 and 4 can be seen by clicking on the images to enlarge them. Figure 4 has more islands and more detailed shorelines. The names of World Bank
the countries and territories on the map in Figure 4 have a length up to 40 characters (South Georgia and South Sandwich Islands).
UN Sustainable Development
Figure 4: Length of country names (large scale map) Goals
Related articles
External links
Friedrich Huebler, 31 August 2012 (edited 18 April 2015), Creative Commons License
Permanent URL: http://huebler.blogspot.com/2012/08/stata-maps.html
32 comments:
thanks.
May 28, 2013 3:54 PM
Nigma said...
Cheers for the tutorial.
First, download the countries dataset from the 1:110m Cultural Vectors page (direct link, 184 KB).
Unzip the downloaded file and convert the map to Stata format with this command: shp2dta using ne_110m_admin_0_countries, data(worlddata)
coor(worldcoor) genid(id)
Open the file worlddata.dta in Stata and generate a variable with the length of country names with this command: generate length = length(admin)
The following command creates a map of the entire world: spmap length using worldcoor.dta, id(id)
This command creates a map of France, Portugal and Spain that also shows the French area in South America: spmap length using worldcoor.dta if
admin=="France" | admin=="Portugal" | admin=="Spain", id(id)
We can now limit this map to Europe by adding the plotregion(margin()) option to the command above: spmap length using worldcoor.dta if
admin=="France" | admin=="Portugal" | admin=="Spain", id(id) plotregion(margin(-240 0 -170 0))
The appropriate margins can be found through trial and error. The command above adds a negative margin on the left side and on the bottom of the
map, which means that the map is cropped on those sides. For additional information see the Stata documentation (help region_options).
August 28, 2013 9:48 PM
Regards,
Yangki
April 28, 2014 2:51 PM
Greg said...
Can anyone recommend any shapefiles that only have European countries. I agree google search identifies several but they are not all as easy to use
as the natural earth file in this example. Links would be greatly appreciated.
August 22, 2014 11:18 AM
Anonymous said...
Thanks Friedrich this worked well.
Greg
September 09, 2014 6:55 AM
Sebastian said...
Is it possible to get rid of the small islands without deleting countries like Malta?
I would like to creat a map from the EU and the small islands are a little irritating.
Thanks in advance!
September 30, 2014 8:35 AM
Anonymous said...
Thank you for the tutorial.
I would like to generate a map where countries that meet some condition, e.g. having a particular law, are shaded, while countries that do not, remain
colorless.
I have a binary variable (0's and 1's) in my dataset, but when I use it as the "attribute," Stata thinks the 0's are another "class," and shades them light
gray, while shading the 1's as dark gray. How can I leave the 0's unshaded while shading the 1's?
Thank you!
October 27, 2014 4:48 PM
Nina said...
Hi Friedrich,
I am trying to create a map of the world with different colours for each country.
spmap length using worldcoor2.dta if admin=="Malaysia" | admin=="Indonesia" | admin=="Brunei" | admin=="Timor-Leste" | admin=="Papua New
Guinea", id(id) fcolor(Blues) clnumber(5) legend(symy(*2) symx(*2) size(*2)) legorder(lohi)
November 04, 2014 9:13 AM
Nina said...
Thanks a lot!
Nina said...
Thank you! I appreciate your help.
November 05, 2014 7:23 PM
Unknown said...
Hi Huebler,
I want to change my legend label to appear shorter than the actual data, for example, only presenting it in 2 digits decimal.
Anonymous said...
Hi,
excuse me for my ignorance in this matter, i just recently started to use stata. can you give me a example of a visible folder?
When i use the following command:
"shp2dta using ne_110m_admin_0_countries, data(worlddata) coor(worldcoor) genid(id)"
error r(601) appears...
Kind regards,
John
March 13, 2015 1:53 PM
Anonymous said...
Dear Huebler,
I am intending to publish a list of point coordinates in the ocean (which I have as latitude and longitude columns in my dataset).
What I am doing wrong? I have one single dataset where all the latitude and longitude data is present.
March 27, 2015 7:55 AM
I cannot go into more detail here but this is all documented in help spmap. Quote from the spmap help file: "fcolor(colorlist) specifies the list of fill
colors of the base map polygons. When no choropleth map is drawn, the list should include only one element. On the other hand, when a choropleth
map is drawn, the list should be either composed of k elements, or represented by the name of a predefined color scheme."
In the examples in the article I use fcolor with the Blues color scheme but I could also have specified five different colors.
April 18, 2015 8:30 PM
Unknown said...
Hi, please let me know, how I can show country name on the map. My another question is that how I can draw regional map, for instance, South Asia?
I would like to give you thanks in advance.
March 05, 2016 10:36 PM
Unknown said...
Hi, Please let me know how I can show country's name in the place of the country and how I can draw regional diagram, for instance, South Asia, in
the map.
You have two options if you want to draw a regional map, for example for South Asia. You can either use a shapefile for the region, or you can limit the
map to specific countries with the help of if. The second approach is used in the examples in the article to exclude Antarctica from the map (compare
Figure 1 and Figure 2).
March 06, 2016 10:11 PM
Anonymous said...
Thanks a lot!!!!
February 16, 2017 3:17 PM
Post a Comment