Untitled
unknown
r
5 years ago
6.3 kB
10
Indexable
#install.packages("areal")
library(sf)
library(areal)
library(dplyr)
dat90 = st_read("cw4/data/san_francisco_tracts_1990_attr.shp")
dat00 = st_read("cw4/data/san_francisco_tracts_2000_attr.shp")
dat10 = st_read("cw4/data/san_francisco_tracts_2010_attr.shp")
#target units to granice z 2010 roku
target_units <- dat10[, c("GISJOIN")]
#source units to dane w granicach z 1990 roku
source_units <- dat90[, c("GISJOIN", list_race, "POP")]
colnames(source_units) <- c("GJOIN", list_race, "POP", "geometry")
intersect <- aw_intersect(target_units,
source = source_units,
areaVar = "area")
intersect <- aw_total(intersect,
source = source_units, #granice zrodlowe
id = GJOIN, #id jednostek zrodlowych
areaVar = "area", #nazwa pola z powierzchnia jednostek z przeciecia, Ai
totalVar = "totalArea",
type = "extensive",
weight = "sum")
intersect <- aw_weight(intersect,
areaVar = "area", #Ai - obliczane przez aw_intersect
totalVar = "totalArea", #Aj, obliczane przez aw_total
areaWeight = "areaWeight")
intersect <- aw_calculate(intersect,
value = "POP", #kolumna do przeliczenia
newVar = "POPnew", #nazwa nowej kolumny z przeliczonymi danymi.
areaWeight = "areaWeight")
result <- aw_aggregate(intersect,
target = target_units, #granice docelowe
tid = GISJOIN, #id docelowe (target units)
interVar = "POPnew") #nazwa przeliczonej zmiennej
result90_10 <- aw_interpolate(target_units, #granice jednostek docelowych (target_units)
tid = GISJOIN, #id jednostek docelowych
source = source_units, #dane zrodlowe
sid = GJOIN, #id jednostek zrodlowych (source units)
weight = "sum",
output = "tibble", #wynik w jako tabela, moze tez być obiekt sf
extensive = list_race) #lista zmiennych do przeliczenia
##################3
source_units <- dat90[, c("GISJOIN", list_race, "POP")]
colnames(source_units) <- c("GJOIN", list_race, "POP", "geometry")
intersect <- aw_intersect(target_units,
source = source_units,
areaVar = "area")
intersect <- aw_total(intersect,
source = source_units, #granice zrodlowe
id = GJOIN, #id jednostek zrodlowych
areaVar = "area", #nazwa pola z powierzchnia jednostek z przeciecia, Ai
totalVar = "totalArea",
type = "extensive",
weight = "sum")
intersect <- aw_weight(intersect,
areaVar = "area", #Ai - obliczane przez aw_intersect
totalVar = "totalArea", #Aj, obliczane przez aw_total
areaWeight = "areaWeight")
intersect <- aw_calculate(intersect,
value = "POP", #kolumna do przeliczenia
newVar = "POPnew", #nazwa nowej kolumny z przeliczonymi danymi.
areaWeight = "areaWeight")
result <- aw_aggregate(intersect,
target = target_units, #granice docelowe
tid = GISJOIN, #id docelowe (target units)
interVar = "POPnew") #nazwa przeliczonej zmiennej
result90_10 <- aw_interpolate(target_units, #granice jednostek docelowych (target_units)
tid = GISJOIN, #id jednostek docelowych
source = source_units, #dane zrodlowe
sid = GJOIN, #id jednostek zrodlowych (source units)
weight = "sum",
output = "tibble", #wynik w jako tabela, moze tez być obiekt sf
extensive = list_race) #lista zmiennych do przeliczenia
########################################################################3
target_units <- dat10[, c("GISJOIN")]
#source units to dane w granicach z 2000 roku
source_units <- dat00[, c("GISJOIN", list_race, "POP")]
colnames(source_units) <- c("GJOIN", list_race, "POP", "geometry")
intersect <- aw_intersect(target_units,
source = source_units,
areaVar = "area")
intersect <- aw_total(intersect,
source = source_units, #granice zrodlowe
id = GJOIN, #id jednostek zrodlowych
areaVar = "area", #nazwa pola z powierzchnia jednostek z przeciecia, Ai
totalVar = "totalArea",
type = "extensive",
weight = "sum")
intersect <- aw_weight(intersect,
areaVar = "area", #Ai - obliczane przez aw_intersect
totalVar = "totalArea", #Aj, obliczane przez aw_total
areaWeight = "areaWeight")
intersect <- aw_calculate(intersect,
value = "POP", #kolumna do przeliczenia
newVar = "POPnew", #nazwa nowej kolumny z przeliczonymi danymi.
areaWeight = "areaWeight")
result <- aw_aggregate(intersect,
target = target_units, #granice docelowe
tid = GISJOIN, #id docelowe (target units)
interVar = "POPnew") #nazwa przeliczonej zmiennej
result00_10 <- aw_interpolate(target_units, #granice jednostek docelowych (target_units)
tid = GISJOIN, #id jednostek docelowych
source = source_units, #dane zrodlowe
sid = GJOIN, #id jednostek zrodlowych (source units)
weight = "sum",
output = "tibble", #wynik w jako tabela, moze tez być obiekt sf
extensive = list_race) #lista zmiennych do przeliczenia
Editor is loading...