Skip to content
Uwe Schneider edited this page May 17, 2022 · 42 revisions

Welcome to the gams2shademap wiki!

GAMS to Shademap

A free software interface from GAMS to Shademap developed by Uwe A. Schneider. Other GAMS interfaces can be found here.


Other GAMS interfaces

GAMS2Gnuplot GAMS2Shademap GAMS2Powerpoint GAMS2GAMS GAMS Memory

Description

"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)

Installation

  1. Download Shademap program from Mark Horridge's webpage. Extract files for Shademap program ("shademap.exe","shademap.chm") to your GAMS system directory.

  2. Download shademap.gms and place in ".\inclib" subdirectory of GAMS system

  3. Create a ".\gislib" subdirectory of GAMS system

  4. 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)

Existing Maps

(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)

Syntax and Use

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)

Format Options

Colors

(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)

Syntax for Loops

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)

Map Examples

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.

World Countries

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

WorldCountries

Continents

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

Continents

Europe NUTS2

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

NUTS2

Europe

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

Europe

The Contiguous US States

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

USA_States_48

All US States

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

USA_States

US Counties

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

USCounties.svg

10 US FASOM Regions

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

USFASOM_10region

GGIFASOM Regions

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

GGIFasom

(Home Description Installation Syntax and Use Format Options Syntax for Loops Map Examples Map Creation Map Enhancement)

Map creation for GIS maps

The following steps describe how to create new maps.

  1. 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

  2. Place shape files in a single zip file and save it.

  3. Convert Shape files to MIF/MID format using Geoconverter. Choose the option "Vector File to ...", attach the zip file from step 2 and choose as export format MapInfo File (MIF). Once the conversion succeeded download the results. Geoconverter produces a zip file which contains a MIF and a MID file.

Geoconverter

  1. Create a new directory of your choice and open a new GAMS project in it

  2. Rename the MIF file into <yourmapname>_mif.gis

    Rename the MID file into <yourmapname>_mid.gis

  3. 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

  4. Save make_GAMSshademaps.gms to the new directory and open a GAMS project in your new directory.

  5. Place <yourmapname> as set element in the set mapname. Remove all unwanted maps from set mapname.

  6. 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

  7. 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)

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)