Skip to content

Commit 71de767

Browse files
committed
removing rgdal and replacing with sf
1 parent d656a27 commit 71de767

3 files changed

Lines changed: 26 additions & 8 deletions

File tree

map/global.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
library(dplyr)
22
library(hash)
3-
library(rgdal)
3+
#library(rgdal)
4+
5+
library(sf)
46

57
#tableTextGlobal <- "old"
68
latestDim <- ""
79
asset <- readRDS("cap_data/joinTable.rds")
810
block <- readRDS("cap_data/block_summary.rds")
9-
dist <- readOGR("boundaries/template_datasets/Zaatari_reference_datasets")
10-
dist <- spTransform(dist, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"))
11+
12+
dist <- st_read("boundaries/")
13+
#dist <- readOGR("boundaries/template_datasets/Zaatari_reference_datasets")
14+
dist <- st_transform(dist, st_crs("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"))
1115

1216
modifiedName = c()
1317
table <- read.csv("asset-map.csv")

map/server.R

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ library(scales)
44
library(lattice)
55
library(dplyr)
66
library(hash)
7-
library(rgdal)
7+
#library(rgdal)
88
library(classInt)
99
library(tidyr)
1010
library(shinyStore)
1111
library(stringi)
12+
library(sp)
1213
source("core.R")
1314

1415
# Leaflet bindings are a bit slow; for now we'll just sample to compensate
@@ -35,9 +36,11 @@ colmat.print <- function(nquantiles = 10, upperleft = rgb(0,150,235, maxColorVal
3536
my.pal.1 <- findColours(my.class,c(upperleft,bottomleft))
3637
my.pal.2 <- findColours(my.class,c(upperright, bottomright))
3738
col.matrix <- matrix(nrow = 101, ncol = 101, NA)
39+
print(my.pal.1[i])
3840
for(i in 1:101){
3941
my.col <- c(paste(my.pal.1[i]),paste(my.pal.2[i]))
40-
col.matrix[102-i,] <- findColours(my.class,my.col)}
42+
col.matrix[102-i,] <- findColours(my.class,my.col)
43+
}
4144
plot(c(1,1),pch = 19,col = my.pal.1, cex = 0.5,xlim = c(0,1),ylim = c(0,1),frame.plot = F, xlab = xlab, ylab = ylab,cex.lab = 1.3)
4245
for(i in 1:101){
4346
col.temp <- col.matrix[i-1,]
@@ -135,6 +138,8 @@ function(input, output, session) {
135138
newVal <- paste0(ele,"---",eval(parse(text=paste0("input$store$",ele))))
136139
extraList = c(extraList, newVal)
137140
}
141+
142+
print(storeNames)
138143
sumData(joinTable,extraList = extraList)
139144
}, ignoreNULL = FALSE)
140145

@@ -326,14 +331,19 @@ function(input, output, session) {
326331
z[is.na(z)] <- 0
327332
z[startsWith(z,"#")] <- .75
328333

329-
leafletProxy("map", data = dist) %>% clearShapes() %>%
334+
#print(z)
335+
#print(unique(col.matrix)[x])
336+
337+
leafletProxy("map", data = st_zm(dist)) %>% clearShapes() %>%
330338
addPolygons(color = "#444444", weight = 0.01, smoothFactor = 1.0,
331339
opacity = .75, fillOpacity = z,
332340
fillColor=unique(col.matrix)[x]
333341
#highlightOptions = highlightOptions(weight = 1,
334342
# color = "white",
335343
# bringToFront = TRUE)
344+
336345
)
346+
337347
})
338348

339349
# # Show a popup at the given location
@@ -344,9 +354,13 @@ function(input, output, session) {
344354
coords <- as.data.frame(cbind(lng, lat))
345355
point <- SpatialPoints(coords)
346356
proj4string(point) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
357+
point <- st_as_sf(point, coords = c('y', 'x'), crs = st_crs(map))
347358
findDistrictinDist <- dist[point,]
359+
360+
348361
findDistrict <- block()[block()$block == findDistrictinDist$Block & block()$district == findDistrictinDist$District,]
349-
362+
363+
print(findDistrict)
350364
popupTagList <- tagList(
351365
tags$h4("District",findDistrict$district,"- Block",findDistrict$block),
352366
tags$h4("Total Residents: ",findDistrict$sum_household),

map/ui.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
library(leaflet)
2-
library(rgdal)
2+
#library(rgdal)
33
library(shinydashboard)
44
library(shiny)
55
library(shinyStore)

0 commit comments

Comments
 (0)