Commit e712eada authored by Boulangeat Isabelle's avatar Boulangeat Isabelle
Browse files

new version

parent fc2ccdc6
......@@ -341,6 +341,155 @@ summary(zp_releve$n)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.000 1.000 2.000 4.529 5.000 69.000
``` r
zp = readOGR("Extract_raster_zp(20_02_2020)", "CEPAZ_ZP")
```
## OGR data source with driver: ESRI Shapefile
## Source: "/Users/isabelleboulangeat/Documents/PROJETS/(CEPAZ)/cepaz-git/Extract_raster_zp(20_02_2020)", layer: "CEPAZ_ZP"
## with 5084 features
## It has 48 fields
## Integer64 fields read as strings: Join_Count TARGET_FID ORIG_FID
``` r
head(zp@data)
```
## Join_Count TARGET_FID CODE INSEEDEP INSEECOM NOM1 NOM2 SURFACE
## 0 1 0 ZP0405001 04 04050 LES MAYOLS MAYOLS 221.82
## 1 1 1 ZP0405002 04 04050 LES JAUMES <NA> 403.12
## 2 1 2 ZP0405701 04 04057 CLOT GARCIN <NA> 143.60
## 3 1 3 ZP0405702 04 04057 LES GRAVES <NA> 129.17
## 4 1 4 ZP0405703 04 04057 BANE <NA> 65.45
## 5 1 5 ZP0405704 04 04057 ROUAST <NA> 29.38
## SURF_MNT ETAGE_ALT PROP_TYPE1 PROP_REG USAGE MOTIF TRAITE
## 0 228.56 PM COM N O <NA> N
## 1 425.98 PM COM N O <NA> N
## 2 153.11 PM COM N O <NA> N
## 3 135.37 PM COM N O <NA> N
## 4 70.25 PM COM N N probl\303\250mes fonciers N
## 5 30.97 PM COM N O <NA> N
## TRANSFORM PHAE MAE SURF_MAE ANNEE_REF SOURCE ID_SOURCE AUT_SOURCE PROP_TYPE2
## 0 N N N 0 2012 CERPAM <NA> <NA> PRI
## 1 N N N 0 2012 CERPAM <NA> <NA> PRI
## 2 N N N 0 2012 CERPAM <NA> <NA> PRI
## 3 N N N 0 2012 CERPAM <NA> <NA> PRI
## 4 N N N 0 2012 CERPAM <NA> <NA> PRI
## 5 N N N 0 2012 CERPAM <NA> <NA> PRI
## PROP_TYPE3 DERN_USAGE EXPLOIT TYPE1 TYPE2 TYPE3 PRINTEMPS ETE AUTOMNE HIVER
## 0 N <NA> 1 OA <NA> <NA> O O O N
## 1 N <NA> 1 EQ <NA> <NA> O O O O
## 2 N <NA> 1 OA <NA> <NA> O O O O
## 3 N <NA> 0 <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## 4 N 2009 0 <NA> <NA> <NA> <NA> <NA> <NA> <NA>
## 5 N <NA> 1 AB <NA> <NA> O O N N
## EF_OV_15J EF_CA_15J EF_VL_15J EF_AB_15J EF_EQ_15J CH_MAX_OV CH_MAX_CA
## 0 250 0 0 0 0 250 0
## 1 0 0 0 0 15 0 0
## 2 300 0 0 0 0 300 0
## 3 0 0 0 0 0 0 0
## 4 0 0 0 0 0 0 0
## 5 25 0 0 0 0 0 0
## CH_MAX_VL CH_MAX_AB CH_MAX_EQ DFCI MILIEU ENQUETEUR ORIG_FID
## 0 0 0 0 N L DB 0
## 1 0 0 15 N L DB 0
## 2 0 0 0 N D DB 0
## 3 0 0 0 N H DB 0
## 4 0 0 0 N L DB 0
## 5 0 0 0 N H DB 0
``` r
zp_n = merge(zp, zp_releve, by = "CODE")
zp_n$CBNA = ifelse(is.na(zp_n$n), 0, 1)
```
Nb de ZP dans territoire agrement CBNA
--------------------------------------
``` r
CBNA = readOGR(".", "CBNA")
```
## OGR data source with driver: ESRI Shapefile
## Source: "/Users/isabelleboulangeat/Documents/PROJETS/(CEPAZ)/cepaz-git", layer: "CBNA"
## with 1 features
## It has 11 fields
## Integer64 fields read as strings: ID_GEOFLA
``` r
CBNA_proj = spTransform(CBNA, CRS("+init=epsg:4326"))
library(leaflet)
zp_n_proj <- spTransform(zp_n, CRS("+init=epsg:4326")) # Reproject coordinates
qpal <- colorBin(c("red", "blue"), zp_n_proj$CBNA, bins=3)
# qpal <- colorQuantile("Greens", zp_n_proj$n, n = 2, reverse = TRUE)
# leaflet(zp_n_proj) %>%
# addPolygons(stroke = TRUE,opacity = 1,fillOpacity = 0.5, smoothFactor = 0.5, color=NA,fillColor = ~qpal(CBNA),weight = 1,) %>%
# addLegend(values=~CBNA,pal=qpal, labels = c("aucune", "au moins une"), labFormat = "factor", title="observations CBNA") %>%
# addProviderTiles("CartoDB.Positron") %>%
# addPolygons(data = CBNA_proj, fill = F, weight = 2, color = "black")
table(zp_n$CBNA)
```
##
## 0 1
## 4912 172
``` r
library(rgeos)
```
## rgeos version: 0.5-3, (SVN revision 634)
## GEOS runtime version: 3.8.1-CAPI-1.13.3
## Linking to sp version: 1.4-2
## Polygon checking: TRUE
``` r
index = lapply(1:nrow(zp_n_proj), function(x){gWithin(zp_n_proj[x,], CBNA_proj)})
sum(unlist(index))
```
## [1] 3948
``` r
sum(unlist(index)) / nrow(zp_n_proj)
```
## [1] 0.7765539
``` r
table(zp_n$CBNA, zp_n$INSEEDEP)
```
##
## 01 04 05 06 13 26 38 73 74 83 84
## 0 7 922 542 220 217 972 291 304 769 369 299
## 1 1 42 17 0 0 36 27 35 13 0 1
``` r
table(zp_n$CBNA, zp_n$MILIEU)
```
##
## B D H L
## 0 1536 293 1882 1175
## 1 39 25 73 35
``` r
# > table(zp_n$CBNA, zp_n$INSEEDEP)
#
# 01 04 05 06 13 26 38 73 74 83 84
# 0 7 922 542 220 217 972 291 304 769 369 299
# 1 1 42 17 0 0 36 27 35 13 0 1
# > table(zp_n$CBNA, zp_n$MILIEU)
#
# B D H L
# 0 1536 293 1882 1175
# 1 39 25 73 35
```
Diversité alpha des ZP
======================
......@@ -536,18 +685,50 @@ length(sp_points_zp) # 2146
## [1] 2146
``` r
length(unique(sp_zp_2013$CODE))
```
## [1] 742
``` r
statuts_all$UICN =as.factor(statuts_all$UICN)
levels(statuts_all$UICN) = c("CR","CR","DD","EN","EW","LC", "NE" ,"NT", "RE", "VU")
table(unique(statuts_all[, c("numtaxon", "UICN")])$UICN)
```
##
## CR DD EN EW LC NE NT RE VU
## 53 433 116 2 2431 186 173 13 164
``` r
aa = table(unique(statuts_all[, c("numtaxon", "UICN")])$UICN) / length(sp_points)
sum(is.na(unique(statuts_all[, c("numtaxon", "UICN")])$UICN))/ length(sp_points)
```
## [1] 0.3630039
``` r
aa
```
##
## CR DD EN EW LC NE
## 0.0094541563 0.0772386729 0.0206921156 0.0003567606 0.4336425259 0.0331787371
## NT RE VU
## 0.0308597931 0.0023189440 0.0292543703
``` r
sp_zp_2013$UICN =as.factor(sp_zp_2013$lr_fr)
table(unique(sp_zp_2013[, c("numtaxon", "UICN")])$UICN)
```
##
## DD EN LC NT VU
## 33 4 1628 28 4
``` r
zp = table(unique(sp_zp_2013[, c("numtaxon", "UICN")])$UICN) / length(sp_points_zp)
sum(is.na(unique(sp_zp_2013[, c("numtaxon", "UICN")])$UICN))/ length(sp_points_zp)
```
......@@ -556,7 +737,14 @@ sum(is.na(unique(sp_zp_2013[, c("numtaxon", "UICN")])$UICN))/ length(sp_points_z
``` r
zp_vec = unclass(zp)
zp
```
##
## DD EN LC NT VU
## 0.015377446 0.001863933 0.758620690 0.013047530 0.001863933
``` r
library(reshape2)
rbind(unclass(aa),c(CR=0, zp_vec[1:2], EW=0, zp_vec[3], NE=0, zp_vec[4], RE=0, zp_vec[5])) %>% melt() %>%
ggplot(aes(x = Var2, y = value, fill = factor(Var1))) +
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment