Closed zacharyDez closed 2 months ago
@zacharyDez
I couldn't verify that the notebook worked all the way, my computer hung on the do.call
that combines all the dataframes together.
So I jumped down a rabbit whole of doing it a different way, which I think is much faster, though not as pretty to read.
Note: I also tried using httr2
instead which I think is a little more user friendly for building API requests.
library(httr2)
# Request the summary data
req <- request(base_url) |>
req_url_path("/summary") |>
req_body_json(request_payload)
resp <- req |> req_perform()
resp
#Turn response into a geodataframe (aka sf object)
df <- resp |> resp_body_string() |> fromJSON(flatten = TRUE)
df$x <- sapply(df$geometry.coordinates, function(x){unlist(x)[1]} )
df$y <- sapply(df$geometry.coordinates, function(x){unlist(x)[2]} )
# convert to sf, drop extra geometry fields
gdf <- st_as_sf(df, coords = c("x", "y"), crs = 4326)[,c(1,2,5)]
Only other note, is that the bins on the plot are very uniform, and I'm wondering if the linear scaled applied it the best given the data. Is this Population or Population Change? the lowest value for population is 0, and that should probably be a very different color than 1-200,000
@wildintellect, thanks for your detailed and precise feedback. It makes a huge difference in the geodata frame creation, and your pointer on the bins makes the map more adapted to the population variable.
@bpstewar @andresfchamorro, could you provide some feedback on the R notebook, or would someone else at the Bank be better positioned? This is more on the user-facing side. Alex has already provided feedback on industry best practices, but it would be useful to hear from you.
@andresfchamorro, please keep me updated on feedback from Chevron and Brian. I'd love to merge this soon! It brings a nicer classification for the Python notebook also.
@zacharyDez this works great. good to see the performance improvement and the syntax makes sense to me
What I Changed
How to Test it
Other Notes