cyipt / acton

Active Transport Options for New Developments
https://cyipt.github.io/acton/
GNU General Public License v3.0
3 stars 2 forks source link

Add additional arguments to get_planit_data() #16

Closed Robinlovelace closed 4 years ago

Robinlovelace commented 4 years ago

Format

URL schema

Query params:

Robinlovelace commented 4 years ago

Heads-up @joeytalbot I think #15 is good to go. Please try to reproduce this on your computer and let me know if you find any issues (next comment).

Robinlovelace commented 4 years ago

Heads-up @joeytalbot and @mvl22 can you try to run the following lines on your computers?

If you can reproduce the results shown below, I think that's good enough to close this issue for now, fast progress 🎉 if so!

remotes::install_github("cyipt/acton", "planit-api2")
library(acton)
bbox = c(-1.4, 53.7, -1.3, 53.8)
res = get_planit_data(bbox) # return geographic (`sf`) object
class(res)
res
get_planit_data(bbox, fmt = "json") # return data frame
get_planit_data(bbox, end_date = "2008-01-01") # historic data
get_planit_data(bbox, pcode = "LS2 9JT") # data from specific postcode
res = get_planit_data(bbox, limit = 20, krad = 9) # return geographic (`sf`) object
mapview::mapview(res)
remotes::install_github("cyipt/acton", "planit-api2")
#> Skipping install of 'acton' from a github remote, the SHA1 (58618ac9) has not changed since last install.
#>   Use `force = TRUE` to force installation
library(acton)
bbox = c(-1.4, 53.7, -1.3, 53.8)
res = get_planit_data(bbox) # return geographic (`sf`) object
#> Getting data from https://www.planit.org.uk/api/applics/geojson?limit=6&bbox=-1.4%2C53.7%2C-1.3%2C53.8&end_date=2020-01-08&start_date=2000-02-01&pg_sz=6
class(res)
#> [1] "sf"         "tbl_df"     "tbl"        "data.frame"
res
#> Simple feature collection with 6 features and 16 fields
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: -1.398203 ymin: 53.72102 xmax: -1.357085 ymax: 53.79595
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +datum=WGS84 +no_defs
#> # A tibble: 6 x 17
#>   doc_type name  url   description when_updated        authority_id source_url
#>   <chr>    <chr> <chr> <chr>       <dttm>                     <int> <chr>     
#> 1 PlanApp… Leed… http… Alteration… 2020-01-07 17:51:35          292 https://p…
#> 2 PlanApp… Leed… http… Certificat… 2020-01-07 10:59:32          292 https://p…
#> 3 PlanApp… Wake… http… Change of … 2020-01-07 02:38:01          293 https://p…
#> 4 PlanApp… Wake… http… Residentia… 2020-01-07 02:38:01          293 https://p…
#> 5 PlanApp… Leed… http… Reserved M… 2020-01-07 10:59:32          292 https://p…
#> 6 PlanApp… Leed… http… Single sto… 2020-01-07 17:49:45          292 https://p…
#> # … with 10 more variables: authority_name <chr>, link <chr>, postcode <chr>,
#> #   address <chr>, lat <dbl>, lng <dbl>, start_date <date>, uid <chr>,
#> #   altid <chr>, geometry <POINT [°]>
get_planit_data(bbox, fmt = "json") # return data frame
#> Getting data from https://www.planit.org.uk/api/applics/json?limit=6&bbox=-1.4%2C53.7%2C-1.3%2C53.8&end_date=2020-01-08&start_date=2000-02-01&pg_sz=6
#>     doc_type                   name
#> 1 PlanApplic      Leeds/19/07662/FU
#> 2 PlanApplic     Leeds/19/07837/CLP
#> 3 PlanApplic Wakefield/19/02825/FUL
#> 4 PlanApplic Wakefield/19/02827/FUL
#> 5 PlanApplic      Leeds/19/07688/RM
#> 6 PlanApplic      Leeds/19/07584/FU
#>                                                                                                                  url
#> 1 https://publicaccess.leeds.gov.uk/online-applications/applicationDetails.do?activeTab=summary&keyVal=Q2EDP8JB0C000
#> 2 https://publicaccess.leeds.gov.uk/online-applications/applicationDetails.do?activeTab=summary&keyVal=Q2SU9AJBG6I00
#> 3 https://planning.wakefield.gov.uk/online-applications/applicationDetails.do?activeTab=summary&keyVal=Q2PEL4QQI6C00
#> 4 https://planning.wakefield.gov.uk/online-applications/applicationDetails.do?activeTab=summary&keyVal=Q2PFSBQQ07R00
#> 5 https://publicaccess.leeds.gov.uk/online-applications/applicationDetails.do?activeTab=summary&keyVal=Q2G6LZJBIPF00
#> 6 https://publicaccess.leeds.gov.uk/online-applications/applicationDetails.do?activeTab=summary&keyVal=Q2ABLHJBN0C00
#>                                                                                                                                    description
#> 1                                                            Alterations to garage for use as therapy room and single storey extension to rear
#> 2                                                             Certificate of Proposed Lawful Development for an extension to the side and rear
#> 3                                    Change of use of a dwelling to 8 no. flats including single storey extension to side and associated works
#> 4                                                                                                    Residential development for 4no dwellings
#> 5 Reserved Matters application for 134 dwellings, including appearance, landscaping, layout and scale pursuant to Outline approval 17/05759/OT
#> 6                                                                                                                 Single storey rear extension
#>                       when_updated authority_id
#> 1 2020-01-07T17:51:35.468000+00:00          292
#> 2 2020-01-07T10:59:32.614000+00:00          292
#> 3 2020-01-07T02:38:01.578000+00:00          293
#> 4 2020-01-07T02:38:01.578000+00:00          293
#> 5 2020-01-07T10:59:32.617000+00:00          292
#> 6 2020-01-07T17:49:45.382000+00:00          292
#>                                                                        source_url
#> 1 https://publicaccess.leeds.gov.uk/online-applications/search.do?action=advanced
#> 2 https://publicaccess.leeds.gov.uk/online-applications/search.do?action=advanced
#> 3 https://planning.wakefield.gov.uk/online-applications/search.do?action=advanced
#> 4 https://planning.wakefield.gov.uk/online-applications/search.do?action=advanced
#> 5 https://publicaccess.leeds.gov.uk/online-applications/search.do?action=advanced
#> 6 https://publicaccess.leeds.gov.uk/online-applications/search.do?action=advanced
#>   authority_name                                                         link
#> 1          Leeds      https://www.planit.org.uk/planapplic/Leeds/19/07662/FU/
#> 2          Leeds     https://www.planit.org.uk/planapplic/Leeds/19/07837/CLP/
#> 3      Wakefield https://www.planit.org.uk/planapplic/Wakefield/19/02825/FUL/
#> 4      Wakefield https://www.planit.org.uk/planapplic/Wakefield/19/02827/FUL/
#> 5          Leeds      https://www.planit.org.uk/planapplic/Leeds/19/07688/RM/
#> 6          Leeds      https://www.planit.org.uk/planapplic/Leeds/19/07584/FU/
#>   postcode                                                  address      lat
#> 1 LS25 7DT                  199A Valley Ridge Kippax Leeds LS25 7DT 53.77577
#> 2 LS25 2NX                   9 Saxton Court Garforth Leeds LS25 2NX 53.79595
#> 3 WF10 5LD      74 Lumley Street Castleford West Yorkshire WF10 5LD 53.72102
#> 4 WF10 1EZ Bradley Avenue (Former Maestro Club) Castleford WF10 1EZ 53.72659
#> 5     <NA>          Land To South Of Selby Road Garforth Leeds LS25 53.78500
#> 6 LS25 1EN                 36 Lowther Grove Garforth Leeds LS25 1EN 53.78889
#>         lng start_date          uid       altid
#> 1 -1.380506 2019-12-30  19/07662/FU        <NA>
#> 2 -1.380163 2019-12-20 19/07837/CLP        <NA>
#> 3 -1.368323 2019-12-18 19/02825/FUL PP-08143834
#> 4 -1.357085 2019-12-17 19/02827/FUL        <NA>
#> 5 -1.398203 2019-12-13  19/07688/RM        <NA>
#> 6 -1.389283 2019-12-12  19/07584/FU        <NA>
get_planit_data(bbox, end_date = "2008-01-01") # historic data
#> Getting data from https://www.planit.org.uk/api/applics/geojson?limit=6&bbox=-1.4%2C53.7%2C-1.3%2C53.8&end_date=2008-01-01&start_date=2000-02-01&pg_sz=6
#> Simple feature collection with 6 features and 15 fields
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: -1.388588 ymin: 53.71833 xmax: -1.360772 ymax: 53.79289
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +datum=WGS84 +no_defs
#> # A tibble: 6 x 16
#>   doc_type name  url   description when_updated        authority_id source_url
#>   <chr>    <chr> <chr> <chr>       <dttm>                     <int> <chr>     
#> 1 PlanApp… Leed… http… Change of … 2017-07-22 10:42:30          292 https://p…
#> 2 PlanApp… Wake… http… Extension … 2019-08-29 15:45:35          293 https://p…
#> 3 PlanApp… Wake… http… Extension … 2019-08-29 15:45:35          293 https://p…
#> 4 PlanApp… Leed… http… Retrospect… 2017-07-22 05:41:58          292 https://p…
#> 5 PlanApp… Leed… http… Two storey… 2017-07-20 23:53:30          292 https://p…
#> 6 PlanApp… Wake… http… Detached d… 2019-08-29 15:45:35          293 https://p…
#> # … with 9 more variables: authority_name <chr>, link <chr>, postcode <chr>,
#> #   address <chr>, lat <dbl>, lng <dbl>, start_date <date>, uid <chr>,
#> #   geometry <POINT [°]>
get_planit_data(bbox, pcode = "LS2 9JT") # data from specific postcode
#> Getting data from https://www.planit.org.uk/api/applics/geojson?limit=6&bbox=-1.4%2C53.7%2C-1.3%2C53.8&end_date=2020-01-08&start_date=2000-02-01&pg_sz=6&pcode=LS2%209JT
#> Simple feature collection with 6 features and 16 fields
#> geometry type:  POINT
#> dimension:      XY
#> bbox:           xmin: -1.55333 ymin: 53.80796 xmax: -1.55333 ymax: 53.80796
#> epsg (SRID):    4326
#> proj4string:    +proj=longlat +datum=WGS84 +no_defs
#> # A tibble: 6 x 17
#>   doc_type name  distance url   description when_updated        authority_id
#>   <chr>    <chr>    <dbl> <chr> <chr>       <dttm>                     <int>
#> 1 PlanApp… Leed…        0 http… Removal of… 2019-07-23 09:45:04          292
#> 2 PlanApp… Leed…        0 http… Two new of… 2019-02-10 20:52:08          292
#> 3 PlanApp… Leed…        0 http… Consent, a… 2018-12-23 15:58:03          292
#> 4 PlanApp… Leed…        0 http… Refurbishm… 2018-09-19 05:39:38          292
#> 5 PlanApp… Leed…        0 http… Refurbishm… 2018-06-04 03:34:51          292
#> 6 PlanApp… Leed…        0 http… Listed Bui… 2018-05-05 18:39:50          292
#> # … with 10 more variables: source_url <chr>, authority_name <chr>, link <chr>,
#> #   postcode <chr>, address <chr>, lat <dbl>, lng <dbl>, start_date <date>,
#> #   uid <chr>, geometry <POINT [°]>
res = get_planit_data(bbox, limit = 20, krad = 9) # return geographic (`sf`) object
#> Getting data from https://www.planit.org.uk/api/applics/geojson?limit=20&bbox=-1.4%2C53.7%2C-1.3%2C53.8&end_date=2020-01-08&start_date=2000-02-01&pg_sz=20&krad=9
mapview::mapview(res)

Created on 2020-01-08 by the reprex package (v0.3.0)

Robinlovelace commented 4 years ago

Heads-up @mem48 this may also be of use/interest for your work. Thoughts? Please give it a spin, e.g. to see if there are any developments planned out in Huddersfield.