use API key to get geocode,but it said my key experied

67 Views Asked by At

I try to geocode batch addresses use googleway package, like "2105 Woodcrest Lane SW", but it said MY API key was experied. but I know we don't need to update API key every time once using it. this is r picture and my code here.enter image description hereis the problem about URL signiture?Do I need to add my signiture here? but how?

DT<-data.frame(newdata$`level of care`, newdata$AddressLine1, stringsAsFactors = FALSE)
names(DT)<-c("level of care","Address")
write.table(DT)

DT$Address<-as.character(DT$Address)
mykey <- "api key"
set_key(key= mykey)
library(googleway)
lat = vector("numeric", length = nrow(DT))
lng = vector("numeric", length = nrow(DT))
#google_geocode(address = DT$Address[i], key=mykey)

for (i in 1:nrow(DT)) {
  coord = googleway::google_geocode(DT$Address[i], key=mykey)

  if (coord$status == "OK") {
    coord = googleway::geocode_coordinates(coord)
    lat[i] = coord$lat[1]  # sometimes returns multiple coordinates
    lng[i] = coord$lng[1]  # sometimes returns multiple coordinates
  } else {
    lat[i] = NA
    lng[i] = NA
  }

}

#add log lat to DT
DT$lat<-lat
DT$lng<-lng
0

There are 0 best solutions below