Book Image

Python Geospatial Development - Third Edition

By : Erik Westra
Book Image

Python Geospatial Development - Third Edition

By: Erik Westra

Overview of this book

Geospatial development links your data to locations on the surface of the Earth. Writing geospatial programs involves tasks such as grouping data by location, storing and analyzing large amounts of spatial information, performing complex geospatial calculations, and drawing colorful interactive maps. In order to do this well, you’ll need appropriate tools and techniques, as well as a thorough understanding of geospatial concepts such as map projections, datums, and coordinate systems. This book provides an overview of the major geospatial concepts, data sources, and toolkits. It starts by showing you how to store and access spatial data using Python, how to perform a range of spatial calculations, and how to store spatial data in a database. Further on, the book teaches you how to build your own slippy map interface within a web application, and finishes with the detailed construction of a geospatial data editor using the GeoDjango framework. By the end of this book, you will be able to confidently use Python to write your own geospatial applications ranging from quick, one-off utilities to sophisticated web-based applications using maps and other geospatial data.
Table of Contents (20 chapters)
Python Geospatial Development Third Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Geospatial development


The term geospatial refers to finding information that is located on the earth's surface. This can include, for example, the position of a cellphone tower, the shape of a road, or the outline of a country:

Geospatial data often associates some piece of information with a particular location. For example, the following map, taken from http://opendata.zeit.de/nuclear-reactors-usa, shows how many people live within 50 miles of a nuclear reactor within the eastern United States:

Geospatial development is the process of writing computer programs that can access, manipulate, and display this type of information.

Internally, geospatial data is represented as a series of coordinates, often in the form of latitude and longitude values. Additional attributes, such as temperature, soil type, height, or the name of a landmark, are also often present. There can be many thousands (or even millions) of data points for a single set of geospatial data. For example, the following outline of New Zealand consists of almost 12,000 individual data points:

Because so much data is involved, it is common to store geospatial information within a database. A large part of this book will be concerned with how to store your geospatial information in a database and access it efficiently.

Geospatial data comes in many different forms. Different Geographical Information Systems vendors have produced their own file formats over the years, and various organizations have also defined their own standards. It is often necessary to use a Python library to read files in the correct format when importing geospatial data into your database.

Unfortunately, not all geospatial data points are compatible. Just like a distance value of 2.8 can have very different meanings depending on whether you are using kilometers or miles, a given coordinate value can represent any number of different points on the curved surface of the earth, depending on which projection has been used.

A projection is a way of representing the earth's surface in two dimensions. We will look at projections in more detail in Chapter 2, GIS, but for now, just keep in mind that every piece of geospatial data has a projection associated with it. To compare or combine two sets of geospatial data, it is often necessary to convert the data from one projection to another.

Note

Latitude and longitude values are sometimes referred to as unprojected coordinates. We'll learn more about this in the next chapter.

In addition to the prosaic tasks of importing geospatial data from various external file formats and translating data from one projection to another, geospatial data can also be manipulated to solve various interesting problems. Obvious examples include the task of calculating the distance between two points, calculating the length of a road, or finding all data points within a given radius of a selected point. We will be using Python libraries to solve all of these problems and more.

Finally, geospatial data by itself is not very interesting. A long list of coordinates tells you almost nothing; it isn't until those numbers are used to draw a picture that you can make sense of it. Drawing maps, placing data points onto a map, and allowing users to interact with maps are all important aspects of geospatial development. We will be looking at all of these in later chapters.