【R】geomander

1. はじめに

geomanderは、ゲリマンダリング(選挙区分けをすること)のためのツール一式を提供するパッケージです。

2. インストール

CRANからインストールできます。

install.packages("geomander")

3. つかってみる

資料が充実していないので、ヘルプをみます。

??geomander

geomander-package {geomander}	R Documentation
Geographic Tools for Studying Gerrymandering
Description
A compilation of tools to complete common tasks for studying gerrymandering. This focuses on the geographic tool side of common problems, such as linking different levels of spatial units or estimating how to break up units. Functions exist for creating redistricting-focused data for the US.

Package Content
Index of help topics:

add_edge                Add Edges to an Adjacency List
adjacency               Build Adjacency List
block2prec              Aggregate Block Table by Matches
block2prec_by_county    Aggregate Block Table by Matches and County
check_contiguity        Check Contiguity by Group
checkerboard            Checkerboard
checkerboard_adj        Checkerboard Adjacency
compare_adjacencies     Compare Adjacency Lists
count_connections       Count Times Precincts are Connected
create_block_table      Create Block Level Data
create_tract_table      Create Tract Level Data
dra2r                   DRA to R
estimate_down           Estimate Down Levels
estimate_up             Estimate Up Levels
geo_estimate_down       Estimate Down Geography Levels
geo_estimate_up         Estimate Up Geography Levels
geo_filter              Filter to Intersecting Pieces
geo_match               Match Across Geographic Layers
geo_plot                Plots a Shape with Row Numbers as Text
geo_plot_group          Create Plots of Shapes by Group with Connected
                        Components Colored
geo_sort                Sort Precincts
geo_trim                Trim Away Small Pieces
geomander-package       Geographic Tools for Studying Gerrymandering
global_gearys           Compute Global Geary's C
global_morans           Compute Global Moran's I
gstar_i                 Compute Standardized Getis Ord G*i
local_gearys            Compute Local Geary's C
local_morans            Compute Local Moran's I
nrcsd                   nrcsd
orange                  orange
precincts               precincts
r2dra                   R to DRA
rockland                rockland
split_precinct          Split a Precinct
st_centerish            Get the kind of center of each shape
suggest_component_connection
                        Suggest Connections for Disconnected Groups
suggest_neighbors       Suggest Neighbors for Lonely Precincts
towns                   towns
va18sub                 va18sub
va_blocks               va_blocks
va_vtd                  va_vtd
Maintainer
NA

Author(s)
NA

[Package geomander version 1.0.8 Index]

いくつのかのデータセットがあります。例えば、rockland

library(geomander)

data(rockland)
> rockland
Simple feature collection with 4764 features and 25 fields
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: -74.23447 ymin: 40.9972 xmax: -73.88718 ymax: 41.32469
geographic CRS: NAD83
First 10 features:
   state county  tract block           GEOID waterpct pop pop_white
1     36    087 013100  3006 360870131003006        0  54        50
2     36    087 013002  3046 360870130023046        0   0         0
3     36    087 013200  2005 360870132002005        0  71        44
4     36    087 013003  2009 360870130032009        0  65        61
5     36    087 013200  2012 360870132002012        0   6         4
6     36    087 013200  3008 360870132003008        0 155        55
7     36    087 013200  1007 360870132001007        0  49        41
8     36    087 013200  1005 360870132001005        0  25        25
9     36    087 013200  2020 360870132002020        0   7         6
10    36    087 013300  2013 360870133002013        0  88        75
   pop_black pop_hisp pop_aian pop_asian pop_nhpi pop_other pop_two
1          1        3        0         0        0         0       0
2          0        0        0         0        0         0       0
3         13        9        0         4        0         0       1
4          1        0        0         3        0         0       0
5          2        0        0         0        0         0       0
6         50       46        0         1        0         0       3
7          8        0        0         0        0         0       0
8          0        0        0         0        0         0       0
9          0        1        0         0        0         0       0
10         0       11        0         2        0         0       0
   vap vap_white vap_black vap_hisp vap_aian vap_asian vap_nhpi
1   51        48         1        2        0         0        0
2    0         0         0        0        0         0        0
3   63        39        12        7        0         4        0
4   48        46         1        0        0         1        0
5    5         4         1        0        0         0        0
6  117        43        33       39        0         1        0
7   38        32         6        0        0         0        0
8   19        19         0        0        0         0        0
9    7         6         0        1        0         0        0
10  71        64         0        5        0         2        0
   vap_other vap_two place                       geometry
1          0       0 54100 POLYGON ((-73.91693 41.0942...
2          0       0 55167 POLYGON ((-73.9474 41.0367,...
3          0       1 69441 POLYGON ((-73.92622 41.0823...
4          0       0 99999 POLYGON ((-73.92707 41.0787...
5          0       0 69441 POLYGON ((-73.92315 41.0774...
6          0       1 69441 POLYGON ((-73.92185 41.0853...
7          0       0 69441 POLYGON ((-73.91886 41.0807...
8          0       0 69441 POLYGON ((-73.91861 41.0826...
9          0       0 69441 POLYGON ((-73.92189 41.0765...
10         0       0 57749 POLYGON ((-73.92046 41.0480...

描画してみます。

library(tidyverse)

rockland %>% 
  ggplot()+
  geom_sf()

4. さいごに

いろいろ機能があるようですが、それはまたの機会に。

Add a Comment

メールアドレスが公開されることはありません。