Select Language

Open Dataset

森林被覆率データ、インド林業部

森林被覆率データ、インド林業部

24K
457 hits
0 likes
6 downloads
0 discuss
Arts and Entertainment,Government,Forestry Classification

rgdal パッケージを読み込む。sp パッケージを読み込む。x を rgdal とする。もし x パッケージが読み込めない場合(character.only = TRUE として)、パッケージ x を依存関係を含めてインストールし、......

Data Structure ? 24K

    Data Structure ?

    *The above analysis is the result extracted and analyzed by the system, and the specific actual data shall prevail.

    README.md

    require(rgdal)
    require(sp)
    x<-"rgdal"
    if (!require(x,character.only=TRUE))
    {
    install.packages(pkgs=x,dependencies = TRUE)
    require(x,character.only=TRUE)
    }

    位置

    location="C:/Users/acer/documents/R/data/India Map"
    india1<- readOGR(dsn = location,"IND_adm1")

    インドをプロットする

    plot(india1)
    slotNames(india1)
    names(india1)
    head(india1@data)

    データセットに含まれる名前

    head(india1$NAME_1,10)

    サンプルとして1つの州をプロットする

    plot(india1[india1$NAME_1=="Delhi",],col="red")
    title("Delhi")

    森林情報を含むファイルを読み込む

    forestdata<-read.csv(file="C:/Users/acer/documents/R/data/Recorded_Forest_Area.csv", stringsAsFactors = FALSE)
    head(forestdata)
    names(forestdata)

    名前が長すぎるので変更する

    colnames(forestdata)<-c("state","statearea","forestarea2005","reserved","protected","unclassed","totalforestarea","forestareapercent")
    names(forestdata)
    head(forestdata)

    今度は因子を文字型に変更する

    india1$NAME_1 = as.character(india1$NAME_1)
    forestdata$state=as.character(forestdata$state)

    今度はマップとCSVファイルのデータがすべて一致しているか確認する

    india1$NAME_1 %in% forestdata$state

    不一致の行を返す

    india1$NAME_1[which(!india1$NAME_1 %in% forestdata$state)]

    問題は「and」の代わりに「&」が使われていること、そして州名の「Uttaranchal」が後に「Uttrakhand」に変更されたことである

    #

    関連する変更を行う

    india1$NAME_1[grepl("Andaman and Nicobar",india1$NAME_1)]="Andaman & Nicobar"
    india1$NAME_1[grepl("Dadra and Nagar Haveli",india1$NAME_1)]="Dadra & Nagar Haveli"
    india1$NAME_1[grepl("Jammu and Kashmir",india1$NAME_1)]="Jammu & Kashmir"
    india1$NAME_1[grepl("Daman and Diu",india1$NAME_1)]="Daman & Diu"
    india1$NAME_1[grepl("Uttaranchal",india1$NAME_1)]="Uttarakhand"

    今度は再度一致を確認する

    india1$NAME_1%in%forestdata$state


    ×

    The dataset is currently being organized and other channels have been prepared for you. Please use them

    The dataset is currently being organized and other channels have been prepared for you. Please use them

    Note: Some data is currently being processed and cannot be directly downloaded. We kindly ask for your understanding and support.
    No content available at the moment
    No content available at the moment
    • Share your thoughts
    Go share your ideas~~

    ALL

      Welcome to exchange and share
      Your sharing can help others better utilize data.
    Points:4 Go earn points?
    • 457
    • 6
    • 0
    • collect
    • Share