2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

考古学のためのRでGIS〜ポイントサンプリングツールをRで使う

Posted at

ポイントサンプリングツールとは点データと同じ位置のラスタ地図の値(標高値とか傾斜角など)を取得し、点データに付値するQGISのプラグインです。考古学では、遺跡立地地点の標高や傾斜などの地形指標を取得するという利用方法が考えられます。
同じ作業をRで実行する方法を紹介します。

01pointsampling.png

extract()関数

QGISのポイントサンプリングツールに相当する機能はextract()関数が提供しています。標高ラスタと傾斜ラスタの値を同一地点の遺跡データに付値します。

01eleve.png
02slope.png

extract()関数の最低限の引数は次のとおりです。

  • x = ラスタオブジェクト
  • y = SpatialPoints; SpatialPolygons; SpatialLinesを指定します。
  • meshod = "simple"か"bilinear"が選べます。

method = "simple"では該当する1点のラスタ値を取得します。method = "bilinear"では周囲4点から算出した補完値を使用します。

lev <-
  dem3100cr %>%
    extract(
      y = asbSite,    # SpatialPointsオブジェクト 
      method="bilinear", #周囲4点から算出した補完値を使う "bilinear"を指定
  ) %>%
  as_tibble() %>%
  rename("Elevation" = value )
# 標高値を確認
> head(lev)
[1]  95.70188  29.00163 113.30141  35.50785  31.91255  72.68698

遺跡位置データに標高値を付値

asbSite <-
  bind_cols(asbSite ,lev)

遺跡位置データに傾斜を付値

slope <-
  slp %>%
    extract(
      y = asbSite,    # SpatialPointsオブジェクト 
      method="bilinear", #周囲4点から算出した補完値を使う "bilinear"を指定
  ) %>%
  as_tibble() %>%
  rename("Slope" = value )
# 遺跡位置データに付値
asbSite <-
  bind_cols(asbSite ,slope)

遺跡立地地点の標高ヒストグラム

asbSite %>%
  ggplot() +
    geom_histogram(
    aes(x = Elevation)
    ) +
    theme_minimal()

03標高.png

遺跡立地地点の傾斜ヒストグラム

asbSite %>%
  ggplot() +
    geom_histogram(
    aes(x = Slope)
    ) +
    theme_minimal()

04slope.png

自然地形と遺跡立地地点の傾斜比較

前処理として、対象領域の傾斜ラスタ地図と遺跡地点の傾斜データを結合します。

# 自然地形
df_slp2 <-
  df_slp %>%
    dplyr::select(Slope) # Slopeカラムのみ選択
df_slp2$class <- factor("自然")  # 自然地形を意味する"自然"をfactor化してclassカラムに付値
# 遺跡
asbSite2 <-
  asbSite %>%
    as.tibble() %>%s
    dplyr::select(Slope) # Slopeカラムのみ選択
asbSite2$class <- factor("遺跡")
# データ結合
asbSlope <-
  bind_rows(asbSite2 , df_slp2)

ggplotで描画します。

asbSlope %>%
  ggplot() +
    geom_histogram(
    aes(x = Slope)
    ) +
    facet_wrap(~class , scales ="free_y")  +
    theme_minimal()

06傾斜比較.png

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?