python将经纬度坐标转换为xy,如何在R或Python中将County FIPS转换为经纬度坐标?

Glyphosate has hogged the limelight recently due to listing as a possible carcinogen by the World Health Organization's IARC. I got curious about pesticide usage patterns in the US and plotting this data with interactive maps in R-Shiny, using leaflet, for example.

County-level estimates of pesticide usage can be found here: https://water.usgs.gov/nawqa/pnsp/usage/maps/county-level/

The data are reported using State/County FIPS codes. I require lat-long coordinates to show the data.

It seems possible to go from lat-long to FIPS quite easily, as illustrated by this API here: https://geo.fcc.gov/api/census/

How to go in the reverse direction?

解决方案

The solution I found required using a REST API from here.com of the five options (below). I first cross-referenced FIPS codes from USGS table with County and State names using table fips_codes from library(tigris). This gave me names to put together in address lines, like Boulder County, CO. Next, I wrote a small function here_now with sample usage as:

here_now("Boulder+County,+CO") # $lat: 40.08791; $lon: -105.3447

Implementation is a call to the REST API using fromJSON from library(jsonlite)

here_now

AppCode

AppID

rootURL

app_id = paste("app_id", AppID, sep="=")

app_code = paste("app_code", AppCode, sep="=")

searchtext = paste("searchtext", searchtext, sep="=")

request

response = fromJSON(request)

res

res$lat

res$lon

res

}

Further, I used the FCC's reverse geo-coding API to validate: https://geo.fcc.gov/api/census/

Options I experimented with for geocoding included:

- google APIs via ggmap (requires API key, requires credit card)

- mapquest API (requires API key, no credit card needed)

- Data Science Toolkit's RDSK implementation

- Geonames service via eponymous R package

- Here APIs (require AppID and AppCode, freemium model)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值