Displaying SpatialLinesDataFrame in Mapview

Asked 2 years ago, Updated 2 years ago, 35 views


Road data (http://nlftp.mlit.go.jp/ksj/gml/datalist/KsjTmplt-N10.html) I want to use the mapview package to display it, but I can't.
Some data can be displayed, but what is the cause?

data<- Road data
pj2000<-CRS("+init=epsg:4612")
load<-maptools::readShapeLines (data, proj4string=pj2000)
mapview::mapview(road)

The following example (SpatialLinesDataFrame class) can be displayed.

library(mapview)
mapview (atlStorms 2005)

Thank you for your cooperation.

Data is a simple example or kokudosuuchi package (http://notchained.hatenablog.com/entry/2016/11/08/220222)
I wish I could use , but I couldn't, so
I will show you the URL of the data acquisition destination.

r

2022-09-30 17:18

2 Answers

Some Japanese words in data.frame seem to be causing the error.

 data (atlStorms 2005)
test1<-test2<-atlStorms 2005

test1@data$test<-as.factor(c("Japanese", "Test"))
test2@data$test<-as.factor(c("Japanese", "Igarashi"))

mapview(test1)# Displayed without problems
mapview(test2)# does not appear


2022-09-30 17:18

Thank you very much for answering my question.
We found that the data frame's character code could not be displayed.

 data (atlStorms 2005)
test1<-test2<-atlStorms 2005

test1@data$test<-as.factor(c("Japanese", "Test"))
test2@data$test<-as.factor(c("Japanese", "Igarashi"))

mapview(test1)# Displayed without problems
mapview(test2)# does not appear

You can save and load data frames.

re.data.frame<-function(data, encoding="UTF-8", fileEncoding="UTF-8"){
  write.csv(data, file("clipboard", encoding=encoding), row.names=F, fileEncoding=fileEncoding)
  fileEncoding=fileEncoding)
  tmp<-read_csv("clipboard")
  return(tmp)
}



test2@data<-re.data.frame (test2@data)
mapview(test2)# Displayable


2022-09-30 17:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.