Company Blog

SCIENCE - TECHNOLOGY - SOLUTIONS

Google Maps Engine: Python Basics - Part 2

A few weeks ago I posted regarding the basics of terminology and authentication for Google Maps Engine (GME) via the Python API.  In this post we will cover the installation of the API, including verification of dependencies.  This is one lesson that I learned the hard way, so hopefully I can make it a little easier on you.

To begin let's look at the API architecture and try to understand the core dependencies.  This will help us out in debugging our installation and use.  The PyDoc documentation of the API is a good place to start (http://google-api-python-client.googlecode.com/hg/docs/epy/frames.html).  As documented in the previous link, here are some of the dependencies to be aware of.

  1. Python 2.7 or higher is suggested
  2. pyOpenSSL is required
    1. Subdependencies include libcffi in order to be able to install Cryptography
  3. pyCrypto is required

Depending on your operating system there are different ways to install the API.  For Linux and Mac, make sure you have a current installation of Setuptools or pip.  Then execute the following;

easy_install --upgrade google-api-python-client

OR

pip install --upgrade google-api-python-client

For Microsoft Windows;
  1. Download the API from here.
  2. Unzip the package to a location where you have rights
  3. Open a command prompt and navigate to the new directory
  4. Execute python setup.py install
To test your installation, open a Python prompt and execute the following;
from oauth2client.client import SignedJwtAssertionCredentials

If this returns an error, you most likely have a problem with your pyOpenSSL configuration.  Go here to start to debug problems with the pyOpenSSL installation.

Otherwise you have successfully installed the API and are now ready to proceed with setup your code.

In part 3, we will cover the actual code and the required elements to interface with GME.

Accuracy Standards and Statistical Tests

As part of a recent project, I had to do some research on accuracy, standards, and methods of assessing accuracy.  The following paragraphs are the results of that research.

Horizontal Accuracy Tests

There are several horizontal accuracy tests, but the most prominent are the Circular Error of 90%, the Root Mean Square Error, and 1 Sigma.  The following describes each of these methods.

CE90

Circular Error of 90% (CE90) is commonly used for quoting and validating geodetic image registration accuracy.  A CE90 value is the minimum diameter of the horizontal circle that can be centered on all photo-identifiable Ground Control Points (GCPs) and also contain 90% of their respective twin counterparts acquired in an independent geodetic survey.  It can be stated as the radial error which 90% of all errors in a circular distribution will not exceed.  Circular error may be defined as the circle radius, R, that satisfies the conditions of the equation below, where C.L. is the desired confidence level (Ross, 2004).

 

Equation 1 - CE90 (Greenwalt and Shultz, 1962)



RMSE

RMSE is commonly used for quoting and validating geodetic image registration accuracy. A RMSE value is a single summary statistic that describes the square-root of the mean horizontal distance between all photo-identifiable GCPs and their respective twin counterparts acquired in an independent geodetic survey. 

 

RMSE is the square root of the average of the set of squared differences between dataset coordinate values and coordinate values from an independent source of higher accuracy for identical points. Accuracy is reported in ground distances at the 95% confidence level. Accuracy reported at the 95% confidence level means that 95% of the positions in the dataset will have an error with respect to true ground position that is equal to or smaller than the reported accuracy value. The reported accuracy value reflects all uncertainties, including those introduced by geodetic control coordinates, compilation, and final computation of ground coordinate values in the product (FGDC, 1998). 

 

Equation 2 - RMSE 1 Dimensional (Ross, 2004)


Equation 3 - RMSE 2 Dimensional (Ross, 2004)


1-Sigma

1-Sigma (Standard Deviation Error) is used for quoting and validating geodetic image registration accuracy.  1-Sigma is the minimum diameter of the horizontal circle that, when centered on all of the photo-identifiable GCPs, would contain one Standard Deviation (i.e.: ~68%) of the population of all available twin counterparts acquired in an independent geodetic survey.  This is provided that the GCP population is sufficiently large for their relationship to be "normally" distributed.

 

Accuracy Standards

For the use of geographic data to be consistent and dependable there must be standards.  Standards exist to ensure that the experience is the same, regardless of location, when using geographic data and to allow for the better use of different datasets in conjunction with one another.  They must provide a foundation in which expectations can be measured.  The following standards are the most prevalently referred to for aerial photography and photogrammetry currently today.

