forked from comeetie/francepixelsbati-recette
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.Rhistory
265 lines (265 loc) · 13 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
library(sf)
data = read_sf("./BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D001_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15.gpkg")
names(data)
plot(head(data) %>% st_geometry())
head(data) %>% st_geometry()
path "./BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D001_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15.gpkg"
path="./BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D001_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15.gpkg"
st_layers(path)
?read_sf
data = read_sf("./BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D001_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15.gpkg","batiment")
head(data) %>% st_geometry()
head(data)
unique(data$nature)
data$usage_1
unique(data$usage_1)
unique(data$appariement_fichiers_fonciers)
unique(data$date_d_apparition)
unique(data$date_modification)
unique(data$date_d_apparition)
unique(data$date_de_confirmation)
unique(data$sources)
unique(data$origine_du_batiment)
unique(data$date_d_apparition)
unique(substr(data$date_d_apparition,1,4))
as.numeric(substr(data$date_d_apparition,1,4))
substr(data$date_d_apparition,1,4)
data$date_d_apparition
library(dplyr)
data.date = data %>% filer(!is.na(date_d_apparition)) %>% mutate(datecrea = as.numeric(substr(date_d_apparition)))
data.date = data %>% filter(!is.na(date_d_apparition)) %>% mutate(datecrea = as.numeric(substr(date_d_apparition)))
data.date = data %>% filter(!is.na(date_d_apparition)) %>% mutate(datecrea = as.numeric(substr(date_d_apparition,1,4)))
head(data.date)
hist(data.date$datecrea)
unique(data$materiaux_de_la_toiture)
table(data$materiaux_de_la_toiture)
data %>% head() %>% st_centroid()
table(data$materiaux_des_murs)
library(sf)
path="./BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D001_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15.gpkg"
data = read_sf("./BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D001_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15.gpkg","batiment")
library(dplyr)
names(data)
head(data$construction_legere)
head(data$etat_de_l_objet)
unqiue(data$etat_de_l_objet)
unique(data$etat_de_l_objet)
data.date = data %>%
filter(!construction_legere,etat_de_l_objet=="En service") %>%
mutate(datecrea = as.numeric(substr(date_d_apparition,1,4))) %>%
select(datecrea,materiaux_des_murs,materiaux_de_la_toiture,nombre_d_etages) %>%
st_centroid()
plot(data.date %>% slice(1:50000) %>% select(datecrea))
plot(data.date %>% slice(1:50000) %>% select(materiaux_des_murs))
plot(data.date %>% slice(1:50000) %>% select(materiaux_de_la_toiture))
plot(data.date %>% slice(1:50000) %>% select(nombre_d_etages))
write_sf(data.date,"BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D001_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15/bati.geojson")
st_crs(data.date)
pt_in_grid <- function(feat, adm, cellsize = 1000){
grid <- st_make_grid(x = adm, cellsize = cellsize, what = "polygons")
. <- st_intersects(grid, adm)
grid <- grid[sapply(X = ., FUN = length)>0]
. <- st_intersects(grid, feat)
grid <- st_sf(n = sapply(X = ., FUN = length), grid)
return(grid)
}
grid = st_make_grid(data.date,cellsize=200,what="polygons")
plot(grid)
?st_coordinates()
data.date = data.date %>% mutate(x=st_coordinates(geom)[,1],y=st_coordinates(geom)[,2])
data.date$y
data.date = data.date %>% mutate(x=st_coordinates(geom)[,1],y=st_coordinates(geom)[,2],cid=paste(floor(x/200),ceiling(y/200),sep="_"),i=floor(x/200),j=ceiling(y/200))
head(data.date)
head(data.date) %>% select(i,j,cid)
table(data.date$materiaux_de_la_toiture)
data.car = data.date %>% group_by(cid) %>%
summarize(datecrea = mean(datecrea,na.rm=TRUE),
etage=mean(nombre_d_etages),
tuiles=sum(if_else(materiaux_toiure ==10, 1,0)))
data.car = data.date %>% group_by(cid) %>%
summarize(datecrea = mean(datecrea,na.rm=TRUE),
etage=mean(nombre_d_etages),
tuiles=sum(if_else(materiaux_de_la_toiure ==10, 1,0)))
data.car = data.date %>% group_by(cid) %>%
summarize(datecrea = mean(datecrea,na.rm=TRUE),
etage=mean(nombre_d_etages),
tuiles=sum(if_else(materiaux_de_la_toiture ==10, 1,0)))
data.car = data.date %>% st_drop_geometry() %>% group_by(cid) %>%
summarize(datecrea = mean(datecrea,na.rm=TRUE),
etage=mean(nombre_d_etages),
tuiles=sum(if_else(materiaux_de_la_toiture ==10, 1,0)))
head(data.car)
data.car = data.date %>% st_drop_geometry() %>% group_by(cid) %>%
summarize(datecrea = mean(datecrea,na.rm=TRUE),
etage=mean(nombre_d_etages,na.rm=TRUE),
tuiles=sum(if_else(!is.na(materiaux_de_la_toiture) & materiaux_de_la_toiture ==10, 1,0)))
head(data.car)
tail(data.car)
data.car = data.date %>% st_drop_geometry() %>% group_by(cid) %>%
summarize(datecrea = mean(datecrea,na.rm=TRUE),
etage=mean(nombre_d_etages,na.rm=TRUE),
tuiles=sum(if_else(!is.na(materiaux_de_la_toiture) & materiaux_de_la_toiture ==10, 1,0)), n=n())
tail(data.car)
hist(data.car %>% filter(tuiles!=0) %>% pull(tuiles))
hist(data.car %>% pull(n))
hist(data.car %>% filter(tuiles!=0) %>% mutate(p=tuiles/n)%>% pull(p))
hist(data.car %>% filter(is.na(datecrea)) %>% mutate(p=tuiles/n)%>% pull(datecrea))
hist(data.car %>% filter(!is.na(datecrea)) %>% mutate(p=tuiles/n)%>% pull(datecrea))
hist(data.car %>% filter(!is.na(datecrea)) %>% mutate(p=tuiles/n)%>% pull(etage))
library(readr)
data.date = data %>%
filter(!construction_legere,etat_de_l_objet=="En service") %>%
mutate(datecrea = as.numeric(substr(date_d_apparition,1,4))) %>%
select(datecrea,materiaux_des_murs,materiaux_de_la_toiture,nombre_d_etages) %>%
write_sf(data.date %>% st_transform(4326) ,paste0(path,"bati_poly.geojson"))
data.date = data %>%
filter(!construction_legere,etat_de_l_objet=="En service") %>%
mutate(datecrea = as.numeric(substr(date_d_apparition,1,4))) %>%
select(datecrea,materiaux_des_murs,materiaux_de_la_toiture,nombre_d_etages)
write_sf(data.date %>% st_transform(4326) ,paste0(path,"bati_poly.geojson"))
data.date.point = data.date %>% st_centroid() %>% st_transform(4326)
write_sf(data.date.point,paste0(path,"bati_ponctuel.geojson"))
data.car = data.date %>% st_drop_geometry() %>%
mutate(x=st_coordinates(geom)[,1],y=st_coordinates(geom)[,2],cid=paste(floor(x/200),ceiling(y/200),sep="_"),i=floor(x/200),j=ceiling(y/200)) %>%
group_by(cid) %>%
summarize(datecrea = mean(datecrea,na.rm=TRUE),
etage=mean(nombre_d_etages,na.rm=TRUE),
tuiles=sum(if_else(!is.na(materiaux_de_la_toiture) & materiaux_de_la_toiture ==10, 1,0)), n=n())
write_csv(data.car,paste0(path,"bati_carreaux.csv"))
data.date.point = data.date %>% st_centroid()
data.car = data.date.point %>%
mutate(x=st_coordinates(geom)[,1],y=st_coordinates(geom)[,2],cid=paste(floor(x/200),ceiling(y/200),sep="_"),i=floor(x/200),j=ceiling(y/200)) %>%
st_drop_geometry() %>%
group_by(cid) %>%
summarize(datecrea = mean(datecrea,na.rm=TRUE),
etage=mean(nombre_d_etages,na.rm=TRUE),
tuiles=sum(if_else(!is.na(materiaux_de_la_toiture) & materiaux_de_la_toiture ==10, 1,0)), n=n())
write_csv(data.car,paste0(path,"bati_carreaux.csv"))
path
path="./BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D001_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D001-ED2021-03-15/"
write_sf(data.date %>% st_transform(4326) ,paste0(path,"bati_poly.geojson"))
write_sf(data.date.point %>% st_transform(4326) ,paste0(path,"bati_ponctuel.geojson"))
write_csv(data.car,paste0(path,"bati_carreaux.csv"))
unique(data$usage_1)
unique(data$usage_1)
unique(data$usage_1)
is.na(data$materiaux_de_la_toiture)
codes_murs = read_delim("codes_murs.csv",delim="\t")
codes_murs = read_delim("codes_murs.csv",delim=";")
codes_murs = read_delim("codes_murs.csv",delim=";")
codes_murs %>% filter(grepl(nature,"PIERRE"))
codes_murs %>% filter(grepl("PIERRE",nature))
# code mur
# http://piece-jointe-carto.developpement-durable.gouv.fr/NAT004/DTerNP/html3/annexes/desc_pb40_pevprincipale_dmatgm.html
codes_murs = read_delim("codes_murs.csv",delim=";")
code_pierre codes_murs %>% filter(nature=="PIERRE") %>% pull(code)
code_pierre = codes_murs %>% filter(nature=="PIERRE") %>% pull(code)
code_pierres = codes_murs %>% filter(nature=="PIERRE") %>% pull(code)
code_pierre
code_meulieres = codes_murs %>% filter(nature=="MEULIERE") %>% pull(code)
code_meulieres
code_meulieres = codes_murs %>% filter(nature=="BETON") %>% pull(code)
code_betons = codes_murs %>% filter(nature=="BETON") %>% pull(code)
code_betons
code_pierres = codes_murs %>% filter(nature=="PIERRE") %>% pull(code)
code_meulieres = codes_murs %>% filter(nature=="MEULIERE") %>% pull(code)
code_betons = codes_murs %>% filter(nature=="BETON") %>% pull(code)
code_briques = codes_murs %>% filter(nature=="BRIQUES") %>% pull(code)
code_bois = codes_murs %>% filter(nature=="BOIS") %>% pull(code)
code_agglo = codes_murs %>% filter(nature=="AGGLOMERE") %>% pull(code)
codes_pierres = codes_murs %>% filter(nature=="PIERRE") %>% pull(code)
codes_meulieres = codes_murs %>% filter(nature=="MEULIERE") %>% pull(code)
codes_betons = codes_murs %>% filter(nature=="BETON") %>% pull(code)
codes_briques = codes_murs %>% filter(nature=="BRIQUES") %>% pull(code)
codes_bois = codes_murs %>% filter(nature=="BOIS") %>% pull(code)
codes_agglo = codes_murs %>% filter(nature=="AGGLOMERE") %>% pull(code)
data$nature
unique(data$nature)
unique(data$usage_1)
sum(is.na(data$usage_1))
sum(is.na(data$usage_2))
data.car = data.date.point %>%
mutate(x=st_coordinates(geom)[,1],y=st_coordinates(geom)[,2],cid=paste(floor(x/200),ceiling(y/200),sep="_"),i=floor(x/200),j=ceiling(y/200)) %>%
st_drop_geometry() %>%
group_by(cid) %>%
summarize(datecrea = sum(datecrea,na.rm=TRUE),
n_datecrea = sum(!is.na(datecrea)),
etage=sum(nombre_d_etages,na.rm=TRUE),
n_etage = sum(!is.na(nombre_d_etages)),
n_tuiles = sum(if_else(!is.na(materiaux_de_la_toiture) & materiaux_de_la_toiture %in% codes_tuiles, 1,0)),
n_ardoises = sum(if_else(!is.na(materiaux_de_la_toiture) & materiaux_de_la_toiture %in% codes_ardoises, 1,0)),
n_toits = sum(!is.na(materiaux_de_la_toiture)&materiaux_de_la_toiture!=0),
n_pierres = sum(if_else(!is.na(materiaux_des_murs) & materiaux_des_murs %in% codes_pierres, 1,0)),
n_meulieres = sum(if_else(!is.na(materiaux_des_murs) & materiaux_des_murs %in% codes_meulieres, 1,0)),
n_betons= sum(if_else(!is.na(materiaux_des_murs) & materiaux_des_murs %in% codes_betons, 1,0)),
n_briques= sum(if_else(!is.na(materiaux_des_murs) & materiaux_des_murs %in% codes_briques, 1,0)),
n_bois= sum(if_else(!is.na(materiaux_des_murs) & materiaux_des_murs %in% codes_bois, 1,0)),
n_agglo= sum(if_else(!is.na(materiaux_des_murs) & materiaux_des_murs %in% codes_agglo, 1,0)),
n_murs = sum(!is.na(materiaux_des_murs)&materiaux_des_murs!=0),
n_indus = sum(usage_1=="Industriel"),
n_indif = sum(usage_1=="Industriel"),
n_indif = sum(usage_1=="Industriel"),
n_indif = sum(usage_1=="Industriel"),
n_indif = sum(usage_1=="Industriel"),
n_indif = sum(usage_1=="Industriel"),
n_indif = sum(usage_1=="Industriel"),
n_indif = sum(usage_1=="Industriel"),
n=n())
sum(is.na(data$usage_2))
unique(data$usage_1)
path="./BDTOPO_3-0_TOUSTHEMES_GPKG_LAMB93_D005_2021-03-15/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_D005-ED2021-03-15/"
read_csv(paste0(path,"bati_carreaux.csv"))
library(readr)
read_csv(paste0(path,"bati_carreaux.csv"))
data=read_csv(paste0(path,"bati_carreaux.csv"))
data=st_read(paste0(path,"bati_poncteul.geojson"))
library(sf)
data=st_read(paste0(path,"bati_poncteul.geojson"))
data=st_read(paste0(path,"bati_ponctuel.geojson"))
table(data$materiaux_de_la_toiture)
dirs = list.dirs(recursive = FALSE)
for (d in dirs[-1]){
dsplit = strsplit(d,"_")
dep = dsplit[[1]][6]
print(dep)
path=paste0("../bdtopo",d,"/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_",dep,"-ED2021-03-15/bati_poly.geojson")
cat(path)
}
dirs = list.dirs(recursive = FALSE)
for (d in dirs[-1]){
dsplit = strsplit(d,"_")
dep = dsplit[[1]][6]
path=paste0("../bdtopo",d,"/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_",dep,"-ED2021-03-15/bati_poly.geojson")
cat(path)
}
dirs = list.dirs(recursive = FALSE)
for (d in dirs[-1]){
dsplit = strsplit(d,"_")
dep = dsplit[[1]][6]
path=paste0("../bdtopo",d,"/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_",dep,"-ED2021-03-15/bati_poly.geojson ")
cat(path)
}
dirs = list.dirs(recursive = FALSE)
for (d in dirs[-1]){
dsplit = strsplit(d,"_")
dep = dsplit[[1]][6]
path=paste0("../bdtopo",substring(d,2),"/BDTOPO/1_DONNEES_LIVRAISON_2021-04-00014/BDT_3-0_GPKG_LAMB93_",dep,"-ED2021-03-15/bati_poly.geojson ")
cat(path)
}
# code mur
# http://piece-jointe-carto.developpement-durable.gouv.fr/NAT004/DTerNP/html3/annexes/desc_pb40_pevprincipale_dmatgm.html
codes_murs = read_delim("codes_murs.csv",delim=";")
codes_pierres = codes_murs %>% filter(nature=="PIERRE") %>% pull(code)
library(dplyr)
codes_pierres = codes_murs %>% filter(nature=="PIERRE") %>% pull(code)
codes_pierres
codes_meulieres
codes_betons
codes_briques
codes_bois = codes_murs %>% filter(nature=="BOIS") %>% pull(code)
code_agglo
code_bois
code_agglo
dirs = list.dirs("data",recursive = FALSE)
dirs
gc()