gis_tools.Rd
These functions smooth the gateway between working with geohashes and geospatial information built for the major geospatial packages in R, sp
and sf
.
gh_to_sp(geohashes) gh_to_spdf(...) gh_to_sf(...) gh_covering(SP, precision = 6L, minimal = FALSE) # S3 method for default gh_to_spdf(geohashes, ...) # S3 method for data.frame gh_to_spdf(gh_df, gh_col = 'gh', ...)
geohashes |
|
---|---|
... | Arguments for subsequent methods. |
SP | A |
precision |
|
minimal |
|
gh_df |
|
gh_col |
|
gh_to_sp
relies on the gh_decode
function. Note in particular that this function accepts any length of geohash (geohash-6, geohash-4, etc.) and is agnostic to potential overlap, though duplicates will be caught and excluded.
gh_to_spdf.data.frame
will use match.ID = FALSE
in the call to SpatialPolygonsDataFrame
. Please file an issue if you'd like this to be more flexible.
gh_to_sf
is just a wrapper of st_as_sf
around gh_to_spdf
; as such it requires both sp
and sf
packages to work.
For gh_to_sp
, a SpatialPolygons
object.
For gh_to_spdf
, a SpatialPolygonsDataFrame
object.
For gh_to_sf
, a sf
object.
# get the neighborhood of this geohash in downtown Apia as an sp object downtown = '2jtc5x' apia_nbhd = unlist(gh_neighbors(downtown)) apia_sp = gh_to_sp(apia_nbhd) # all geohashes covering a random sampling within Apia: apia_covering = gh_covering(smp <- sp::spsample(apia_sp, 10L, 'random')) apia_sf = gh_to_sf(apia_nbhd)