Vector-based methods

There are two main categories of geospatial analysis and file types, vector and raster. Vectors are all about shapes, while rasters are more about grids. Vector is more common due to flexibility and efficient storage. Vectors can be defined simply by using a set of points. There are three main types of vector geometry:

  • Points: This can be defined in two or three dimensions. It is the common latitude, longitude pair you are probably very familiar with. The airport locations used in the R code previously are examples of points.
  • Lines or LineString: A LineString is defined by a set of points and order is important. More than one LineString can be stored together; in that case it is called, unsurprisingly, a MultiLineString. A river system or roadways network is an example of a MultiLineString. A file that contains a MultiLineString for the US Interstate roadways network can be downloaded from the University of Iowa GIS Library (ftp://ftp.igsb.uiowa.edu/gis_library/USA/us_interstates.htm). The following image is a visualization of that file:
The US Interstate system. Source: Environmental Systems Research Institute, Inc. (ESRI)
  • Polygon: A polygon is defined as a closed network of points. Order of the points is important and the starting point is also repeated as the ending point, thus closing out the shape. More than one polygon can be stored together, which is then called, you guessed it, a MultiPolygon. An example of this is a MultiPolygon representing the nation of Indonesia, which, according to the CIA World Factbook, consists of 13,466 islands:
A Multipolygon image of Indonesia

There are several Python packages developed for geospatial analytics. Two of the most popular related to vectors are shapely and fiona. Shapely has several computational geography algorithms while fiona interacts with vector files. You can install both packages using conda or pip install from the command line, as seen in the following code. Use conda install if you installed the Anaconda distribution:

conda install shapely

Or you can use the following:

pip install shapely

We will review some key vector concepts and the shapely code that implements them. There are many more than we cover here, but this should give you a good starting place. Use fiona to save the results into a file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.96.146