# Fires

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE,warning = FALSE,message = FALSE)
```


```{r}
library(giscourse)
conn<-connect()


```


```{r}

#dbListFields(conn,"nat_earth_countries_hi")



```


```{r}
query1<-"select * from nat_earth_countries_hi where name ilike '%roatia%'"
query2<-"select * from fires"


query<-sprintf("select f.* from (%s) c, (%s) f where st_intersects(f.geom,c.geometry)",query1,query2)

query
st_read(conn,query=query) -> croatia_fires

```




```{r}

query1<-"select * from nat_earth_countries_hi where name ilike '%united%ingdom%'"
query2<-"select * from fires"


query<-sprintf("select f.* from (%s) c, (%s) f where st_intersects(f.geom,c.geometry)",query1,query2)

query
st_read(conn,query=query) -> uk_fires
```


```{r}
mapview(uk_fires)
```


```{r}

fires<-rbind(data.frame(country="uk",area=242495,uk_fires),data.frame(country="croatia",area= 56594,croatia_fires))

library(lubridate)

fires$year<-year(fires$day)

library(dplyr)
library(ggplot2)

fires %>% group_by(year,country,area) %>% summarise(n=n()) %>% ggplot(aes(x=year,y=n/area*100,col=country)) + geom_line()
```






