Geocoding using R

Hi,

I am trying to use RStudio to perform geocoding and I cannot seem to do it.

My code is as follows:

library(httr)
url = “https://developers.onemap.sg/commonapi/search
address = “650622”
body = list(searchVal = address, returnGeom = ‘Y’, getAddrDetails = ‘N’)
res = POST(url, body = body, encode = “json”, verbose())
content(res)

Please advise.

Thanks!

Hi BenLoo,

You should use GET Method.

GET METHOD

library(httr)

url <- “https://developers.onemap.sg/commonapi/search

query <- list(‘searchVal’ = ‘650622’, ‘returnGeom’ = ‘Y’, ‘getAddrDetails’ = ‘N’, ‘pageNum’ = ‘1’)

res <- GET(url, query = query, verbose())

content(res)





You can reference to this page for more infomation.

https://developers.onemap.sg/swagger

thanks.

1 Like

Yes it’s working. Thank you!

1 Like