Geographic location plays a vital role in a variety of socioeconomic and environmental decisions, such as in selecting sites for new businesses or providing location-based services [1, 2]; detecting, valuing, and defining protected marine areas [3]; locating prospective areas for grid-connected offshore wind power development [3]; identifying disease-prone areas [4]; responding to crime and natural hazards; and locating customer-friendly shopping malls [5]. Geocoding, the process of assigning coordinates (latitude and longitude) to a physical location, has helped various industries improve performance through spatial analysis [6, 7]. However, the accuracy and reliability of geocoded results have always been a matter of concern among the geospatial analytics community [4, 7,8,9,10]. Senaratne et al. (2017) provide a detailed review of the various methods applied in assessment of the quality of locational analytics. The authors report that accuracy measurement is the most frequent and reliable technique currently in practice [11]. They define accuracy as the degree of closeness between measured and actual values, noting that it may vary with use of various geocoding tools [11]. Geocoding is highly prone to error for various reasons, including lack of coverage (local vs. global); lack of complete, correct, consistent, and updated reference databases; and the making of inappropriate assumptions [7, 9, 10, 12, 13]. All these may affect match rate and positional accuracy [7]. Additionally, incorrect geocoding may bias the results of spatial analysis, resulting in misclassification of actual physical locations that may adversely affect research outcomes or location-based business decisions [14, 15]. Accordingly, understanding and addressing these geocoding challenges is vital [16]. Yet geocoding processes and error handling have been largely ignored in some studies [14, 15].

Various subscription-based and freely available geocoding tools can be used for batch geocoding of physical locations (Table 1) [17]. All these service providers use different reference databases, geocoding algorithms, address parsing, approaches, and inaccuracy reporting methods [8, 9]. Consequently, the likelihood of differences in geocoded results is high [8, 9].

Table 1 A non-exhaustive list of geocoding services (Adapted from [17])

Several studies have offered a comparative analysis of various free or subscription-based geocoding services. For example, Karimi et al. [13] have evaluated the matching rate of geocoded addresses using web-based geocoding services, including Virtual Earth, Google Maps,, MapQuest, and Yahoo Maps. In contrast, Swift and his team members [18] assessed seven commercial geocoding services and one open-source geocoding service—Centrus, Geolytics, ERSI Address Locator,, Google Earth, Google Maps API, and the Yahoo API and USC Geocoding Platforms, respectively—to match accurately geocoded addresses. The authors selected 50 addresses for this purpose and found that only 42% of samples matched their reference data, 54% of addresses matched parcel centroids, and only 4% addresses matched USPS ZIP code centroids [18]. All the geocoding tools tested produced varying results, indicating that analysts should indeed take care when geocoding physical locations, especially when doing so for purposes of location-based analysis, and should take that same care when selecting geocoding tools in the first place.

This study compares the use of two commonly used free geocoding tools for research and business purposes: Google Sheets, which is a Google offering, and ggmap, which is an R package. No comparison of these tools has yet appeared in mainstream journals.

ggmap is one of the most widely used geospatial R packages in a variety of domains. For example, it was used to geocode helminth (nematodes popularly known as roundworms) host–parasite interactions that helped establish the London Natural History Museum’s Host–Parasite Database [19]; was used in a big-data environment to geocode customer movements from homes to shopping centers [20]; and was used to site locations for implementation of a U.S. federal program offering families and children healthful foods during the summer months, administered by the U.S. Department of Agriculture [21]. Google Sheets, or Google Spreadsheets, by contrast, has gained little attention among geospatial analytics communities, even though it has been applied to an array of domains, such as in the geocoding of socioeconomic historical data for visualization of urban geographies [22] and in the public health domain [23, 24]. Google Sheets provides advantages not seen in ggmap, because it does not require coding and is a web-based application. By contrast, ggmap runs through the RStudio software and requires a sequence of queries; even so, it is widely used and accepted by researchers and professionals the world over.


Data collection

For testing purposes, a publicly available list of Center of Excellence–awarded restaurants in California was downloaded from the website of the Public Health Care Agency of Orange County [25]. In 2016, fully 3631 restaurants were recognized as a Center of Excellence for their performance in 2015. The list contains each restaurant’s name, address, city, and ZIP code. Because use of both Google Sheets and R is subject to a maximum geocoding limit per day, only 200 of these 3631 restaurants were selected for geocoding purposes in this study. Moreover, this study seeks to compare the accuracy of geocoded results produced by two popular geocoding tools while providing a stepwise method of resolving geocoding challenges: because visual verification of individual address is a tedious task, a small sample size—but larger than that used by Swift et al. (2008)—was selected. Because the selection was purely for research purposes, no priority was given to any specific restaurant chain. The 200 addresses were stored as address.csv for further analysis.

