首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >下载Geonames

下载Geonames
EN

Stack Overflow用户
提问于 2018-11-21 12:54:07
回答 1查看 189关注 0票数 0

我有兴趣下载加拿大的Geonames湖。麦克斯。每天可下载的行为1000行。当我运行下面的代码时,丢失的记录很少,有些记录会重叠。是否有一种方法可以获得湖名记录的总数,并且只下载一次记录,而不存在任何重叠?

代码语言:javascript
复制
library(geonames); GN_lake <- GNsearch(featureCode='LK', country='CA',startRow=1,maxRows = 1000) 

GN_lake <- GNsearch(featureCode='LK', country='CA',startRow=1000, maxRows=1000)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-21 13:12:12

为什么不直接在本地使用CA数据库呢?

代码语言:javascript
复制
library(httr)
library(tidyverse)

# Get CA database
httr::GET(
  url = "http://download.geonames.org/export/dump/CA.zip",
  httr::write_disk("CA.zip"),
  httr::progress()
) -> res

# unzip it
unzip("CA.zip")

read.csv( # readr::read_tsv doesn't like this file at least when I read it
  file = "CA.txt",
  header = FALSE,
  sep = "\t",
  col.names = c(
    "geonameid", "name", "asciiname", "alternatenames", "latitude",
    "longitude", "feature_class", "feature_code", "country", "cc2",
    "admin1_code1", "admin2_code", "admin3_code", "admin4_code",
    "population", "elevation", "dem", "timezone", "modification_date"
  ),
  stringsAsFactors = FALSE
) %>% tbl_df() -> ca_geo

filter(ca_geo, feature_code == "LK")
## # A tibble: 104,663 x 19
##    geonameid name          asciiname     alternatenames latitude longitude
##        <int> <chr>         <chr>         <chr>             <dbl>     <dbl>
##  1   5881640 101 Mile Lake 101 Mile Lake ""                 51.7    -121. 
##  2   5881642 103 Mile Lake 103 Mile Lake ""                 51.7    -121. 
##  3   5881644 105 Mile Lake 105 Mile Lake ""                 51.7    -121. 
##  4   5881647 108 Mile Lake 108 Mile Lake ""                 51.7    -121. 
##  5   5881660 130 Mile Lake 130 Mile Lake ""                 51.9    -122. 
##  6   5881666 16 1/2 Mile … 16 1/2 Mile … ""                 52.7    -118. 
##  7   5881668 180 Lake      180 Lake      ""                 57.4    -130. 
##  8   5881673 {1}útsaw Lake {1}utsaw Lake ""                 62.7    -137. 
##  9   5881680 24 Mile Lake  24 Mile Lake  ""                 46.5     -82.0
## 10   5881683 28 Mile Lake  28 Mile Lake  ""                 54.8    -124. 
## # ... with 104,653 more rows, and 13 more variables: feature_class <chr>,
## #   feature_code <chr>, country <chr>, cc2 <chr>, admin1_code1 <int>,
## #   admin2_code <chr>, admin3_code <int>, admin4_code <chr>,
## #   population <int>, elevation <int>, dem <int>, timezone <chr>,
## #   modification_date <chr>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53412488

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档