Creating a Shapefile from point data stored in Microsoft Excel
Excel files are so common these days that often an analyst or developer receives an Excel file that needs to be mapped out. Sure, we could save these to a .csv
file and then use the great Python standard csv module but this involves an extra manual step. We will take a look at how to read a very simple Excel file that contains a list of Europe's highest mountains. This data set is derived from http://www.geonames.org.
Getting ready
We are going to need one new Python library to read a Microsoft Excel file and this library is xlrd (http://www.python-excel.org).
Note
This library can only READ an Excel file; if you are looking to write out to an Excel file, download and install xlwt.
First, fire up you virtual environment from your workon pygeoan_cb
Linux machine, run pip install xlrd
, and you are off to the races.
To write out to a new Shapefile, we will use the pyshp library we installed in Chapter 1, Setting Up Your Geospatial Python...