Geographic Data
Maple 2017 updates the DataSets package to include a built-in geographic information database and a map visualization facility.
GeoNames Dataset
WorldMap
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:
withDataSets:
withDataSets:-Builtin:
ref≔ReferenceGeoNames
ref≔Geonames (GeoNamesid)NameType…(7 more)68Boneh-ye Mehdisection of populated place…121Lab Sefidlocality…166Gorizilocality…⋮⋮⋮⋱(1087362 more)
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):
GetHeadersref
Name,Type,Latitude,Longitude,Country,Province/State/Region,City/County,Population,Time Zone
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:
GetDatarefCountry=Canada,Name=Waterloo
Waterloopopulated place45.3500799999999984−72.5158200000000051CanadaQuebecMonteregie4064America/TorontoWaterloopopulated place43.4667999999999992−80.5163900000000012CanadaOntarioundefined97475America/TorontoWaterloothird-order administrative division45.3367300000000029−72.5279599999999931CanadaQuebecMonteregieundefinedAmerica/Toronto
Find out which states in the US have population greater than 5 million:
refCountry=United States,Type=first-order administrative division,Population>5000000
Geonames (GeoNamesid)NameType…(7 more)4155751Floridafirst-order administrative division…4197000Georgiafirst-order administrative division…4361885Marylandfirst-order administrative division…⋮⋮⋮⋱(18 more)
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:
regionsOfAustria≔refCountry=Austria, Type=first-order administrative division;
regionsOfAustria≔Geonames (GeoNamesid)NameType…(7 more)2761367Wienfirst-order administrative division…2762300Vorarlbergfirst-order administrative division…2763586Tirolfirst-order administrative division…⋮⋮⋮⋱(6 more)
regionsOfAustriaMap≔WorldMapregionsOfAustria
regionsOfAustriaMap≔PLOT⁡...A map of the world with 9 pointsprojection: MillerCylindrical
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:
bigPopulationCapitals≔ReferenceGeonamesType=capital of a political entity,Population>8000000
bigPopulationCapitals≔Geonames (GeoNamesid)NameType…(7 more)524901Moscowcapital of a political entity…1185241Dhakacapital of a political entity…1642911Jakartacapital of a political entity…⋮⋮⋮⋱(6 more)
bigPopulationCapitalsMap≔WorldMapbigPopulationCapitals:
seqAddPathbigPopulationCapitalsMap,bigPopulationCapitalsi,bigPopulationCapitalsmodpi,CountRowsbigPopulationCapitals+1,endpoint=false,i=1..CountRowsbigPopulationCapitals:
SetCenterbigPopulationCapitalsMap,0,0:
ZoomOutbigPopulationCapitalsMap:
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≔WorldMap
m≔PLOT⁡...A map of the worldprojection: MillerCylindrical
For example, to generate a world map in the Van der Grinten projection, call the Display command on m with the projection=VanderGrinten option:
Display⁡m,projection=VanderGrinten,size=600,600
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 (φ1) parameter which makes it vary between the sinusoidal projection (φ1=0) and the Werner projection (φ1=90).
Use Explore to see this transformation:
Explore⁡Display⁡m,projection=Bottomleyφ1,grid=true, thickness=0,φ1=0..90,animate=true,size=600,600
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.
coastlines≔ ReferenceCountry .. , Coastline
coastlines≔Country (Name)CoastlineAfghanistan0Albania362.⁢kmAlgeria998.⁢km⋮⋮(182 more)
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
Download Help Document