rMaps ichoropleth とカスタムマップ/shp 質問する

rMaps ichoropleth とカスタムマップ/shp 質問する

Rでは、チュートリアルを再現する手助けが欲しいですここ独自のカスタム SHP (Shapefile) ファイルまたはマップをインタラクティブなコロプレス マップにします...

この地図は北アイルランドの小地域の地図です。ここ

以下は私がこれまでに行った手順です...

問題はデータの設定だと思いますがgeographyConfig

どのような助けでも大歓迎です。

# Download and unzip the data
system('wget http://www.nisra.gov.uk/archive/geography/digital_products/SA2011_Esri_Shapefile.zip')
system('unzip SA2011_Esri_Shapefile.zip')

# Load libraries
library(rgdal)
library(rgeos)
library(rMaps)

shp.file <- 'SA2011.shp'

# Convert projection
system(paste0('ogr2ogr tmp.shp ',
               shp.file,
              ' -t_srs "+proj=longlat +ellps=WGS84 +no_defs +towgs84=0,0,0"'))

# Read in the data
xx <- readOGR(dsn=getwd(),layer='tmp')
mm <- xx@data
head(mm)
n <- nrow(mm)
dat.val <- mm$Hectares

# Add extra year data
mm <- mm[rep(seq(n),3),]
mm$Hectares <- c(dat.val,rev(dat.val),dat.val/2)
mm$year <- rep(c(2000:2002),each=n)
colnames(mm)[1] <- 'ID'
id.var <- 'SA2011'


# Convert to json
system(paste0('topojson -o tmp.json -s 1e-7 -q 1e5 tmp.shp -p ID=',
              id.var,
              ' --id-property ',
              id.var))

d1 <- ichoropleth(Hectares ~ ID, data = mm, ncuts = 9, pal = 'YlOrRd', 
                  animate = 'year',  map = 'states'
)
d1$set(
  geographyConfig = list(
    dataUrl = "tmp.json"
  ),
  scope = 'states',
  setProjection = '#! function( element, options ) {
  var projection, path;
  projection = d3.geo.mercator()
  .center([-7, 55]).scale(element.offsetWidth)
  .translate([element.offsetWidth / 2, element.offsetHeight / 2]);

  path = d3.geo.path().projection( projection );
  return {path: path, projection: projection};
  } !#'
)
d1$save('rMaps.html', cdn = TRUE)

rMaps.htmlロードすると、下部にカットのみが表示され、マップは表示されないため、関連するマップは生成されません。

ベストアンサー1

recordnotfound.com のさまざまな人が、このスレッド (recordnotfound.com 上) に返信するよう著者に依頼しました。私は rMaps プロジェクトの所有者である Ramnath に連絡を取りました。彼は、強化された機能セットを提供する新しいプロジェクトがあることを提案しました。http://github.com/rstudio/リーフレット

リーフレット プロジェクトの詳細については、次のとおりです。https://recordnotfound.com/leaflet-rstudio-35205

おすすめ記事