NMAS

The National Map Accuracy Standards were published in 1941 by the U.S. Bureau of the Budget in an attempt to provide a foundation for maps that were being generated throughout the U.S.  The document was surprisingly short and was only revised twice since then in 1943 and in 1947.  The portions of the document that are relevant to this assessment are as follows (U.S. BUREAU OF THE BUDGET, 1947):


“Horizontal accuracy. For maps on publication scales larger than 1:20,000, not more than 10 percent of the points tested shall be in error by more than 1/30 inch, measured on the publication scale; for maps on publication scales of 1:20,000 or smaller, 1/50 inch. These limits of accuracy shall apply in all cases to positions of well-defined points only. Well-defined points are those that are easily visible or recoverable on the ground, such as the following: monuments or markers, such as bench marks, property boundary monuments; intersections of roads, railroads, etc.; corners of large buildings or structures (or center points of small buildings); etc. In general what is well defined will be determined by what is plottable on the scale of the map within 1/100 inch. Thus while the intersection of two road or property lines meeting at right angles would come within a sensible interpretation, identification of the intersection of such lines meeting at an acute angle would obviously not be practicable within 1/100 inch. Similarly, features not identifiable upon the ground within close limits are not to be considered as test points within the limits quoted, even though their positions may be scaled closely upon the map. In this class would come timber lines, soil boundaries, etc.”

“The accuracy of any map may be tested by comparing the positions of points whose locations or elevations are shown upon it with corresponding positions as determined by surveys of a higher accuracy. Tests shall be made by the producing agency, which shall also determine which of its maps are to be tested, and the extent of the testing.”

ASPRS

The American Society for Photogrammetry and Remote Sensing (ASPRS) created these standards in July of 1990 in a report title “ASPRS Accuracy Standards for Large-Scale Maps”.  These standards were a response to the need for scale-independent accuracy standards.

The ASPRS standards explicitly used the statistical term, Root Mean Square Error (RMSE), and described a method of testing and reporting that related this more modern statistical language to map classes and contour intervals (ASPRS, 1990).

Table 2 - ASPRS Standards for Maps in Feet (ASPRS, 1990)

 

RMSE

Map Scale

Class I

Class II

Class III

1:60

0.05

0.1

0.2

1:120

0.1

0.2

0.3

1:240

0.2

0.4

0.6

1:360

0.3

0.6

0.9

1:480

0.4

0.8

1.2

1:600

0.5

1.0

1.5

1:1200

1.0

2.0

3.0

1:2400

2.0

4.0

6.0

1:4800

4.0

8.0

12.0

1:6000

5.0

10.0

15.0

1:9600

8.0

16.0

24.0

1:12000

10.0

20.0

30.0

1:20000

16.7

33.4

50.1

 

 

NSSDA

The National Standard for Spatial Data Accuracy (NSSDA) implements a statistic and testing methodology for positional accuracy of maps and geospatial data derived from sources such as aerial photographs, satellite imagery, or maps. Accuracy is reported in ground units. The testing methodology is comparison of data set coordinate values with coordinate values from a higher accuracy source for points that represent features readily visible or recoverable from the ground. While this standard evaluates positional accuracy at points, it applies to geospatial data sets that contain point, vector, or raster spatial objects. Data content standards, such as FGDC Standards for Digital Orthoimagery and Digital Elevation Data, will adapt the NSSDA for particular spatial object representations.

The standard insures flexibility and inclusiveness by omitting accuracy metrics, or threshold values, that data must achieve. However, agencies are encouraged to establish "pass-fail" criteria for their product standards and applications and for contracting purposes. Ultimately, users must identify acceptable accuracies for their applications (FGDC, 2008).


 References
ASPRS. 1990. “ASPRS ACCURACY STANDARDS FOR LARGE-SCALE MAPS”. The American Society for Photogrammetry and Remote Sensing. http://www.asprs.org/a/society/committees/standards/1990_jul_1068-1070.pdf.

Congalton, R.G., and K. Green. 2008. Assessing the Accuracy of Remotely Sensed Data: Principles and Practices, Second Edition. Mapping Science. Taylor & Francis. http://books.google.com/books?id=T4zj2bnGldEC.

Edgar Falkner, and Dennis Morgan. 2002. Aerial Mapping: Methods and Applications, Second Edition. http://gis-lab.info/docs/books/aerial-mapping/cr1557_08.pdf.

