在静态地图中使用tweenr和gganimate

我有一个一般性的问题。我对使用这些软件包是超级新手,并不是很精明,所以提前致歉!我正在尝试制作一张上面有点的静态地图。我想同时使用补间动画和gganimate动画地图,以根据数据集中的另一个变量使地图上的点平滑地增长和缩小。

我发现使用tweenr和gganimate的大多数示例都是针对地块/图形的,而不是针对地图的。我一直在使用transition_time为地图设置动画,但是我无法决定要使用哪个补间功能。

有人有什么建议吗?或者有人可以向我指出正确的方向以找到一些适用的例子吗?

谢谢!

也: 在下面的代码中,您可以看到这些点在彼此之间/离开轨迹之间来回反弹。我不希望那样,我只希望静态点增加和缩小。有什么建议可以解决吗?

这是我测试过的一些代码:

map.zoomB<-ggplot(data = na.lakes,aes(x = long,y = lat)) + 
  geom_polygon(data = na.map,aes(long,lat,group = group),colour = "grey",fill="grey98") + 
  geom_polygon(aes(group = group),fill = "white") + coord_map(projection
               ="mercator",xlim = c(xminA,xmaxA),ylim =
                 c(yminA,ymaxA)) + labs(x = "",y = "") +
  geom_point(aes(x = recvLon,y = recvLat,size=detectperhour),data = year2018.B,alpha=.5) +
  labs(size = 'Daily Detections per Hour Tower Functional')+
  scale_size_continuous(range = c(1,5),breaks = c(10,50,100,500,1000)) +
  theme_bw() 

map.zoomB
combine.map.B <-map.zoomB +
  geom_point(data = year2018.B,aes(x = recvLon,size = detectperhour),alpha = .2) +
  labs(title= "Number of Detections at Each Tower in Atlantic Canada Strat B",subtitle = "Date: {frame_time}",x = "Longitude",y = "Latitude") 


combine.map.B
animate.map.B<- combine.map.B +
  transition_time(Date) +
  enter_appear() +
  shadow_mark(alpha = 0.3,size = 1) 


animate.map.B

map.B.final<-animate(animate.map.B,duration = 90,fps = 20,end_pause = 10)

这是数据:

structure(list(Age = c("Adult","Adult","Juvenile","Juvenile"),doy = c(224L,224L,226L,227L,228L,229L,230L,231L,232L,233L,234L,235L,236L,237L,238L,239L,240L,241L,242L,243L,244L,245L,246L,247L,250L,252L,248L,249L,264L,265L,266L,267L,269L,269L),Date = structure(c(17755,17755,17757,17758,17759,17760,17761,17762,17763,17764,17765,17766,17767,17768,17769,17770,17771,17772,17773,17774,17775,17776,17777,17778,17781,17783,17779,17780,17795,17796,17797,17798,17800,17800),class = "Date"),recvDeployName = c("Johnstons.Point","Johnstons.Point","Baccaro","Beaubassin","Blandford","Eagle.Head.West.berlin","Matthews.Lake","Port.Joli","Port.Mouton","Tintamarre","Wells1","West.Bay","East.Walton","Jordan.Bay","Lockhartville","Linden","Clam.Bay","Selma2","Cap.Bimet","Truro","Sonora","Taylor.Head","Lawrencetown","Cavendish","Johnstons.Point"),Hours = c(24,24,23,14,15.5,22,12.5,24),Strategy = c("B","B","B"),nDet = c(20L,20L,106L,44L,45L,24L,66L,55L,18L,581L,80L,49L,8L,23L,274L,102L,39L,912L,27L,390L,112L,118L,180L,164L,84L,336L,86L,312L,75L,10L,214L,50L,60L,46L,56L,992L,396L,104L,268L,33L,552L,36L,26L,78L,5L,54L,128L,31L,178L,30L,97L,96L,362L,100L,13L,496L,35L,172L,12L,32L,130L,404L,7L,108L,9L,67L,452L,4L,15L,8L),detectperhour = c(0.833333333,0.833333333,4.416666667,1.833333333,1.875,1,2.75,2.291666667,0.75,24.20833333,3.333333333,2.041666667,2.391304348,0.333333333,0.958333333,11.41666667,4.434782609,9.833333333,1.625,38,1.125,16.25,4.666666667,4.916666667,7.5,6.833333333,3.5,3.583333333,9.75,13,3.125,0.416666667,8.916666667,3.571428571,2.5,1.916666667,2.434782609,41.33333333,16.5,4.333333333,17.29032258,1.5,1.083333333,3.25,0.208333333,2.25,5.333333333,1.291666667,7.416666667,1.25,4.041666667,4,15.08333333,4.545454545,2.333333333,0.565217391,20.66666667,1.458333333,7.166666667,0.5,1.333333333,5.416666667,26.06451613,0.291666667,4.5,0.72,2.791666667,18.83333333,0.375,0.166666667,0.625,0.333333333),recvLat = c(46.2,46.2,43.45,45.85,44.5,44.05,43.7,43.8,43.95,45.95,46.1,45.35,45.25,45.1,45.9,44.75,46.25,45.05,44.8,44.65,46.5,46.2),recvLon = c(-64.1,-64.1,-65.5,-64.3,-64.6,-65.05,-64.9,-64.85,-64.25,-64.4,-63.95,-65.25,-64.2,-63.8,-62.9,-63.55,-64.45,-63.35,-61.9,-62.55,-63.3,-63.4,-64.1),Year = c(2018,2018,2018)),row.names = 287:436,class = "data.frame")
iCMS 回答:在静态地图中使用tweenr和gganimate

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2187638.html

大家都在问