library(plotly)

library(sf)

library(maps)

library(keras)

install_keras()

library(tensorflow)

install_tensorflow()


city <- read.csv("d://filebox/csv/city.csv")

city


set.seed(254)

x<-sample(0:1,128,replace=TRUE)

y<-rpois(128,5)

z<-rpois(128,3)


co<-data.frame(x,y,z)

co


l <- list(color = toRGB("#d1d1d1"), width = 0.5)


g <- list(


  showframe = FALSE,

  showcoastlines = TRUE,

  projection = list(type = 'orthographic'),

  resolution = '100',

  showcountries = TRUE,

  countrycolor = '#d1d1d1',

  showocean = TRUE,

  oceancolor = '#c9d2e0',

  showlakes = TRUE,

  lakecolor = '#99c0db',

  showrivers = TRUE,

  rivercolor = '#99c0db'

)


library(keras)


gl <- plot_geo(color = I("black"), showlegend = TRUE) %>%


 

  

  add_sf(

    data = sf::st_as_sf(maps::map("world", plot = FALSE, fill = TRUE)),

      keras_model_sequential(data)%>%

      

      world %>%

      layer_dense(units = 128, input_shape = c(4)) %>%

      layer_activation(activation = 'sigmoid')%>%

    

    world %>%  compile(

      loss = "categorical_crossentropy",

      optimizer = optimizer_rmsprop(),

      metric = c(metric_binary_accuracy))%>%

      

      history <- world$new()%>%

    world %>% fit(

      world,labels,

      batch_size=128, epochs=20, verbose=0,

      callbacks= list(world))%>%

    world <- plot_ly(history,

    x = ~ 1.001 * cos(degrees2radians(x)) * cos(degrees2radians(y)),

    y = ~ 1.001 * sin(degrees2radians(x)) * cos(degrees2radians(y)),

    z = ~ 1.001 * sin(degrees2radians(y)),

    color = I("black"), size = I(1),

    hoverinfo = "skip",

    add_segments(world,

      x = ~x, xend = ~xend,

      y = ~y, yend = ~y,

      color = I("black"),

      hoverinfo = "text",

      text = ~text ))

  ) %>%


  add_trace(z = ~z , color = ~x, colors = 'black',

            text = NULL, locations = ~y, marker = list(l = 'marker'))%%


  add_surface(

    x = cos(degrees2radians(lon)) * cos(degrees2radians(lat)),

    y = sin(degrees2radians(lon)) * cos(degrees2radians(lat)),

    z = sin(degrees2radians(lat)),

    surfacecolor = matrix(world, nrow = nlat, ncol = nlon),

    showscale = TRUE, hoverinfo = "skip",

    lightposition = xyzmean,

    contours = list(

      x = list(highlight = TRUE),

      y = list(highlight = TRUE),

      z = list(highlight = TRUE))

  )%>%

  

  layout(history,

    projection = list(type = 'orthographic'),

    showlegend = FALSE, geo = 'g',

    camer = list(aeye = xyzmean)

  )


print(gl)


###############

gl <- plot_ly(color = I("black"), showlegend = TRUE) %>%



  add_sf(

    data = sf::st_as_sf(maps::map("world", plot = FALSE, fill = TRUE)),

    x = ~ 1.001 * cos(degrees2radians(x)) * cos(degrees2radians(y)),

    y = ~ 1.001 * sin(degrees2radians(x)) * cos(degrees2radians(y)),

    z = ~ 1.001 * sin(degrees2radians(y)),

    color = I("black"), size = I(1),

    hoverinfo = "skip"


  ) %>%


  add_trace(z = ~z , color = ~x, colors = 'black',

            text = NULL, locations = ~y, marker = list(l = 'line'))%%


  add_surface(

    x = cos(degrees2radians(lon)) * cos(degrees2radians(lat)),

    y = sin(degrees2radians(lon)) * cos(degrees2radians(lat)),

    z = sin(degrees2radians(lat)),

    surfacecolor = matrix(NA, nrow = nlat, ncol = nlon),

    showscale = TRUE, hoverinfo = "skip",

    lightposition = xyzmean,

    contours = list(

      x = list(highlight = TRUE),

      y = list(highlight = TRUE),

      z = list(highlight = TRUE)

    )%>%


      layout(

        projection = list(type = 'orthographic'),

        showlegend = TRUE,

        scene = list(

          xaxis = empty_axis,

          yaxis = empty_axis,

          zaxis = empty_axis),

        aspectratio = list(x = 1, y = 1, z = 1),

        camera = list(eye = xyzmean),

        geo = "g"

      )

  )


print(gl)





##################

add_segments( x = 0,y = 0, xend = 180, yend = tan(60))%>%

  add_segments(x = cos(90), y = 0,xend = 180,yend = 180)%>%

  add_segments(x = cos(90), y = 180 ,xend = 360 ,yend = tan(89))%>%

  add_segments(x = cos(15), y = 180 ,xend = 360 ,yend = sin(45))%>%

  add_segments(x = 0, y = 60 ,xend = 40 ,yend = tan(45))

add_segments(x = 0, y = -60 ,xend = -40 ,yend = tan(45))%>%

  add_segments(x = cos(90), y = 180 ,xend = 360 ,yend = tan(89))%>%

  add_segments(x = cos(15), y = 180 ,xend = 360 ,yend = sin(45))%>%

  add_segments(x = 0, y = 60 ,xend = 40 ,yend = tan(45))%>%

  add_segments(x = 0,y = 0, xend = 180, yend = tan(60))%>%

  add_segments(x = tan(45),y = 180 , xend = 90, yend = tan(15))%>%

  add_segments(x = 0,y = 90 , xend = 90, yend = tan(15))%>%

  add_segments(x = 0,y = sin(60) , xend = sin(60), yend = 0)%>%

  add_segments(x = sin(45),y = 0 , xend = 0, yend = -sin(45))%>%

  add_segments(x = -sin(45),y = 0 , xend = 0, yend = -sin(45))%>%

  add_segments(x = 0,y = 0 , xend = -sin(45), yend = -sin(45))%>%

  add_segments(x = 0,y = 0 , xend = -sin(45), yend = tan(45), z = 90, zend = tan(89),length = z)%>%

  add_segments(x = 90,y = 90 , xend = -sin(45), yend = tan(45), z = 90, zend = tan(89), length = z)%>%

  add_segments(x = -100, xend = -50, y = 50, yend = 75) %>%

  add_surface(

    x = cos(degrees2radians(lon)) * cos(degrees2radians(lat)),

    y = sin(degrees2radians(lon)) * cos(degrees2radians(lat)),

    z = sin(degrees2radians(lat)),

    surfacecolor = matrix(NA, nrow = nlat, ncol = nlon),

    showscale = FALSE, hoverinfo = "skip",

    lightposition = xyzmean,

    contours = list(

      x = list(highlight = FALSE),

      y = list(highlight = FALSE),

      z = list(highlight = FALSE)

    )

  ) %>%



댓글(0) 먼댓글(0) 좋아요(0)
좋아요
l 공유하기 l 북마크하기찜하기