按国家/地区的人口普查数据邮政编码

时间:2016-03-03 22:58:19

标签: r

我正在使用acs包来获取人口普查数据。特别是,我正在尝试获取新泽西州所有邮政编码的数据。

问题是我似乎只能抓住美国的所有邮政编码。

List<Integer> items = Stream
    .of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
    .collect(Collectors.toList());

Set<Integer> exclude = Stream
    .of(5, 10, 15)
    .collect(Collectors.toSet());

List<Integer> filtered = items
    .parallelStream()
    .filter(num -> !exclude.contains(num))
    .collect(Collectors.toList());

没有其他组合正在发挥作用。

有什么想法吗?

3 个答案:

答案 0 :(得分:2)

这是不可能的。邮政编码不会映射到州。请参阅:https://www.census.gov/geo/reference/webatlas/

通常,不鼓励使用邮政编码作为地理组织单位。使用邮政编码存在许多问题,其中许多都在Zip Code Wikipedia page上列出。最值得注意的是,虽然邮政编码通常具有地理成分,但代表地理区域;它们对应于地址组或交付路线。因此,邮政编码可以重叠州界限,甚至可以是没有地理区域的人工结构。

答案 1 :(得分:2)

您可以使用R包从totalcensus获取任何区域的所有邮政编码。按照说明安装和设置https://github.com/GL-Li/totalcensus。这里有an example显示如何获取邮政编码的人口普查数据。

以下是获取新泽西州所有邮政编码的代码:

# follow the instruction in the link to install the package, then
library(totalcensus)
zip_NJ <- read_decennial(
    year = 2010,
    states = "NJ",
    geo_headers = "ZCTA5",
    summary_level = "871"
)

# all zip codes in New Jersy
zip_NJ$ZCTA5

