-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the gams2shademap wiki!
A free software interface from GAMS to Shademap developed by Uwe A. Schneider. Other GAMS interfaces can be found here.
- Description
- Installation
- Syntax and Use
- Format Options
- Syntax for Loops
- Map Examples
- Map Creation
- Map Enhancement
Other GAMS interfaces
GAMS2Gnuplot | GAMS2Shademap | GAMS2Powerpoint | GAMS2GAMS | GAMS Memory |
---|
"ShadeMap is a tool, developed by Mark Horridge, for shading or colouring regions of simple maps according to each region's score" (ShadeMap webpage). The GAMS to ShadeMap interface passes regional scores from GAMS programs to ShadeMap. The interface is developed for a Windows Operating System.
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)
-
Download Shademap program from Mark Horridge's webpage. Extract files for Shademap program ("shademap.exe","shademap.chm") to your GAMS system directory.
-
Download shademap.gms and place in ".\inclib" subdirectory of GAMS system
-
Create a ".\gislib" subdirectory of GAMS system
-
For each map, place three files in the ".\gislib" subdirectory of GAMS system. You can create these files on your own (see description below) or download them for available maps from below:
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)
- Worldcountries
- Continents
- Europe
- Europe NUTS2
- USA_States
- USA_States_48
- USFASOM_10region
- USCounties
- GGIFasom
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)
A map is invoked through the following statement in your GAMS program.
$libinclude shademap <map ID> <Parameter>
for example:
Set yoursetname /<firstmapelement, ... , lastmapelement>/;
Parameter v(yoursetname) Shade Values for the Map of Europe;
v(yoursetname) = uniform(0.5,1);
format options - see below
v(yoursetname) = uniform(0.5,1);
$libinclude shademap Europe v
v(yoursetname) = uniform(2,3);
$libinclude shademap Europe v
map ID
must be the filename (without the extension) of the *.mif, *.mid files, which reside in the .\gislib subdirectory of GAMS system. yoursetname
can be more or less any name but the elements of this set must be identical with the elements of the second index in the set <map ID>_map(<map ID>_r,*)
in the file _sm.gms in the .\gislib subdirectory of GAMS system.
If you create a map using the procedure below, a set called _sm will be created in a file called _set.gms which you could use.
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)
(the values of the global variables are case sensitive. "False" may not work, but "false" does.)
$setglobal sm_LineWidth 0
$setglobal sm_RegLineWidth 0
$setglobal sm_FontSize 6
$setglobal sm_SpaceAround 10
$setglobal sm_DesiredWidth 700
$setglobal sm_yytrans 120
$setglobal sm_xDistort 0
$setglobal sm_yDistort 0
$setglobal sm_DotCentroids false
$setglobal sm_DotPolyStarts false
$setglobal sm_UseGreys false
$setglobal sm_OrdinalShades false
$setglobal sm_RGBScores false
$setglobal sm_NumberRegions false
$setglobal sm_ShowScores false
$setglobal sm_ShowNames false
$setglobal sm_NumberRegionPatch false
$setglobal sm_ScoreNDec 1
$setglobal sm_LegendPos "10 70"
$setglobal sm_LowColor blue
$setglobal sm_MidColor red
$setglobal sm_HighColor mediumorchid
$setglobal sm_ShowLegend true
$setglobal sm_TitlePos "70 95"
$setglobal sm_Title "My Plot Title"
$setglobal sm_BackgroundColor orangered
$setglobal sm_RegLineColor yellow
$setglobal sm_AutoScale false
$setglobal sm_ScaleBounds "0 50"
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)
You can loop over shademap statements.
Outside the loop, place the following statement:
$libinclude shademap <map ID> loop
If you want to see the loop element in the title, put the following statement(s) below before the loop:
$setglobal sm_loop1 MyScenarioSet1
$setglobal sm_loop2 MyScenarioSet2
$setglobal sm_loop3 MyScenarioSet3
Inside the loop, as before place
$libinclude shademap <map ID> <Parameter>
for example:
$libinclude shademap <map ID> loop
$setglobal sm_loop1 MyScenarioSet1
$setglobal sm_loop2 MyScenarioSet2
$setglobal sm_loop3 MyScenarioSet3
$setglobal sm_Title "This plot shows: "
LOOP( (MyScenarioSet1, MyScenarioSet2,MyScenarioSet3),
$libinclude shademap <map ID> <Parameter>
);
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)
The following maps are produced by i) extracting the map files to the .\gislib subdirectory of your GAMS directory, ii) copying the program code into GAMS IDE, iii) saving the map as *.emf file. The image on this web page is a *.svg file, which was obtained from the *.emf file with Adobe Illustrator.
Download WorldCountries.zip, WorldCountries_set.gms
$include WorldCountries_set.gms
Parameter v(WorldCountries_sm) Shade Values for the Map of WorldCountries;
v(WorldCountries_sm) = uniform(0.5,1);
$setglobal sm_LowColor blue
$setglobal sm_MidColor green
$setglobal sm_HighColor yellow
$setglobal sm_ShowLegend true
$setglobal sm_BackgroundColor white
$setglobal sm_RegLineColor yellow
$setglobal sm_AutoScale false
$setglobal sm_ScaleBounds "0.5 1"
$setglobal sm_LegendPos "7 57"
$setglobal sm_FontSize 10
$libinclude shademap WorldCountries v
Download Continents.zip, Continents_set.gms, shademap_options.gms
$include Continents_set.gms
$include shademap_options.gms
Parameter v(Continents_sm) Shade Values for the Map of Continents;
v(Continents_sm) = uniform(0.5,1);
$setglobal sm_LowColor green
$setglobal sm_MidColor gold
$setglobal sm_HighColor brown
$setglobal sm_BackgroundColor white
$setglobal sm_LegendPos "3 58"
$setglobal sm_FontSize 10
$libinclude shademap Continents v
Download nuts2.zip, nuts2_set.gms
$include Nuts2_set.gms
Parameter v(Nuts2_sm) Shade Values for the Map of Nuts2;
v(Nuts2_sm) = uniform(0.5,1);
$libinclude shademap Nuts2 v
Download Europe.zip, Europe_set.gms
$include Europe_set.gms
$include shademap_options.gms
Parameter v(Europe_sm) Shade Values for the Map of Europe;
v(Europe_sm) = uniform(0.5,1);
$setglobal sm_LowColor green
$setglobal sm_MidColor gold
$setglobal sm_HighColor brown
$setglobal sm_BackgroundColor white
$setglobal sm_LegendPos "15 2"
$setglobal sm_FontSize 8
$libinclude shademap Europe v
Download USA_States_48.zip, USA_States_48_set.gms
$include USA_States_48_set.gms
$include shademap_options.gms
Parameter v(USA_States_48_sm) Shade Values for the Map of USA_States_48;
v(USA_States_48_sm) = uniform(0.5,1);
$setglobal sm_LegendPos "80 68"
$setglobal sm_FontSize 8
$libinclude shademap USA_States_48 v
Download USA_States.zip, USA_States_set.gms
$include USA_States_set.gms
$include shademap_options.gms
Parameter v(USA_States_sm) Shade Values for the Map of USA_States;
v(USA_States_sm) = uniform(0.5,1);
$setglobal sm_LegendPos "15 60"
$setglobal sm_FontSize 10
$libinclude shademap USA_States v
Download USCounties.zip, USCounties_set.gms
$include USCounties_set.gms
$include shademap_options.gms
Parameter v(USCounties_sm) Shade Values for the Map of USCounties;
v(USCounties_sm) = uniform(0.5,1);
$setglobal sm_LowColor lightseagreen
$setglobal sm_MidColor limegreen
$setglobal sm_HighColor mediumorchid
$setglobal sm_ShowLegend true
$setglobal sm_BackgroundColor white
$setglobal sm_RegLineColor white
$setglobal sm_AutoScale false
$setglobal sm_ScaleBounds "0.5 1"
$setglobal sm_LegendPos "10 50"
$setglobal sm_FontSize 10
$libinclude shademap USCounties v
Download USFASOM_10region.zip, USFASOM_10region_set.gms
$include USFASOM_10region_set.gms
$include shademap_options.gms
Parameter v(USFASOM_10region_sm) Shade Values for the Map of USFASOM_10region;
v(USFASOM_10region_sm) = uniform(0.5,1);
$setglobal sm_LowColor green
$setglobal sm_MidColor gold
$setglobal sm_HighColor brown
$setglobal sm_BackgroundColor white
$setglobal sm_LegendPos "80 68"
$setglobal sm_FontSize 8
$libinclude shademap USFASOM_10region v
Download ggifasom.zip, ggifasom_set.gms
$include ggifasom_set.gms
$include shademap_options.gms
Parameter v(ggifasom_sm) Shade Values for the Map of ggifasom;
v(ggifasom_sm) = uniform(0.5,1);
$setglobal sm_LowColor blue
$setglobal sm_MidColor green
$setglobal sm_HighColor yellow
$setglobal sm_ShowLegend true
$setglobal sm_BackgroundColor white
$setglobal sm_RegLineColor white
$setglobal sm_LegendPos "4 57"
$setglobal sm_FontSize 10
$libinclude shademap ggifasom v
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)
The following steps describe how to create new maps.
-
Get map data as shape files. Shapefiles can be obtained from GIS software applications or downloaded from the internet. Useful sites: Administrative Areas of All Countries, Natural Earth Data, ESRI Open Data, USGS Earth Explorer, Socioeconomic Data and Applications Center, Open Topography, UNEP Environmental Data Explorer, Terra Populus
-
Place shape files in a single zip file and save it.
-
Convert Shape files to MIF/MID format using one of the following methods:
Option A: Using Geoconverter (currently not working)
- Go to Geoconverter
- Choose the option "Vector File to ..."
- Attach the zip file from step 2
- Select "MapInfo File (MIF)" as the export format
- Once the conversion succeeds, download the results
- Geoconverter produces a zip file containing a MIF and a MID file
Option B: Using QGIS (Open Source GIS program)
- Download and install QGIS from the official website
- Open QGIS and start a new project
- Drag and drop your shape file into the QGIS window
- Go to "Layer" in the top menu, then select "Save As..."
- In the "Save Vector Layer as..." dialog:
- Choose "MapInfo MIF" as the format
- Select a destination folder and file name
- Click "OK" to export
- The exported files will include both .mif and .mid files
-
Create a new directory of your choice and open a new GAMS project in it
-
Rename the MIF file into
<yourmapname>_mif.gis
Rename the MID file into
<yourmapname>_mid.gis
-
Create a subdirectory "gis" in your new directory (from step 4) and move or copy the two files
<yourmapname>_mif.gis
and<yourmapname>_mid.gis
inside -
Save make_GAMSshademaps.gms to the new directory and open a GAMS project in your new directory.
-
Place
<yourmapname>
as set element in the set mapname. Remove all unwanted maps from set mapname. -
If you left some of the existing map elements (e.g. gadm36_ESP_0, gadm36_ESP_1, gadm36_ESP_2, gadm36_ESP_3, gadm36_ESP_4, worldcountries) you must copy the corresponding mif/mid files for these maps from this compressed folder
-
Run make_GAMSshademaps.gms. This program goes through the columns of the MID file and selects the first column with unique region names. It also changes the larger MIF file into the necessary format for shademap. If all works well, the map will appear on your screen.
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)
Mark Horridge has written a DOS tool to improve maps. Cleanmap.exe is included in the zip file which contains the shade map program.
Syntax: takes 2 filenames (WITHOUT extensions) and a number as parameters:
cleanmap inmapnam outmapnam frac
inmapnam
= name of existing MapInfo region boundaries files (suffixed MIF/MID)
outmapnam
= name of new MapInfo region boundaries files (suffixed MIF/MID)
frac
= fraction (eg, 0.01) remove polygons area < frac*largest poly in region
tol
(optional) = remove polygons area < tol. The largest polygon in a region is never removed.
(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)