Maxima Graphic object
geomap (n1,n2,...)
Draws cartographic maps in 2D.
2D
This function works together with global variable boundaries_array.
Arguments are numbers or lists containing numbers or lists of numbers.
All these numbers must be integers greater or equal than zero,
representing the components of global array boundaries_array.
Each component of boundaries_array is an array of floating
point quantities, the coordinates of a polygonal segment or map boundary.
geomap (n1,n2,...) flattens its arguments and draws the
associated boundaries in boundaries_array.
This object is affected by the following graphic options: line_width,
line_type and color.
Examples:
A simple map defined by hand:
(%i1) load(draw)$ (%i2) /* Vertices of boundary #0: {(1,1),(2,5),(4,3)} */ ( bnd0: make_array(flonum,6), bnd0[0]:1.0, bnd0[1]:1.0, bnd0[2]:2.0, bnd0[3]:5.0, bnd0[4]:4.0, bnd0[5]:3.0 )$ (%i3) /* Vertices of boundary #1: {(4,3),(5,4),(6,4),(5,1)} */ ( bnd1: make_array(flonum,8), bnd1[0]:4.0, bnd1[1]:3.0, bnd1[2]:5.0, bnd1[3]:4.0, bnd1[4]:6.0, bnd1[5]:4.0, bnd1[6]:5.0, bnd1[7]:1.0)$ (%i4) /* Vertices of boundary #2: {(5,1), (3,0), (1,1)} */ ( bnd2: make_array(flonum,6), bnd2[0]:5.0, bnd2[1]:1.0, bnd2[2]:3.0, bnd2[3]:0.0, bnd2[4]:1.0, bnd2[5]:1.0 )$ (%i5) /* Vertices of boundary #3: {(1,1), (4,3)} */ ( bnd3: make_array(flonum,4), bnd3[0]:1.0, bnd3[1]:1.0, bnd3[2]:4.0, bnd3[3]:3.0)$ (%i6) /* Vertices of boundary #4: {(4,3), (5,1)} */ ( bnd4: make_array(flonum,4), bnd4[0]:4.0, bnd4[1]:3.0, bnd4[2]:5.0, bnd4[3]:1.0)$ (%i7) /* Pack all together in boundaries_array */ ( boundaries_array: make_array(any,5), boundaries_array[0]: bnd0, boundaries_array[1]: bnd1, boundaries_array[2]: bnd2, boundaries_array[3]: bnd3, boundaries_array[4]: bnd4 )$ (%i8) draw2d(geomap([0,1,2,3,4]))$
Auxiliary package worldmap sets global variable
boundaries_array to real world boundaries in
(longitude, latitude) coordinates. These data are in the
public domain and come from
http://www-cger.nies.go.jp/grid-e/gridtxt/grid19.html.
Package worldmap defines also boundaries for countries
and continents as lists with the necessary components of
boundaries_array (see file share/draw/worldmap.mac
for more information). Package draw does not
automatically load worldmap.
(%i1) load(draw)$ (%i2) load(worldmap)$ (%i3) c1: gr2d(geomap(Canada,United_States, Mexico,Cuba))$ (%i4) c2: gr2d(geomap(Africa))$ (%i5) c3: gr2d(geomap(Oceania,China,Japan))$ (%i6) c4: gr2d(geomap(France,Portugal,Spain, Morocco,Western_Sahara))$ (%i7) draw(columns = 2, c1,c2,c3,c4)$
Package worldmap is also useful for plotting
countries as polygons. In this case, graphic object
geomap is no longer necessary and the polygon
object is used instead. Since lists are now used and not
arrays, maps rendering will be slower. See also
and make_poly_continent to understand the following code.
(%i1) load(draw)$ (%i2) load(worldmap)$ (%i3) mymap: append( [color = white], /* borders are white */ [fill_color = red], make_poly_country(Bolivia), [fill_color = cyan], make_poly_country(Paraguay), [fill_color = green], make_poly_country(Colombia), [fill_color = blue], make_poly_country(Chile), [fill_color = "#23ab0f"], make_poly_country(Brazil), [fill_color = goldenrod], make_poly_country(Argentina), [fill_color = "midnight-blue"], make_poly_country(Uruguay))$ (%i4) apply(draw2d, mymap)$
See also http://www.telefonica.net/web2/biomates/maxima/gpdraw/geomap for more elaborated examples.