Spatial analysis recipes
Now that we have a full set of geospatial analysis libraries available to us, let's see how we can use them to solve some real-world problems. We will look at how we can calculate and work with locations, lengths, and areas, as well as how we can use NetworkX to calculate the shortest available path between two points.
Calculating and comparing coordinates
As we saw earlier, PyProj can be used to calculate the real-world distance between two locations. It can also be used to measure the angle of a line going between two points, and calculate new points based on a starting point, a distance, and a heading.
Let's use PyProj to calculate the distance between two points. We will then use it to calculate a location at a certain distance and heading from a given point.
Start by creating a new Python program named coord_analysis.py
. Enter the following code into the start of this program:
import pyproj geod = pyproj.Geod(ellps="WGS84")
So far, this is identical...