FGDC. 1998. “Geospatial Positioning Accuracy Standards Part 3: National Standard for Spatial Data Accuracy”. Federal Geographic Data Committee. https://www.fgdc.gov/standards/projects/FGDC-standards-projects/accuracy/part3/chapter3.

FGDC. 2008. “Geospatial Positioning Accuracy Standards, Part 3: National Standard for Spatial Data Accuracy — Federal Geographic Data Committee.” August 19. https://www.fgdc.gov/standards/projects/FGDC-standards-projects/accuracy/part3.

“Geospatial Positioning Accuracy Standards, Part 3: National Standard for Spatial Data Accuracy — Federal Geographic Data Committee.” 2014. Accessed March 2. https://www.fgdc.gov/standards/projects/FGDC-standards-projects/accuracy/part3.

Greenwalt, Clyde R, and Melvin E Shultz. 1962. Principles of Error Theory and Cartographic Applications.

Karen Schuckman, and Mike Renslow. 2014. “Accuracy Standards”. The Pennsylvania State University. https://www.e-education.psu.edu/lidar/l6_p7.html.

Kenton Ross. 2004. “Geopositional Statistical Methods” presented at the High Spatial Resolution Commercial Imagery Workshop, November 8, Reston, Virginia. http://calval.cr.usgs.gov/JACIE_files/JACIE04/files/1Ross16.pdf.

U.S. BUREAU OF THE BUDGET. 1947. “USGS - National Geospatial Data Standards - United States National Map Accuracy Standards.” http://nationalmap.gov/standards/nmas647.html.

“USGS - National Geospatial Data Standards - United States National Map Accuracy Standards.” 2014. Accessed March 2. http://nationalmap.gov/standards/nmas647.html.

Google Maps Engine: Python Basics - Part 1

In case you haven't heard of it, Google has been working on a project for a little over a year or so call Google Maps Engine (GME).  GME is a really powerful cloud-based mapping system that is maturing at a really nice pace.  One of the nice features about it is its accessibility via multiple API's.  One of those API's is Python.  There are some pretty good tutorials (https://developers.google.com/maps-engine/documentation/tutorial) and documentation including an API reference with some examples (https://developers.google.com/maps-engine/documentation/reference/v1/).

However, one thing that is a little lacking is documentation on how the OAuth2 authentication protocol is leveraged in Python.  I have to admit that I struggled some here until I was aided by my friend at Google, Sean Wohltman.  So Sean, much thanks for all your help and guidance.

Before we begin, there is one thing that you must understand to make sure we are consistent in our references, that is the terminology (https://developers.google.com/maps-engine/documentation/definitions).



So with this as the foundation of the discussion, we can loosely refer to these as the accessible objects through the API.

The approach to for the purposes of this article are relatively simple.  We will authenticate and then we will retrieve a collection of each of the objects.  This will demonstrate the core functionality that we have through the Python API.

To start the process of authentication, let's first refer to some of the basics in documentation.



Now that we have a basic understanding of the OAuth2 protocol, you can get the API downloaded and installed.  The Google APIs Client Library for Python is located at (https://code.google.com/p/google-api-python-client/downloads/list).

In Part 2 of this series we will cover the set up and use of the API in Python.

Safe Schools: Indoor Google StreetView

With the Virtual Alabama School Safety Systems (VAS3), there are multiple projects going simultaneously.  One of these projects is the "Indoor Google StreetView" project.  This project includes the creation of "walk throughs" of rooms and hallways through the building.

The process begins with the collection of photos using a very specific device.  This camera system allows for the remote triggering via wifi and download of captured photographs to a user's cell phone or tablet.  The transferred files are automatically stitched together to produce a high quality panoramic image.  Here is a sample of the raw output from our camera system.


Source Image Post Stitching

The next step include the mapping of the positions of where each set of images were captured.  This is done using a mapping interface designed and developed by my team we call the Floor Plan Annotation Tool (FPAT).


Floor Plan Annotation Tool (FPAT)

In the FPAT we are able to actually generate the tiles needed for ingestion into Google StreetView using the "360 View Manager" module by selecting the panoramic image and queue it for tiling.  The tiled Google StreetView dataset is then associated to each point on the map, therefore completing the process.

The following is an example of a final product from the process.