diff --git a/.Rbuildignore b/.Rbuildignore index 1a3fea3..81fcff8 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -11,6 +11,7 @@ # CI & codecov-related ^\.travis\.yml$ +^\.lintr$ ^logo_maker.R$ ^_pkgdown\.yml$ diff --git a/DESCRIPTION b/DESCRIPTION index efbe44f..05880f8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: geohashTools -Version: 0.3.2.9999 +Version: 0.3.3 Title: Tools for Working with Geohashes Authors@R: c( person('Michael', 'Chirico', role = c('aut', 'cre'), email = 'MichaelChirico4@gmail.com'), diff --git a/README.Rmd b/README.Rmd index 0ae5cf2..a7106ab 100644 --- a/README.Rmd +++ b/README.Rmd @@ -47,22 +47,30 @@ The park is quite large, and this is too precise to cover the park; we can "zoom gh_encode(11.3113917, -74.0779006, precision = 5L) ``` + + ### Public Art in Chicago -We can use this as a simple, regular level of spatial aggregation for spatial points data, e.g., counting presence of public art throughout the city of Chicago, as captured in [this dataset](https://data.cityofchicago.org/Parks-Recreation/Parks-Public-Art/sj6t-9cju) provided by the City: +We can use this as a simple, regular level of spatial aggregation for spatial points data, e.g., counting presence of public art throughout the city of Chicago, as captured in a dataset + + + +provided by the City: + +NB: As of this writing, the Chicago data portal is down, apparently temporarily. However I'd like to submit this package update to CRAN in order to avoid deprecation issues around {rgdal} & co, so please check back on the website for a working version of the code below. ```{r chicago_art} ## first, pull the data internally from https://data.cityofchicago.org -api_stem = 'https://data.cityofchicago.org/api/views' -URL = file.path(api_stem, 'sj6t-9cju/rows.csv?accessType=DOWNLOAD') +# api_stem = 'https://data.cityofchicago.org/api/views' +# URL = file.path(api_stem, 'sj6t-9cju/rows.csv?accessType=DOWNLOAD') -suppressPackageStartupMessages(library(data.table)) -art = fread(URL) +# suppressPackageStartupMessages(library(data.table)) +# art = fread(URL) # count art by geohash -gh_freq = art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 5L))] +# gh_freq = art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 5L))] # only show the top 10 -gh_freq[order(-N)][1:10] +# gh_freq[order(-N)][1:10] ``` This is pretty impractical _per se_ (where is `dp3wm`?); we'll return to this once we've introduced more functionality. @@ -118,23 +126,23 @@ Returning to public art locations in Chicago, we can visualize the spatial aggre library(sf) ## first, pull neighborhood shapefiles from https://data.cityofchicago.org -tmp = tempfile(fileext = '.zip') -shp_url = file.path( - api_stem, '9wp7-iasj', 'files', - 'TMTPQ_MTmUDEpDGCLt_B1uaiJmwhCKZ729Ecxq6BPfM?filename=Neighborhoods_2012.zip' -) -download.file(shp_url, tmp) - -chicago = paste0('/vsizip/', tmp) |> - st_read(quiet = TRUE) |> - st_transform(crs = 4326L) - -artSF = gh_to_sf( - art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 6L))], - gh_col = 'geohash' -) -plot(st_geometry(chicago), lwd = 0.5, main = 'Public Art Locations in Chicago') -plot(artSF['N'], add = TRUE) +# tmp = tempfile(fileext = '.zip') +# shp_url = file.path( +# api_stem, '9wp7-iasj', 'files', +# 'TMTPQ_MTmUDEpDGCLt_B1uaiJmwhCKZ729Ecxq6BPfM?filename=Neighborhoods_2012.zip' +# ) +# download.file(shp_url, tmp) + +# chicago = paste0('/vsizip/', tmp) |> +# st_read(quiet = TRUE) |> +# st_transform(crs = 4326L) + +# artSF = gh_to_sf( +# art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 6L))], +# gh_col = 'geohash' +# ) +# plot(st_geometry(chicago), lwd = 0.5, main = 'Public Art Locations in Chicago') +# plot(artSF['N'], add = TRUE) ``` Chicago connoisseurs will recognize the biggest concentration around Lincoln Park, with another concentration along the waterfront near Millenium/Grant Parks. diff --git a/README.md b/README.md index 152198b..6858431 100644 --- a/README.md +++ b/README.md @@ -43,37 +43,31 @@ gh_encode(11.3113917, -74.0779006, precision = 5L) ## [1] "d6526" ``` + + ### Public Art in Chicago -We can use this as a simple, regular level of spatial aggregation for spatial points data, e.g., counting presence of public art throughout the city of Chicago, as captured in [this dataset](https://data.cityofchicago.org/Parks-Recreation/Parks-Public-Art/sj6t-9cju) provided by the City: +We can use this as a simple, regular level of spatial aggregation for spatial points data, e.g., counting presence of public art throughout the city of Chicago, as captured in a dataset + + + +provided by the City: + +NB: As of this writing, the Chicago data portal is down, apparently temporarily. However I'd like to submit this package update to CRAN in order to avoid deprecation issues around {rgdal} & co, so please check back on the website for a working version of the code below. ```r ## first, pull the data internally from https://data.cityofchicago.org -api_stem = 'https://data.cityofchicago.org/api/views' -URL = file.path(api_stem, 'sj6t-9cju/rows.csv?accessType=DOWNLOAD') +# api_stem = 'https://data.cityofchicago.org/api/views' +# URL = file.path(api_stem, 'sj6t-9cju/rows.csv?accessType=DOWNLOAD') -suppressPackageStartupMessages(library(data.table)) -art = fread(URL) +# suppressPackageStartupMessages(library(data.table)) +# art = fread(URL) # count art by geohash -gh_freq = art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 5L))] +# gh_freq = art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 5L))] # only show the top 10 -gh_freq[order(-N)][1:10] -``` - -``` -## geohash N -## 1: dp3wm 46 -## 2: dp3wn 42 -## 3: dp3wt 16 -## 4: dp3wq 13 -## 5: dp3wk 10 -## 6: dp3wj 9 -## 7: dp3ty 9 -## 8: dp3w7 8 -## 9: dp3tw 6 -## 10: dp3wu 4 +# gh_freq[order(-N)][1:10] ``` This is pretty impractical _per se_ (where is `dp3wm`?); we'll return to this once we've introduced more functionality. @@ -180,29 +174,24 @@ Returning to public art locations in Chicago, we can visualize the spatial aggre library(sf) ## first, pull neighborhood shapefiles from https://data.cityofchicago.org -tmp = tempfile(fileext = '.zip') -shp_url = file.path( - api_stem, '9wp7-iasj', 'files', - 'TMTPQ_MTmUDEpDGCLt_B1uaiJmwhCKZ729Ecxq6BPfM?filename=Neighborhoods_2012.zip' -) -download.file(shp_url, tmp) - -chicago = paste0('/vsizip/', tmp) |> - st_read(quiet = TRUE) |> - st_transform(crs = 4326L) - -artSF = gh_to_sf( - art[, .N, by = .(geohash = gh_encode(LATITUDE, LONGITUDE, 6L))], - gh_col = 'geohash' -) -plot(st_geometry(chicago), lwd = 0.5, main = 'Public Art Locations in Chicago') -plot(artSF['N'], add = TRUE) -``` - -