18 | Geocomputation |
The Wolfram Language has extensive built-in knowledge of geography. For example, it knows where New York City is, and it can compute how far it is from there to Los Angeles.
Compute the distance between New York and Los Angeles:
GeoDistance[Entity["City", {"NewYork", "NewYork", "UnitedStates"}],
Entity["City", {"LosAngeles", "California", "UnitedStates"}]]
You can also plot locations on a map, using GeoListPlot.
Plot New York and Los Angeles on a map:
GeoListPlot[{Entity["City", {"NewYork", "NewYork", "UnitedStates"}],
Entity["City", {"LosAngeles", "California", "UnitedStates"}]}]
Plot countries on a map:
GeoListPlot[{Entity["Country", "Iceland"],
Entity["Country", "France"], Entity["Country", "Italy"]}]
Plot two famous locations in Paris:
GeoListPlot[{Entity["Building", "EiffelTower::5h9w8"],
Entity["Building", "TheLouvre::vqy3g"]}]
Generate a map of New York City:
GeoGraphics[Entity["City", {"NewYork", "NewYork", "UnitedStates"}]]
GeoPath represents a path on the surface of the Earth.
Show the shortest path from New York to Tokyo:
GeoGraphics[
GeoPath[{Entity["City", {"NewYork", "NewYork", "UnitedStates"}],
Entity["City", {"Tokyo", "Tokyo", "Japan"}]}]]
Styling works just like in other graphics:
GeoGraphics[
Style[GeoPath[{Entity[
"City", {"NewYork", "NewYork", "UnitedStates"}],
Entity["City", {"Tokyo", "Tokyo", "Japan"}]}], Thick, Red]]
Show a 1-mile-radius disk around the Eiffel Tower:
GeoGraphics[
GeoDisk[Entity["Building", "EiffelTower::5h9w8"],
Quantity[1, "Miles"]]]
Table[GeoGraphics[
GeoDisk[Entity["Building", "EiffelTower::5h9w8"],
Quantity[0.1, "Miles"]*10^n]], {n, 0, 4}]
GeoImage gives satellite images:
GeoImage[
GeoDisk[Entity["Building", "TheWhiteHouse::7q2yf"],
Quantity[0.1, "Miles"]]]
GeoPosition gives a position on the Earth. The numbers it contains are longitude and latitude—the standard coordinates on the surface of the Earth.
Find the geo position of the Eiffel Tower:
GeoPosition[Entity["Building", "EiffelTower::5h9w8"]]
Draw a 4000-mile-radius disk around 0 latitude, 0 longitude:
GeoGraphics[GeoDisk[GeoPosition[{0, 0}], Quantity[4000, "Miles"]]]
Notice that the disk isn’t quite circular. That’s because we have to use a projection to draw the surface of the Earth on a flat map. It’s one of the many subtleties in doing geocomputation.
GeoNearest finds what’s nearest to a given place on the Earth. You tell it what type of thing to look for, and how many you want it to find.
Find the nearest 5 countries to 0 longitude, 0 latitude:
GeoNearest["Country", GeoPosition[{0, 0}], 5]
Find the nearest cities instead:
GeoNearest["City", GeoPosition[{0, 0}], 5]
It’s often nice to know your own geo position. So long as your computer, phone, etc. knows, Here will give you that.
Find where your computer (or phone, etc.) thinks it is:
Here
You can do computations with Here.
Compute how far it is to the Eiffel Tower:
GeoDistance[Here, Entity["Building", "EiffelTower::5h9w8"]]
Find the nearest 5 volcanoes to my position:
GeoNearest["Volcano", Here, 5]
GeoListPlot[GeoNearest["Volcano", Here, 30]]
GeoDistance[entity1,entity2] | geo distance between entities | |
GeoListPlot[{entity1,entity2, ...}] | plot a list of entities on a map | |
GeoGraphics[...] | map constructed from primitives | |
GeoPath[{entity1,entity2}] | path between entities | |
GeoDisk[entity,r] | disk with radius r around an entity | |
GeoImage[...] | satellite image | |
Here | where your computer, phone, etc. thinks it is | |
GeoPosition[entity] | geo position of an entity | |
GeoNearest["type",location,n] | nearest n objects of a certain type to a location |
18.1Find the distance from New York to London. »
18.2Divide the distance from New York to London by the distance from New York to San Francisco. »
18.3Find the distance from Sydney to Moscow in kilometers. »
18.4Generate a map of the United States. »
18.5Plot on a map Brazil, Russia, India and China. »
18.6Plot on a map the path from New York City to Beijing. »
18.7Plot a disk centered on the Great Pyramid, with radius 10 miles. »
18.8Plot a disk centered on New York with a radius large enough to just reach San Francisco. »
18.9Make a satellite image of 0.4 miles around the Pentagon. »
18.12Plot the 25 volcanoes closest to Rome. »
18.13Find the difference in latitude between New York and Los Angeles. »
+18.1Plot on a map the countries in NATO. »
+18.2Plot on a map a thick red line from Moscow to Beijing and a thick blue line from Washington, DC to London. »
+18.3Find the distance from 0 latitude, 0 longitude to the Eiffel Tower. »
+18.4Plot a disk styled red of radius 100 miles centered on Los Angeles. »
+18.5Make a list of plots showing disks with radii 1, 2 and 3 miles around the Empire State Building. »
+18.6Find the 5 countries nearest to New York City. »
+18.7Find the nearest ocean to Chicago. »
Can I get different projections for maps?
Yes. Just use the GeoProjection option. There are more than 300 built-in projections to choose from. The default projection used in any particular case depends on the scale and location of the map.
How detailed are the maps in the Wolfram Language?
They go down to the level of individual streets. Most streets in the world are included.
Can I choose features other than streets to show in my maps?
Yes. The option GeoBackground can for example specify "ReliefMap" or "Satellite", as discussed in Section 20.
How detailed are the highest-resolution satellite images in the Wolfram Language?
In most parts of the world you’ll easily be able to see individual cars, and people will show up as dots.
How does the Wolfram Language find my geo position?
It uses the function FindGeoLocation. On a mobile device, this will normally ask for your GPS position. On a computer, it’ll normally try to deduce your location from your internet address—this won’t always work correctly. You can always explicitly set your geo location by assigning a value to $GeoLocation.
How can I specify the range of a map?
Use the option GeoRangedistance (e.g. GeoRange) or GeoRangeplace (e.g. GeoRange), as discussed in Section 20.
Can the Wolfram Language compute driving directions?
Yes. Use TravelDirections. GeoDistance gives the direct shortest path; TravelDistance gives the path following roads, etc. TravelTime gives estimated travel time.
Is the Wolfram Language restricted to maps of the Earth?
- You need to be connected to the network to use maps in the Wolfram Language.
- Instead of entering , you can just enter and get the same result.
- If you give GeoDistance extended regions (like countries and larger cities), it’ll compute the shortest distance between any points in the regions.
- GeoPosition uses numerical values of longitude and latitude, not 35 Degree, etc.
- GeoPosition normally uses decimal degrees. Use FromDMS to convert from degrees-minutes-seconds.
- To color regions on a map by values, use GeoRegionValuePlot.
- To draw bubbles of different sizes around points on a map (e.g. populations of cities), use GeoBubbleChart.