0

I am trying to geolocate a list of >1,000 of Indian institutions / NGOs / Universities etc. However, I only have the names and states of these. What I am looking for is an output that gives me

(1) a location in India

(2) some measure of how precise the search for the institution was, e.g. whether google maps had multiple results when searching for it

Unfortunately, at the moment my search did geocode many locations as being in the U.S., even though I added the state's name and "India" to the geocode call.

# load world map and packages
library("rnaturalearth")
library("rnaturalearthdata")
library("ggplot2")
world <- ne_countries(scale = "medium", returnclass = "sf")

# Sample Data
dta <-  data.frame(1:9) 
dta$name <- c("Arunodaya  Rural  Integrated  &  Social Education Society , Andhra Pradesh , India"  
 ,"Pathari Vocational Institute , Assam , India"
 ,"Mendu rural Devalopment Society , Andhra Pradesh , India"                            
 ,"Rural Health Care Development Society , Andhra Pradesh , India"                      
 ,"K.G.N.Voluntary Organisatin , Andhra Pradesh , India"                                
 ,"Prakashmay Sevashram , Bihar , India"                        
 ,"Integrity Explosion , Andhra Pradesh , India"                                        
 ,"Sri Prakash Vidyaniketan , Andhra Pradesh , India"                                   
,"Gayatri  Vidya  Parishad  College  of Engineering , Andhra Pradesh , India")

#--------

# geocode data using Google Maps (Indian extension)
geo <- geocode(dta$name, ext="co.in")
# remove missings
geo <- geo[!is.na(geo$lon),]

# plot data:
geo <- st_as_sf(geo, coords = c("lon","lat"))


st_crs(geo) <- st_crs(world)

# plot data
ggplot() +
  geom_sf(data = world) +
  geom_sf(data = geo)

The result:

0

1 Answer 1

0

I tried with tidygeocoder using ArcGis provider, it seems to work:

# load map and packages
library("giscoR")
library("ggplot2")
library("tidygeocoder")
library("sf")
#> Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1

India <- gisco_get_countries(country = "India", epsg=4326)

# Sample Data
dta <- data.frame(1:9)
dta$name <- c(
  "Arunodaya  Rural  Integrated  &  Social Education Society , Andhra Pradesh , India",
  "Pathari Vocational Institute , Assam , India",
  "Mendu rural Devalopment Society , Andhra Pradesh , India",
  "Rural Health Care Development Society , Andhra Pradesh , India",
  "K.G.N.Voluntary Organisatin , Andhra Pradesh , India",
  "Prakashmay Sevashram , Bihar , India",
  "Integrity Explosion , Andhra Pradesh , India",
  "Sri Prakash Vidyaniketan , Andhra Pradesh , India",
  "Gayatri  Vidya  Parishad  College  of Engineering , Andhra Pradesh , India"
)

geo <- tidygeocoder::geo(address = dta$name, method = "arcgis")

# plot data:
geo <- st_as_sf(geo, coords = c("long", "lat"), crs = st_crs(4326))

ggplot(India) +
  geom_sf() +
  geom_sf(data = geo)

Created on 2021-06-01 by the reprex package (v2.0.0)

5
  • thank you very much for your help! :) This worked much better than using Google's geocoding service and there is only one observation outside India (out of >1,000).
    – erpunkt
    Jun 2, 2021 at 7:41
  • Can you trust that geocoder? If I try with address = "Pathari Vocational Institute , Assam , India", method="arcgis" I get a location in India but no sign of any institute. If I query with address = "Foo Bar Baz , Assam , India", method="arcgis" I get a location very close to that. If I query with address = "Pathari Vocational Institute", method="arcgis" I get a location just north of Liverpool, UK. Nothing there on the map matches. Is this geocoder trying too hard?
    – Spacedman
    Jun 2, 2021 at 15:31
  • That’s a fair point. I can’t say how accurate this geocoder is, although I think it should be, as this geocoding is done via ArcGIS developers.arcgis.com/documentation/mapping-apis-and-services/…. Obviously your test cast doubts about this. I also have to say that I tried OSM before and I didn’t get any results. I didn’t try other providers implemented on tidygeocoder since they requiere an API key.
    – dieghernan
    Jun 2, 2021 at 18:28
  • Sorry, the correct link is developers.arcgis.com/rest/geocode/api-reference/…
    – dieghernan
    Jun 2, 2021 at 18:43
  • That's a very good point. I'm also slightly concerned with the precision of the geocoded data and would be grateful for any suggestions regarding alternative geocoders. Alternatively, it would be great to have any indication on how precise the location was geocoded, e.g. which parts of the query "Pathari Vocational Institute , Assam , India" were used to geocode the location. If only "Assam, India" was used, this would point towards a less precise geolocation.
    – erpunkt
    Jun 6, 2021 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.