I am trying to get zipcode for lat-long coordinates in new york region
I tried to use reverse geocoder API from google but its limited to 2500 hits per day so can process my data frame in batch.
Next, I tried using the library(zipcode) with dataset zip code but could not match latitude longitude with the coordinates of train data set as all lat-long coordinates are not in the dataset.
Further though of using KNN to predict zipcode for the dataset but can't get correct results.
zipcode_latlon = zipcode[zipcode$state=="NY",c(1,4,5)]
train_latlon = train_data[,c("latitude","longitude")]
zip1 = rep(10007, nrow(train_latlon))
zip1 = as.character(zip1)
train_latlon = cbind(zip1, train_latlon)
colnames(train_latlon) = c("zip","latitude","longitude")
knn_fit = knn(zipcode_latlon, train_latlon,zipcode_latlon$zip, k=1)
Need to know how I can get zipcodes from lat long in batch, any method would be good in R.