Skip to content

st_as_sf fails when the api returns a list #5

@steffengreup

Description

@steffengreup

On some occasions, the API returns a list instead of a data.frame. This seems to happen when no match is found.

For example:

pdok_res <- nlgeocoder::nl_free("1013AB", rows = 1)

str(pdok_res)
#> List of 1
#>  $ response:List of 4
#>   ..$ numFound: int 0
#>   ..$ start   : int 0
#>   ..$ maxScore: num 0
#>   ..$ docs    : list()

This causes sf to throw an error when using the nl_geocode function with both the (default) output format wsg84 and output format rd:

nlgeocoder::nl_geocode("1013AB")
#> Error in UseMethod("st_as_sf"): no applicable method for 'st_as_sf' applied to an object of class "list"

Created on 2020-10-28 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions