我们有两个地理区域:人口普查区和方形网格。网格数据集仅包含有关人口计数的信息。我们有每个人口普查区的总收入信息。 我们要做的是将这些收入数据从人口普查区域分配到网格单元。
这是地理分析中一个非常普遍的问题,可能有很多方法可以解决它。我们这样做不仅要考虑人口普查区域和网格单元之间的空间重叠,还要考虑每个单元的人口。这主要是为了避免在人口普查区较大但可能只包含居住在较小区域内的人时出现问题。
我们在下面展示了一个可重现的示例(使用 R 和 sf 程序包)以及我们迄今为止找到的解决此问题的方法,使用我们从我们的地理区域中提取的示例。我们很高兴看到其他人是否有替代(更有效)的解决方案来检查我们的结果是否正确。
library(sf)
library(dplyr)
library(readr)
# Files
download.file("https://github.com/ipeaGIT/acesso_oport/raw/master/test/shapes.RData", "shapes.RData")
load("shapes.RData")
# Open tracts and calculate area
tract <- tract %>%
mutate(area_tract = st_area(.))
# Open grid squares and calculate area
square <- square %>%
mutate(area_square = st_area(.))
ui <-
# Create spatial units for all intersections between the tracts and the squares (we're calling these "piece")
st_intersection(square, tract) %>%
# Calculate area for each piece
mutate(area_piece = st_area(.)) %>%
# Compute the proportion of each tract that's inserted in that piece
mutate(area_prop_tract = area_piece/area_tract) %>%
# Compute the proportion of each square that's inserted in that piece
mutate(area_prop_square = area_piece/area_square) %>%
# Based on the square's population, compute the population that lives in that piece
mutate(pop_prop_square = square_pop * area_prop_square) %>%
# Compute the population proportion of each square that is within the tract
group_by(id_tract) %>%
mutate(sum = sum(pop_prop_square)) %>%
ungroup() %>%
# Compute population of each piece whitin the tract
mutate(pop_prop_square_in_tract = pop_prop_square/sum) %>%
# Compute income within each piece
mutate(income_piece = tract_incm* pop_prop_square_in_tract)
# Final agreggation by squares
ui_fim <- ui %>%
# Group by squares and population and sum the income for each piece
group_by(id_square, square_pop) %>%
summarise(square_income = sum(income_piece, na.rm = TRUE))
谢谢!
最佳答案
根据您要使用的插值方法,我可能会为您提供帮助开发的解决方案。 areal
包实现了区域加权插值,我在自己的研究中使用了它,在美国人口普查地理和网格正方形之间进行插值。您可以查看包的网站(和相关的小插图)here .希望这有用!
关于r - 将数据从一个地理区域分配到另一个地理区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56012538/