# 
#   [1] "07001" "07002" "07003" "07004" "07005" "07006" "07008" "07009" "07010" "07011" "07012" "07013" "07014"
#  [14] "07016" "07017" "07018" "07020" "07021" "07022" "07023" "07024" "07026" "07027" "07028" "07029" "07030"
#  [27] "07031" "07032" "07033" "07034" "07035" "07036" "07039" "07040" "07041" "07042" "07043" "07044" "07045"
#  [40] "07046" "07047" "07050" "07052" "07054" "07055" "07057" "07058" "07059" "07060" "07062" "07063" "07064"
#  [53] "07065" "07066" "07067" "07068" "07069" "07070" "07071" "07072" "07073" "07074" "07075" "07076" "07077"
#  [66] "07078" "07079" "07080" "07081" "07082" "07083" "07086" "07087" "07088" "07090" "07092" "07093" "07094"
#  [79] "07095" "07102" "07103" "07104" "07105" "07106" "07107" "07108" "07109" "07110" "07111" "07112" "07114"
#  [92] "07201" "07202" "07203" "07204" "07205" "07206" "07208" "07302" "07304" "07305" "07306" "07307" "07310"
# [105] "07311" "07401" "07403" "07405" "07407" "07410" "07416" "07417" "07418" "07419" "07420" "07421" "07422"
# [118] "07423" "07424" "07430" "07432" "07435" "07436" "07438" "07439" "07440" "07442" "07444" "07446" "07450"
# [131] "07452" "07456" "07457" "07458" "07460" "07461" "07462" "07463" "07465" "07470" "07480" "07481" "07495"
# [144] "07501" "07502" "07503" "07504" "07505" "07506" "07508" "07512" "07513" "07514" "07522" "07524" "07601"
# [157] "07603" "07604" "07605" "07606" "07607" "07608" "07620" "07621" "07624" "07626" "07627" "07628" "07630"
# [170] "07631" "07632" "07640" "07641" "07642" "07643" "07644" "07645" "07646" "07647" "07648" "07649" "07650"
# [183] "07652" "07656" "07657" "07660" "07661" "07662" "07663" "07666" "07670" "07675" "07676" "07677" "07701"
# [196] "07702" "07703" "07704" "07711" "07712" "07716" "07717" "07718" "07719" "07720" "07721" "07722" "07723"
# [209] "07724" "07726" "07727" "07728" "07730" "07731" "07732" "07733" "07734" "07735" "07737" "07738" "07739"
# [222] "07740" "07746" "07747" "07748" "07750" "07751" "07753" "07755" "07756" "07757" "07758" "07760" "07762"
# [235] "07764" "07801" "07803" "07820" "07821" "07822" "07823" "07825" "07826" "07827" "07828" "07830" "07832"
# [248] "07833" "07834" "07836" "07838" "07840" "07842" "07843" "07846" "07847" "07848" "07849" "07850" "07851"
# [261] "07852" "07853" "07856" "07857" "07860" "07863" "07865" "07866" "07869" "07870" "07871" "07874" "07876"
# [274] "07878" "07880" "07881" "07882" "07885" "07901" "07920" "07921" "07922" "07924" "07926" "07927" "07928"
# [287] "07930" "07931" "07932" "07933" "07934" "07935" "07936" "07939" "07940" "07945" "07946" "07950" "07960"
# [300] "07961" "07970" "07974" "07976" "07977" "07979" "07980" "07981" "08001" "08002" "08003" "08004" "08005"
# [313] "08006" "08007" "08008" "08009" "08010" "08011" "08012" "08014" "08015" "08016" "08019" "08020" "08021"
# [326] "08022" "08023" "08026" "08027" "08028" "08029" "08030" "08031" "08033" "08034" "08035" "08036" "08037"
# [339] "08038" "08039" "08041" "08042" "08043" "08045" "08046" "08048" "08049" "08050" "08051" "08052" "08053"
# [352] "08054" "08055" "08056" "08057" "08059" "08060" "08061" "08062" "08063" "08064" "08065" "08066" "08067"
# [365] "08068" "08069" "08070" "08071" "08072" "08073" "08074" "08075" "08077" "08078" "08079" "08080" "08081"
# [378] "08083" "08084" "08085" "08086" "08087" "08088" "08089" "08090" "08091" "08092" "08093" "08094" "08095"
# [391] "08096" "08097" "08098" "08102" "08103" "08104" "08105" "08106" "08107" "08108" "08109" "08110" "08201"
# [404] "08202" "08203" "08204" "08205" "08210" "08212" "08215" "08217" "08221" "08223" "08224" "08225" "08226"
# [417] "08230" "08232" "08234" "08240" "08241" "08242" "08243" "08244" "08246" "08247" "08248" "08251" "08260"
# [430] "08270" "08302" "08310" "08311" "08312" "08314" "08316" "08317" "08318" "08319" "08320" "08321" "08322"
# [443] "08323" "08324" "08326" "08327" "08328" "08329" "08330" "08332" "08340" "08341" "08343" "08344" "08345"
# [456] "08346" "08348" "08349" "08350" "08352" "08353" "08360" "08361" "08401" "08402" "08403" "08406" "08501"
# [469] "08502" "08505" "08510" "08511" "08512" "08514" "08515" "08518" "08520" "08525" "08527" "08528" "08530"
# [482] "08533" "08534" "08535" "08536" "08540" "08542" "08550" "08551" "08553" "08554" "08555" "08558" "08559"
# [495] "08560" "08561" "08562" "08608" "08609" "08610" "08611" "08618" "08619" "08620" "08628" "08629" "08638"
# [508] "08640" "08641" "08648" "08690" "08691" "08701" "08720" "08721" "08722" "08723" "08724" "08730" "08731"
# [521] "08732" "08733" "08734" "08735" "08736" "08738" "08740" "08741" "08742" "08750" "08751" "08752" "08753"
# [534] "08755" "08757" "08758" "08759" "08801" "08802" "08804" "08805" "08807" "08808" "08809" "08810" "08812"
# [547] "08816" "08817" "08820" "08821" "08822" "08823" "08824" "08825" "08826" "08827" "08828" "08829" "08830"
# [560] "08831" "08832" "08833" "08835" "08836" "08837" "08840" "08844" "08846" "08848" "08850" "08852" "08853"
# [573] "08854" "08857" "08858" "08859" "08861" "08863" "08865" "08867" "08869" "08872" "08873" "08876" "08879"
# [586] "08880" "08882" "08884" "08886" "08887" "08889" "08890" "08901" "08902" "08904"

答案 2 :(得分:0)

我最后从感兴趣区域的其他来源导入邮政编码列表,然后将该表格与所有邮政编码合并到新邮政编码。