Git Product home page Git Product logo

cra-pbi's Introduction

Introducción a datos e información de pronósticos para construir mapas de PBI

🔵 Ejemplos:

  • 🌧️ Niño Costero Perú 2017
  • 🌀 Tifón Molave Vietnam 2020

🔵 Intento de automatización usando el ecosistema espacial de R

  • Requerimientos:
    • rgee
    • tidyverse
    • sf
    • mapview

Activación de paquetes necesarios

library(tidyverse)
library(sf)
library(mapview)
library(rgee)
ee_Initialize(user = "[email protected])

Lectura de datos

pronostico <- st_read("resources/Tifon/datos_tifon2020.gpkg",layer = "pronostico")
limites <- st_read("resources/Tifon/datos_tifon2020.gpkg",layer = "admin1")

Función para calcular la posible afectacción

zona_impactada <- function(x){
  # Nivel de pronostico
  nivel <- pronostico[x,]
  # Intersección de capas
  nuevos_limites <- st_intersection(x = limites,y = nivel) %>% 
    dplyr::select(ADM1_EN,value) %>% 
    sf_as_ee()
  # Datos de población de Earth Engine
  poblacion_estimada <- ee$ImageCollection$Dataset$WorldPop_GP_100m_pop$
    select('population')$
    filter(ee$Filter$calendarRange(2020,2020, "year"))$
    mosaic()$
    rename('pop')
 # Estadistica zonal 
  stat_general <- ee_extract(
    x = poblacion_estimada,
    y = nuevos_limites,
    fun = ee$Reducer$sum(),
    scale = 100)
  stat_final <- stat_general %>% 
    mutate(pop = round(pop,0))
  return(stat_final)
}

# Resultados finales en listas
lista_stat <- lapply(X = 1:3,FUN = zona_impactada) 

Cuadro estadístico

datos_finales <- lista_stat %>% 
  map_df(.f = as_tibble) %>% 
  group_by(value) %>% 
  summarise(pop = sum(pop,na.rm = TRUE))
# A tibble: 3 × 3
   ...1 value       pop
  <dbl> <chr>     <dbl>
1     1 < 5     6520944
2     2 > 90    5314314
3     3 30 - 40 2175340

cra-pbi's People

Contributors

ambarja avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.