Geographic Data - Maple Help

Geographic Data

Maple 2017 updates the DataSets package to include a built-in geographic information database and a map visualization facility.

GeoNames Dataset

The GeoNames data set is a built-in geographic information database which contains data for over one million geographic locations around the world. The GeoNames data set shares the same set of accessing commands as other built-in data sets.

Obtain a Reference object for the GeoNames data set:

$\mathrm{with}\left(\mathrm{DataSets}\right):$

$\mathrm{with}\left(\mathrm{DataSets}:-\mathrm{Builtin}\right):$

$\mathrm{ref}≔\mathrm{Reference}\left("GeoNames"\right)$

 ${\mathrm{ref}}{≔}\left[\begin{array}{ccccc}{\mathrm{Geonames \left(GeoNamesid\right)}}& {\mathrm{Name}}& {\mathrm{Type}}& {\dots }& {\mathrm{\left(7 more\right)}}\\ {\mathrm{68}}& {\mathrm{Boneh-ye Mehdi}}& {"section of populated place"}& {\dots }& {}\\ {\mathrm{121}}& {\mathrm{Lab Sefid}}& {"locality"}& {\dots }& {}\\ {\mathrm{166}}& {\mathrm{Gorizi}}& {"locality"}& {\dots }& {}\\ {⋮}& {⋮}& {⋮}& {\ddots }& {}\\ {\mathrm{\left(1087362 more\right)}}& {}& {}& {}& {}\end{array}\right]$ (1.1)

Each data entry (row) consists of 10 columns where each column denotes certain information about that geographic location. The first column, GeoNamesid, is an integer id unique to each row.

View a list of all the column headers (not including GeoNamesid):

$\mathrm{GetHeaders}\left(\mathrm{ref}\right)$

 $\left[{"Name"}{,}{"Type"}{,}{"Latitude"}{,}{"Longitude"}{,}{"Country"}{,}{"Province/State/Region"}{,}{"City/County"}{,}{"Population"}{,}{"Time Zone"}\right]$ (1.2)

You can search the data set by indexing into the Reference object. The most interesting and useful indexing method is to index by boolean constraints on column values. For example, find all places in Canada with the name Waterloo and see the actual data:

$\mathrm{GetData}\left(\mathrm{ref}\left[\left[\mathrm{Country}="Canada",\mathrm{Name}="Waterloo"\right]\right]\right)$

 $\left[\begin{array}{ccccccccc}{"Waterloo"}& {"populated place"}& {45.3500799999999984}& {-72.5158200000000051}& {"Canada"}& {"Quebec"}& {"Monteregie"}& {4064}& {"America/Toronto"}\\ {"Waterloo"}& {"populated place"}& {43.4667999999999992}& {-80.5163900000000012}& {"Canada"}& {"Ontario"}& {\mathrm{undefined}}& {97475}& {"America/Toronto"}\\ {"Waterloo"}& {"third-order administrative division"}& {45.3367300000000029}& {-72.5279599999999931}& {"Canada"}& {"Quebec"}& {"Monteregie"}& {\mathrm{undefined}}& {"America/Toronto"}\end{array}\right]$ (1.3)

Find out which states in the US have population greater than 5 million:

$\mathrm{ref}\left[\left[\mathrm{Country}="United States",\mathrm{Type}="first-order administrative division",\mathrm{Population}>5000000\right]\right]$

 $\left[\begin{array}{ccccc}{\mathrm{Geonames \left(GeoNamesid\right)}}& {\mathrm{Name}}& {\mathrm{Type}}& {\dots }& {\mathrm{\left(7 more\right)}}\\ {\mathrm{4155751}}& {\mathrm{Florida}}& {"first-order administrative division"}& {\dots }& {}\\ {\mathrm{4197000}}& {\mathrm{Georgia}}& {"first-order administrative division"}& {\dots }& {}\\ {\mathrm{4361885}}& {\mathrm{Maryland}}& {"first-order administrative division"}& {\dots }& {}\\ {⋮}& {⋮}& {⋮}& {\ddots }& {}\\ {\mathrm{\left(18 more\right)}}& {}& {}& {}& {}\end{array}\right]$ (1.4)

WorldMap

The WorldMap object under the Builtin subpackage of the DataSets package is new to Maple 2017. It is a versatile map-displaying tool that can cooperate with the GeoNames data set as well as work alone.

The WorldMap object can provide visualization for search results from the GeoNames data set. For example, to generate a map of regions of Austria, first search for the data using the GeoNames data set and then create a WorldMap object using the search results:

 ${\mathrm{regionsOfAustria}}{≔}\left[\begin{array}{ccccc}{\mathrm{Geonames \left(GeoNamesid\right)}}& {\mathrm{Name}}& {\mathrm{Type}}& {\dots }& {\mathrm{\left(7 more\right)}}\\ {\mathrm{2761367}}& {\mathrm{Wien}}& {"first-order administrative division"}& {\dots }& {}\\ {\mathrm{2762300}}& {\mathrm{Vorarlberg}}& {"first-order administrative division"}& {\dots }& {}\\ {\mathrm{2763586}}& {\mathrm{Tirol}}& {"first-order administrative division"}& {\dots }& {}\\ {⋮}& {⋮}& {⋮}& {\ddots }& {}\\ {\mathrm{\left(6 more\right)}}& {}& {}& {}& {}\end{array}\right]$ (2.1)