Geocoding using Google sheets and the RStudio ggmap package

Google Sheets is a free web-based application, developed by Google for real-time online document editing while collaborating with other users [26]. Several blog articles and tutorial videos are available that instruct users in the steps used for geocoding physical locations through Google Sheets, such as one available through GitHub, which was adapted for this study [27].

R is one of the most widely used statistical and visualization open-source tools [28, 29], with more than 6000 packages [30] contributed by thousands of authors across the world. Ggmap, a bundle of 34 functions, is a spatial data modeling and visualization R package [31]. This package uses Google and Stamen Maps as reference sources for geocoding and mapping. The codes used in this study are adapted from Shane Lynn [32]. Most are kept intact for reproducibility, and the code used is available in geocode_2016.R and geocode_2016.txt, accessible through this article.

Distance calculation in RStudio using the geosphere package

After geocoding all addresses using Google Sheets and ggmap, distances between coordinates having the same locations were calculated to validate the geocoding results, using the geosphere package. Geosphere, a recently developed spatial analytics R package, combines 40 functions developed for calculation of various aspects of distance, direction, and area when dealing with geographic coordinates [33]. The distHaversine function of the geosphere package was used for distance calculation. This function measures the shortest distance between two geographic coordinates, also known as the “great-circle distance” or distance measured “as the crow flies” [33]. The advantage of this method is that it assumes a spherical earth, ignoring ellipsoidal effects [33]. It accepts data in a specific format only: coordinates, with the first column of the input file corresponding to longitude and the second to latitude [33]. This method produces distance in meters, taking Earth’s radius to be 6,378,137 m [33]. The original code was modified to produce results in miles instead of meters. The modified output data for Google Sheets and ggmap is stored as gsheets.csv and ggplot.csv, respectively. A stepwise method of assessing geographical inconsistencies of geocoding errors is presented through a flow diagram (Fig. 1).

Fig. 1
figure 1

A stepwise method of geocoding and analyzing geographical inconsistencies of geocoded results

Descriptive statistics in RStudio using the pastecs package

Descriptive statistical analysis of the distance calculated between the geocoded locations produced by Google Sheets and those produced by ggmap was performed using the pastecs R package [34]. The stat.desc function of pastecs quantifies various descriptive statistics, including number of variables, null values, NAs, minimum, maximum, range, sum, median, mean, standard error of the mean, confidence interval of the mean, variance, standard deviation, and coefficient of variance [34]. In the results, only a few required outputs are presented and discussed.

GIS mapping

The Arc Geographical Information System (ArcGIS) has seen much use in spatial analytics and modeling in different perspectives and is one of the most advanced and reliable geospatial analytical tools available [35,36,37]. However, QGIS, an open-source GIS tool, has become very popular in the field of geospatial analytics [38]. In this study, QGIS is used to plot geocoded locations on a map using QGIS version 2.18.2 for the Windows environment [38]. Within the QGIS environment, the open layers plugin provides options for selecting Google Maps and OSM as base maps on which to plot geocoded locations. These locations were plotted on Google Maps and OSM for visualization, comparison, and validation. Google Earth, a freeware virtual globe, map, and geographical information program that offers various mapping facilities and that is one of the most reliable geocoding tools available, was also used to investigate locational accuracy [39]. Google Earth has a street view option, which provides a 360° horizontal and 290° vertical panoramic view at the street level from a height of about 2.5 m [39]. These help users verify actual locations by zooming to the street level.

Results and discussion

Geocoded outputs from Google sheets and ggmap

Google Sheets and ggmap were able to geocode all 200 addresses without error. The number of geocoded addresses was within the limit of 2500 instances per day for both tools; see google-sheets_ggmap_geocoded.csv for their outputs. Unlike Google Sheets, however, ggplot provides additional information on the accuracy level of the geocoded locations (google-sheets_ggmap_geocoded.csv). Most (82%) addresses were found to be geocoded with street address–level accuracy (Table 2). Twenty-two of 200 addresses were found to be accurate at the sub-premise level, with seven pointing to the nearest bus station, two to the locality, and one to the campground level (Table 2).

Table 2 The accuracy level of geocoded addresses produced by ggmap

