ipeaGIT / aopdata

Download data from the Access to Opportunities Project (AOP)
https://ipeagit.github.io/aopdata/
13 stars 4 forks source link

Filter only available cities when reading access for public transport #43

Closed kauebraga closed 2 years ago

kauebraga commented 2 years ago

Right now, the behavior when trying to download accessibility by public transport for all cities returns an error:

# download data
aop_data <- aopdata::read_access(city = "all", mode = "public_transport", year = 2019, geometry = TRUE)

`Using mode public_transport
Downloading accessibility data for the year 2019
  |======================================================================================================| 100%
Error in aopdata::read_access(city = "all", mode = "public_transport",  : 
  One of the selected cities does not have public transport data for that year.`

I think it would be nice to pre-filter only cities with public transport for that year and return the accessibility estimates for them, instead of returning an error. A message indicating the cities would be nice as well.

rafapereirabr commented 2 years ago

I thought I had fixed this [rolling eye emoji]

igorlaltuf commented 2 years ago

Even when I specify the city, the function doesn't seem to work.

> aopdata::read_access(city = 'Rio de Janeiro')
Using mode walk
Downloading accessibility data from the year 2019
  |===================================================================================| 100%
Downloading land use data from the year 2019
Downloading population data from year 2010
Error in data.table::setkeyv(aop_access, c("abbrev_muni", "name_muni",  : 
  some columns are not in the data.table: name_muni,code_muni
rafapereirabr commented 2 years ago

@igorlaltuf , I belive you are using and earlier version of the package. Please try installing the latest dev version from github

utils::remove.packages('aopdata')

devtools::install_github("ipeaGIT/aopdata", subdir = "r-package")
library(aopdata)

df <- aopdata::read_access(city = 'Rio de Janeiro')
igorlaltuf commented 2 years ago

@rafapereirabr , thank you! Worked perfectly. I'm organizing an introductory R class for my labmates and I'm going to use the aopdata package as an example of the potential that R has in urban studies research. Congratulations on the work.

rafapereirabr commented 2 years ago

Thank you, @igorlaltuf . We are currently working on an online book with a hands-on approach to accessibilty modeling in R. We should have a 1st version ready by September 2022

rafapereirabr commented 2 years ago

Solved. Please try usig the updated dev version and let me know if the problem persists.

utils::remove.packages('aopdata')

devtools::install_github("ipeaGIT/aopdata", subdir = "r-package")
library(aopdata)