Issue #5 resolved

Generalization of the create_new_data function

Paul Hiemstra
repo owner created an issue

Submitted by Pierre Roudier via mail:

Dear Paul,

I'm a long-time fan of your automap package, and I'm happy I can come up with a very simple proposition that would make the use of your package easier: I'm developing a package that extends sp classes [0], and I'm happy to use S4 power to apply directly S4 functions on my objects (that, in a nutshell, inherits from SpatialPointsDataFrame).

However, I found a point in your code that could be generalised to any class that extends SpatialPoints:

in automap:::create_new_data:

{{{

!R

create_new_data <- function (obj) { convex_hull = chull(coordinates(obj)[, 1], coordinates(obj)[, 2]) convex_hull = c(convex_hull, convex_hull[1])

## Here is my one-line proposition! ##

## # d = Polygon(obj[convex_hull, ]) # old version d = Polygon(coordinates(ob)j[convex_hull, ]) # proposed version ## ## ==========================##

new_data = spsample(d, 5000, type = "regular")
gridded(new_data) = TRUE
return(new_data)

}

}}} Using explicitly coordinates would allow classes extending SPDF to make use of your package directly, without the need to coerce using as(foo, "SpatialPointsDataFrame").

Just my two cents on this,

Pierre

Comments (1)

  1. Log in to comment