Skip to content
Uwe Schneider edited this page May 7, 2019 · 31 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

(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. With a special data exporting script (for download below), one can create two files for each map using Arcview. These files, however, must be further processed in order to match the required format for shademap. I have written small awk scripts for use with GAMS that do the job. These awk scripts will be used if you follow the steps below.

  1. Convert Shape files to MIF/MID format using Geoconverter Update May 2019: Geoconverter now only produces TAB files. To produce MIF/MID files an additional conversion from TAB to MIF/MID is needed. An open source tool is here

  2. Create a new directory of your choice

  3. Change the name of the <yourmapname>.mif file into <yourmapname>_mif.gis

    Change the name of the <yourmapname>.mid file into <yourmapname>_mid.gis

  4. Place <yourmapname>_mif.gis and <yourmapname>_mid.gis into a GIS subdirectory of your new directory

  5. Extract these files in the new directory and open a GAMS project in your new directory. The following files should be in this directory:

  6. Open file 1_prepare.gms

  7. Place <yourmapname> as additional set element in the set mapname.

  8. Select from the set mapname all maps (each element identifies a map) you want to prepare

  9. Run 1_prepare.gms (This will create 2_runawk.gms and 3_putfiles.gms)

  10. Open 2_runawk.gms and 3_putfiles.gms and execute sequentially

(3_putfiles.gms will produce one or more maps called 4_map_<map ID>.gms)

  1. Run 4_map_<map ID>.gms files to check whether it works

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

Clone this wiki locally
You can’t perform that action at this time.