Skip to content

Commit

Permalink
summariseRSUs function returns the number of geometries and their mea…
Browse files Browse the repository at this point in the history
…n area by values of a given variable, either on initial geometries or by geometries aggregated if they touch
  • Loading branch information
MGousseff committed Dec 30, 2024
1 parent 36557f2 commit 554a264
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 841 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export(loadMultipleSf)
export(matConfLCZ)
export(matConfLCZGlob)
export(multipleCramer)
export(plotLCZaLocation)
export(produceAnalysis)
export(showLCZ)
export(standLevCol)
Expand All @@ -40,7 +41,6 @@ import(tidyr)
import(units)
import(utils)
importFrom(caret,dummyVars)
importFrom(confintr,cramersv)
importFrom(forcats,fct_recode)
importFrom(ggplot2,aes)
importFrom(ggplot2,geom_sf)
Expand Down
16 changes: 8 additions & 8 deletions R/ConcatAllLocationsAllWf.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ for( i in 1:length(dirList)){
allLocAllWfSf<- st_as_sf(allLocAllWfSf)
}

rootDir<-"/home/gousseff/Documents/3_data/data_article_LCZ_diff_algos/newDataTree"
setwd(rootDir)
allLCZDirNames <- list.dirs()[-1]
allLCZDirNames <- substr(allLCZDirNames, start = 2, stop = 1000)
allLocationsNames<-substr(allLCZDirNames, start = 2, stop = 1000)
allLCZDirNames<-paste0(rootDir, allLCZDirNames, "/")
allLocallWfs<-concatIntersectedLocations(
dirList = allLCZDirNames, locations = allLocationsNames , workflowNames = c("osm","bdt","iau","wudapt"))
# rootDir<-"/home/gousseff/Documents/3_data/data_article_LCZ_diff_algos/newDataTree"
# setwd(rootDir)
# allLCZDirNames <- list.dirs()[-1]
# allLCZDirNames <- substr(allLCZDirNames, start = 2, stop = 1000)
# allLocationsNames<-substr(allLCZDirNames, start = 2, stop = 1000)
# allLCZDirNames<-paste0(rootDir, allLCZDirNames, "/")
# allLocallWfs<-concatIntersectedLocations(
# dirList = allLCZDirNames, locations = allLocationsNames , workflowNames = c("osm","bdt","iau","wudapt"))
2 changes: 1 addition & 1 deletion R/plotLCZaLocation.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ plotLCZaLocation<-function(dirPath, location, workflowNames = c("osm","bdt","iau

surfaces<-concatSf %>%
mutate(wf = factor(wf, levels = c("bdt", "osm", "wudapt", "iau"))) %>%
group_by(wf, lcz_primary) %>% summarise(area=sum(area), location=unique(location))
dplyr::group_by(wf, lcz_primary) %>% dplyr::summarise(area=sum(area), location=unique(location))

location<-unique(surfaces$location)
outPlot<-ggplot(surfaces, aes(fill=lcz_primary, y=area, x=wf)) +
Expand Down
49 changes: 49 additions & 0 deletions R/summariseRSUs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
summariseRSUs<-function(sf, column ){
# sf<-sf %>% mutate(area=st_area(geometry)) %>% st_drop_geometry() %>% as.data.frame

unClustered <-sf %>% group_by(.data[[column]]) %>%
summarise(numberRSUs=n(), meanArea = mean(st_area(geometry))) %>% st_drop_geometry()

clustered <-sf %>% group_by(.data[[column]]) %>% summarise(geometry = st_union(geometry))
clustered <- lapply(1:nrow(clustered), function(i) {
st_cast(clustered[i, ], "POLYGON")
}) %>%
do.call(rbind, .)
clustered <- clustered %>%group_by(.data[[column]]) %>% summarise(numberRSUs=n(), meanArea = mean(st_area(geometry))) %>% st_drop_geometry
output <- list(unClustered = unClustered, clustered = clustered)
return(output)
}

osm<-importLCZvect(dirPath = "/home/gousseff/Documents/3_data/data_article_LCZ_diff_algos/newDataTree/Dourdan/",
file = "osm_lcz.fgb")
osm %>% group_by(LCZ_PRIMARY) %>% summarise(geometry = st_union(geometry))
showLCZ(osm)
test<-summariseRSUs(osm, column ="LCZ_PRIMARY")

osm2<-osm %>% group_by(LCZ_PRIMARY) %>% summarise() %>% ungroup

osm3<-lapply(1:nrow(osm2), function(i) {
st_cast(osm2[i, ], "POLYGON")
}) %>%
do.call(rbind, .)

osm3 %>% group_by(LCZ_PRIMARY) %>% summarise(numberRSUs=n(), meanArea = mean(st_area(geometry)))

showLCZ(osm3)


osm3 <-aggregate(osm, by = osm2, do_union = FALSE)
x,
by,
FUN,
...,
do_union = TRUE,
simplify = TRUE,
join = st_intersects
)


group_by(LCZ_PRIMARY) %>% summarise %>% ungroup %>% st_cast("POLYGON")

st_area(osm2)
showLCZ(osm2)
831 changes: 0 additions & 831 deletions docs/articles/joss/paper.html

This file was deleted.

0 comments on commit 554a264

Please sign in to comment.