@@ -11,7 +11,7 @@ clean_muni <- function( muni_raw_paths ){
11
11
# all_muni_raw_paths <- list.files(path = paste0('./data_raw/municipios/', year),
12
12
# pattern = '.rds',
13
13
# full.names = TRUE)
14
- # f <- all_muni_raw_paths[16 ]
14
+ # f <- all_muni_raw_paths[20 ]
15
15
#
16
16
# # 6666
17
17
# muni_raw_paths <- all_muni_raw_paths[1]
@@ -116,12 +116,12 @@ clean_muni <- function( muni_raw_paths ){
116
116
# remove geometries with area == 0
117
117
temp_sf <- temp_sf [ as.numeric(sf :: st_area(temp_sf )) != 0 , ]
118
118
119
+ # convert to MULTIPOLYGON
120
+ temp_sf <- to_multipolygon(temp_sf )
121
+
119
122
# simplify
120
123
temp_sf_simplified <- simplify_temp_sf(temp_sf )
121
124
122
- # convert to MULTIPOLYGON
123
- temp_sf <- to_multipolygon(temp_sf )
124
- temp_sf_simplified <- to_multipolygon(temp_sf_simplified )
125
125
126
126
# Make any invalid geom valid # st_is_valid( sf)
127
127
temp_sf <- fix_topoly(temp_sf )
@@ -151,11 +151,12 @@ clean_muni <- function( muni_raw_paths ){
151
151
sf :: st_write(temp2_simplified , i ,
152
152
overwrite = TRUE , append = FALSE ,
153
153
delete_dsn = T , delete_layer = T , quiet = T )
154
- }
154
+ }
155
+
155
156
}
156
157
157
158
# clean all files
158
- pbapply :: pblapply(X = muni_raw_paths , FUN = clean_file )
159
+ pbapply :: pblapply(X = all_muni_raw_paths , FUN = clean_file )
159
160
160
161
# requiredPackages <- c('data.table', 'sf','dplyr', 'sfheaders', 'units',
161
162
# 'lwgeom', 'rgeos', 'sp', 'maptools', 'stringr', 'stringi')
0 commit comments