The geocoded addresses produced by Google Sheets and ggmap were compared by calculating the differences between the latitudes and the differences between the longitudes produced by Google Sheets and ggmap. The geocoded addresses matched in only 53% (107 of 200) cases. The minimum difference between the results produced by Google Sheets and those produced by ggmap was −0.00011 degrees of latitude and −35.65284 degrees of longitude. The maximum difference was 4.29319 degrees of latitude and 0.00016 degrees of longitude, with a standard deviation of 0.76 degrees of latitude and 6.60 degree of longitude. Furthermore, the geocoded addresses produced by ggmap exactly matched Google Sheets outputs in only 56% (92 of 165) of instances involving street address–level accuracy, 45% (10 of 22) of instances involving sub-premise-level accuracy, and 100% of instances involving either campground-level (1 of 1) or bus station–level (7 of 7) accuracy.

All 200 geolocations were visualized by means of a QGIS map (Fig. 2). The purple symbols indicate ggmap-geocoded locations and the orange symbols Google Sheets–geocoded locations (Fig. 2-a). Overlapping symbols indicate an exact match in geocoded location. Non-matched locations are distinctive on the map (Fig. 2-b). The biggest failure of ggmap geocoding was in producing similar coordinates for seven addresses, all at the bus station level (google-sheets_ggmap_geocoded.csv, Table 2). Because of their similar coordinates, however, only one is visible on the map, in Florida (Fig. 2-c).

Fig. 2
figure 2

(a) All geocoded center of excellence restaurants in California; (b) Correctly geocoded center of excellence restaurants in California by Google Sheets and ggmap; (c) Incorrectly geocoded center of excellence restaurants in California by ggmap

These eight incorrectly geocoded addresses were further individually geocoded using ggmap. Surprisingly, ggmap produced similar results for seven addresses belonging to the same restaurant chain. These eight addresses were plotted using Google Maps and OSM to visualize their physical locations (Fig. 3). Both maps showed their locations in California, in their actual ZIP codes.

Fig. 3
figure 3

Eight incorrect addresses plotted on google map and OSM after correction

These eight locations were further individually plotted on Google Earth and zoomed to the street level to verify the degree of correspondence of geocoded location with actual location. Errors 1–7 were geocoded to the exact premises of the restaurant (Fig. 4). However, error 8 was located outside the premises of a hotel in which this restaurant likely operates.

Fig. 4
figure 4

Street view of the eight corrected locations on Google earth

Furthermore, the distance between the coordinates produced by Google Sheets and ggmap was calculated (in miles) in RStudio using the geosphere package, with a descriptive statistical summary produced (Table 3).

Table 3 A summary descriptive statistics of the distance between the coordinates

The maximum distance between coordinates of the same address was 2107.2 miles—from California to Florida (Fig. 2a and c). Although both Google Sheets and ggmap were able to successfully geocode all physical locations of these recipients of California’s Center of Excellence award, ggmap could not produce correct coordinates in a majority of cases. Because both tools use Google Maps as a reference, it is questionable whether they actually obtained different results. Accordingly, those addresses incorrectly geocoded—and, indeed, more than 2000 miles from their real locations—were revisited with an eye to identifying the cause of error. In doing so, it was found that all these addresses had one thing in common: their name included the ampersand character: &. (The names of these restaurants have here been replaced with “Restaurants” to protect the actual restaurants’ privacy.) The ampersand character was replaced with the word and in these addresses, and the corrected addresses were re-geocoded using ggmap, then the distance calculated between the incorrect and the corrected coordinates; the results are presented in Table 4.

Table 4 The geocoded addresses after replacing “&” with “and”

After correction of the addresses, all re-geocoded results matched Google Sheets outputs. Evidently, the use of even a single problematic character, the ampersand, can cause ggmap to produce incorrect outputs, assigning coordinates as far as 2000 miles from their real location.


Although the geocoding tools Google Sheets and ggmap use a common map reference, they produce varying results. In addition, specific formatting, free of problematic characters such as the ampersand, is required for correct geocoding by ggmap. Google Sheets, by contrast, features a user-friendly environment that does more to aid production of reliable geocoding results. Regardless, users of geocoding tools should not wholly rely on whichever tool they use but rather should always verify their results by the methods outlined in this study or by any other established approach. The visualizing of geocoded results on a map using QGIS, ArcGIS, Google Earth, OSM, or R can help in identifying and resolving potential challenges to accuracy. Certainly other factors not covered in this study could also produce erroneous geocoded results, so analysts should carefully evaluate their results and report them in detail, taking particular care when geocoding physical locations in bulk. This study seeks merely to compare the geocoding respective potentials of two freely available geocoding tools for research purposes, not to promote or undermine either of them. Reporting positional accuracy challenges and methods of resolving them can help users of geospatial analytics conduct efficient and accurate spatial analysis.