[R] rnrfa package problems

Ivan Krylov kry|ov@r00t @end|ng |rom gm@||@com
Fri Oct 13 11:02:58 CEST 2023


On Fri, 13 Oct 2023 09:11:25 +0100
Nick Wray <nickmwray using gmail.com> wrote:

> But when I try to run the example codes there are various problems
> 
> The code is lifted directly from the document btw it’s not mine
> 
> This bit to convert gives an error message:
> 
> # Option a: from OS grid reference to WGS84 >
> 
> osg_parse(gridRef = "NC581062", CoordSystem = "WGS84")

When reporting problems, it's best to list (1) your actions, (2) their
expected result and (3) their actual result:
https://www.chiark.greenend.org.uk/~sgtatham/bugs.html

In particular, it's best to report error messages together with the
code that causes them. This is what I get:

osg_parse(gridRef = "NC581062", CoordSystem = "WGS84")
# Ошибка в osg_parse(gridRef = "NC581062", CoordSystem = "WGS84") :
#   неиспользованные аргументы (gridRef = "NC581062", CoordSystem =
#   "WGS84")

Presumably, your error message looks a bit differently, but the
underlying cause is the same: the package has evolved since the R
Journal article has been published. In particular, the argument names
have been changed in 2018 with a giant commit commented "lint free":
https://github.com/ilapros/rnrfa/commit/258f11d89726c1031cb5bfa73e2f819d984914f3#diff-acbd0646da1333775e213e83567eaf53cb9e791ff7ba1200d462005e65fd7694L24-R30

I think you can use the argument name grid_refs instead of gridRef
and coord_system instead of CoordSystem:

osg_parse(grid = "NC581062", coo = "WGS84")
# $lon
# [1] -4.404049
# 
# $lat
# [1] 58.02222

Same goes for your catalogue() problems, which can be easily resolved
by calling help() on the respective functions to look up their new
argument names.

> The ggmap code following gives an error – this may be because the bbox
> data is empty but I’m not sure  The needed packages are loaded:

> m <- get_map(location = as.numeric(bbox), maptype = 'terrain')

Is this the error you get?

>> Error in `get_googlemap()`:
>> ! Google now requires an API key; see `ggmap::register_google()`.

Does it help to follow the instructions in help(register_google,
package = ggmap)? Google inflected this change on the world in 2018,
approximately 1.5 years after the article had been published.

OpenStreetMap support is broken in ggmap
<https://github.com/dkahle/ggmap/issues/117>, but passing the source =
'stamen' argument to ggmap::get_map seems to work. Well, partially. I
also get half an error message rendered right into the map telling me
something about "these basemap[s]... no longer... as of October..." and
asking me to upgrade by visiting stamen.com.

This is more or less inevitable when a package depends on an external
service to keep providing map data (you can't bundle the whole map of
the world into a CRAN package, after all), so unless someone steps up
and implements OpenStreetMap's stable API support in ggmap, your best
bet is to ask Google for an API key and pray they won't alter the deal
any further.

-- 
Best regards,
Ivan



More information about the R-help mailing list