SlideShare uma empresa Scribd logo
1 de 24
~素人の手による~Rを用いた地理情報分析 2011/08/27 TokyoR #16 Hiroki Matsui
自己紹介 Hiroki Matsui(RPT,MPH) 専門:リハビリテーション、臨床疫学・医療経済学 元理学療法士(リハビリ屋)->現在は研究者と事務屋の間 Rは趣味程度に利用->現在は、仕事で利用 Rも地理情報分析も素人 Twitter:Hiro_macchan
本日のテーマ Rによる地理的情報の分析 でも、僕はRも地理情報分析も素人 ->タスクを設定してそれを達成し、事例報告でお茶を・・・。 エンジニアの皆様、専門家の皆様ごめんなさい。 逆に色々教えて下さい。
本日のテーマ タスク Rを用いて 東京都の専門医の地理的分布を Google Earth上に描画してみよう!
GISで地図を書く GIS(Geographic InformationSystem:地理的情報システム)を用いることにより、コンピューター上で、地理的情報を重ね合わせて表示し、情報を得るためのソフトウェア。 空間統計や、時空間統計などの統計手法についても近年は発達している。 ->今回は、そういった高度な内容は扱いませんので、また教えて下さい。。。
GISで地図を書く 必要なもの 白地図情報 描画の下地になる白地図情報。数値集計の枠組みになったりする。 地理的情報が付与された統計情報 統計数値と地理的情報(具体的には緯度経度)がセットになったデータセット GISソフト 色々あって選り取り見取り?今回はRを使ってみよう。
GISで地図を書く 必要なもの 白地図情報 描画の下地になる白地図情報。数値集計の枠組みになったりする。 地理的情報が付与された統計情報 統計数値と地理的情報(具体的には緯度経度)がセットになったデータセット GISソフト 色々あって選り取り見取り?今回はRを使ってみよう。
GISで地図を書く 白地図情報 各種白地図情報(国土地理院、国土交通省、ESRI社) ファイル形式は様々だが、ESRI社の開発したShapeファイル形式が広く利用されている。 Google EarthやGoogle Map上に描画する場合もある。
GISで地図を書く 必要なもの 白地図情報 描画の下地になる白地図情報。数値集計の枠組みになったりする。 地理的情報が付与された統計情報 統計数値と地理的情報(具体的には緯度経度)がセットになったデータセット GISソフト 色々あって選り取り見取り?今回はRを使ってみよう。
GISで地図を書く 地理的情報を付加した統計情報 住所情報にジオコーディングで、緯度経度情報を付加する必要性 各種ジオコーダー(Google, Yahoo, 東大CSVアドレスマッチングサービス等) R上でもジオコーディングをする手法があるようです。(R-wiki参照)
GISで地図を書く 必要なもの 白地図情報 描画の下地になる白地図情報。数値集計の枠組みになったりする。 地理的情報が付与された統計情報 統計数値と地理的情報(具体的には緯度経度)がセットになったデータセット GISソフト 色々あって選り取り見取り?今回はRを使ってみよう。
GISで地図を書く GISソフトとしてのR maptoolsというパッケージが有名 地理的情報をSpatialPoligonという形のデータで格納し、R上で地図への描画などを行う事が出来る。 他のパッケージは試してないので、比較できませんが結構便利です。
maptoolsの紹介 maptoolsで出来ること 地理的情報をSpatialPoligonに変換 ShapeFileなどで記載された白地図情報をSpatialPoligonに変換 SpatialPoligonファイルの編集 KMLファイルへの出力 等々
事例紹介(白地図データ) 白地図データは、諸般の事情により、国土交通省国土政策局の国土数値情報から取得したJPGISファイルからShapeファイルを作成 (ESRI社に白地図データをRで使っていい?と聞いたらだめと言われたんで。。。)
事例紹介(ジオコーディング) ジオコーディング済みの地理的情報を取得しましょう。 今回は、東京都における各医療機関の住所情報、及び、所属する専門医数を利用します。 東京都のHPから取得 ジオコーディングは、東大地理空間研究所が提供している、CSVアドレスマッチングサービスを利用
Rによる実際の処理 白地図シェープファイルの取り込み 統計情報の取り込み 主題図の描画 KMLファイルへの出力
白地図のShapeFileの取り込み library(maptools) jpn2<-readShapeSpatial(shapefile,proj4string = CRS("+proj=longlat +datum=WGS84")) tokyo<-jpn2[jpn2$KEN=="東京都",] plot(tokyo,xlim=xlim,ylim=ylim,axes=T)
統計情報の取り込み  hospital<-read.csv(byouin,colClasses=c(rep("numeric",55),rep("character",5),rep("numeric",4)),head=T) lola<-hospital[,fx:fy] sp.hospital<-SpatialPoints(lola,proj4string = CRS("+proj=longlat +datum=WGS84 +units=km")) spdf.hospital<-SpatialPointsDataFrame(sp.hospital,data=hospital)
主題図の描画  #病院の、白地図上での所属を判定     res_all<-overlay(spdf.hospital,tokyo)     spdf.hospital@data$location<-as.factor(res_all)  #各市区町村の別の産婦人科専門医合計人数を計算     obstgyne<-tapply(spdf.hospital$産婦人科専門医,spdf.hospital$location,sum)     obst.name<-names(obstgyne)     obstgyne<-as.data.frame(obstgyne)     obstgyne$name<-obst.name    #SPにマージ     tokyo@data<-merge.data.frame(tokyo@data,obstgyne,by.x="OBJECTID",by.y="name",all=T)     tokyo$obstgyne<-ifelse(is.na(tokyo$obstgyne),0,tokyo$obstgyne)  f.plot<-function(x){ iro<-brewer.pal(8,"Greens") kaisou<-classIntervals(x,n=8,style="kmeans") colcode<-findColours(kaisou,iro)  plot(tokyo,col=paste(colcode,80,sep=""),axes=T,xlim=xlim,ylim=ylim)      }     f.plot(tokyo$p.obstgyne)
主題図の描画
地図の重ね合わせ plot(spdf.hospital,cex=spdf.hospital$産婦人科専門医*0.1,pch = 16, col = "#0000FF70",xlim=xlim,ylim=ylim,add=T)
KMLファイルへの出力  #地図をGoogle Mapとかで使える用に png/kml形式に変換       library(rgdal)       opt_exask <- options(example.ask=FALSE)       tf <- "c:/KML/tokyo"       SGqk <- GE_SpatialGrid(tokyo)       png(file=paste(tf, ".png", sep=""), width=SGqk$width, height=SGqk$height, bg="transparent")       par(mar=c(0,0,0,0), xaxs="i", yaxs="i")       iro<-brewer.pal(8,"Greens")       kaisou<-classIntervals(tokyo$p.obstgyne,n=8,style="kmeans")       colcode<-findColours(kaisou,iro)       plot(tokyo,col=paste(colcode,80,sep=""), xlim=SGqk$xlim, ylim=SGqk$ylim)       dev.off()       kmlOverlay(SGqk, paste(tf, ".kml", sep=""), paste(tf, ".png", sep="")) 参考:R-wiki(http://www.okada.jp.org/RWiki/index.php?GoogleEarth%A4%C8R)
GISの医療政策への応用 患者の医療アクセスの解析 医療マーケティング 医療のアウトカムリサーチを行う際の交絡調整に。。
参考資料 書籍 地理空間データ分析 (Rで学ぶデータサイエンス 7) (谷村 晋 (著), 金 明哲 (編集) ) ホームページ R-wiki(http://www.okada.jp.org/RWiki/index.php?GoogleEarth%A4%C8R) CSVアドレスマッチングサービス(http://newspat.csis.u-tokyo.ac.jp/geocode/) 国土地理院(http://www.gsi.go.jp/kiban/index.html) 国土交通省(http://nlftp.mlit.go.jp/ksj/index.html) ESRIジャパン(http://www.esrij.com/) 参考にさせて頂いたブログ http://d.hatena.ne.jp/dichika/touch http://d.hatena.ne.jp/isseing333/

Mais conteúdo relacionado

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Tokyo r hiromatsu