$\mathrm{regionsOfAustriaMap}≔\mathrm{WorldMap}\left(\mathrm{regionsOfAustria}\right)$

 ${\mathrm{regionsOfAustriaMap}}{≔}\left(\begin{array}{cc}\left[{\mathrm{PLOT}}{}\left({\mathrm{...}}\right)\right]& \begin{array}{c}{\mathrm{A map of the world with 9 points}}\\ {\mathrm{projection: MillerCylindrical}}\end{array}\end{array}\right)$ (2.2)

Then, plot the map by calling the Display command on the WorldMap object:

The WorldMap object can display great circle paths, which are the shortest paths along the earth's surface between two geographic locations.

For example, connect all capital cities in the world with population greater than 8 million in a loop:

$\mathrm{bigPopulationCapitals}≔\mathrm{Reference}\left("Geonames"\right)\left[\left[\mathrm{Type}="capital of a political entity",\mathrm{Population}>8000000\right]\right]$

 ${\mathrm{bigPopulationCapitals}}{≔}\left[\begin{array}{ccccc}{\mathrm{Geonames \left(GeoNamesid\right)}}& {\mathrm{Name}}& {\mathrm{Type}}& {\dots }& {\mathrm{\left(7 more\right)}}\\ {\mathrm{524901}}& {\mathrm{Moscow}}& {"capital of a political entity"}& {\dots }& {}\\ {\mathrm{1185241}}& {\mathrm{Dhaka}}& {"capital of a political entity"}& {\dots }& {}\\ {\mathrm{1642911}}& {\mathrm{Jakarta}}& {"capital of a political entity"}& {\dots }& {}\\ {⋮}& {⋮}& {⋮}& {\ddots }& {}\\ {\mathrm{\left(6 more\right)}}& {}& {}& {}& {}\end{array}\right]$ (2.3)

$\mathrm{bigPopulationCapitalsMap}≔\mathrm{WorldMap}\left(\mathrm{bigPopulationCapitals}\right):$

$\mathrm{seq}\left(\mathrm{AddPath}\left(\mathrm{bigPopulationCapitalsMap},\mathrm{bigPopulationCapitals}\left[i\right],\mathrm{bigPopulationCapitals}\left[\mathrm{modp}\left(i,\mathrm{CountRows}\left(\mathrm{bigPopulationCapitals}\right)\right)+1\right],\mathrm{endpoint}=\mathrm{false}\right),i=1..\mathrm{CountRows}\left(\mathrm{bigPopulationCapitals}\right)\right):$

$\mathrm{SetCenter}\left(\mathrm{bigPopulationCapitalsMap},\left[0,0\right]\right):$

$\mathrm{ZoomOut}\left(\mathrm{bigPopulationCapitalsMap}\right):$

The WorldMap object can display maps under numerous map projections. Some projections are suitable for the type of data visualization presented in previous examples while others make maps themselves interesting and charming to look at. For the complete list of supported map projections, see the List of Projections help page.

$m≔\mathrm{WorldMap}\left(\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}$

 ${m}{≔}\left(\begin{array}{cc}\left[{\mathrm{PLOT}}{}\left({\mathrm{...}}\right)\right]& \begin{array}{c}{\mathrm{A map of the world}}\\ {\mathrm{projection: MillerCylindrical}}\end{array}\end{array}\right)$ (2.4)

For example, to generate a world map in the Van der Grinten projection, call the Display command on $m$ with the projection=VanderGrinten option:

$\mathrm{Display}\left(m,\mathrm{projection}=\mathrm{VanderGrinten},\mathrm{size}=\left[600,600\right]\right)$

For parameterized map projections, using Display together with the Explore command, you can easily see how the map transforms with respect to changes in the parameters.

For example, the Bottomley projection accepts a standard parallel ($\mathrm{φ1}$) parameter which makes it vary between the sinusoidal projection ($\mathrm{φ1}=0$) and the Werner projection ($\mathrm{φ1}=90$).

Use Explore to see this transformation:

The WorldMap object can also highlight the countries of the world based on a set of data using the ChoroplethMap command. The example below shows the countries colored based on their coastline length.

 ${\mathrm{coastlines}}{≔}\left[\begin{array}{cc}{\mathrm{Country \left(Name\right)}}& {\mathrm{Coastline}}\\ {\mathrm{Afghanistan}}& {0}\\ {\mathrm{Albania}}& {362.}{}⟦{\mathrm{km}}⟧\\ {\mathrm{Algeria}}& {998.}{}⟦{\mathrm{km}}⟧\\ {⋮}& {⋮}\\ {\mathrm{\left(182 more\right)}}& {}\end{array}\right]$ (2.5)

Many countries have coastline length 0, so taking the logarithm would yield minus infinity. Instead, we add 1 to each coastline length before taking the logarithm.

Another example for choropleth maps can be found here: Visualizing Custom Data on a Choropleth Map