Package 'geoarrow'

Title: Extension Types for Spatial Data for Use with 'Arrow'
Description: Provides extension types and conversions to between R-native object types and 'Arrow' columnar types. This includes integration among the 'arrow', 'nanoarrow', 'sf', and 'wk' packages such that spatial metadata is preserved wherever possible. Extension type implementations ensure first-class geometry data type support in the 'arrow' and 'nanoarrow' packages.
Authors: Dewey Dunnington [aut, cre] , Anthony North [ctb], Apache Software Foundation [cph], Ulf Adams [cph], Daniel Lemire [cph], Joao Paulo Magalhaes [cph]
Maintainer: Dewey Dunnington <[email protected]>
License: Apache License (>= 2)
Version: 0.2.1.9000
Built: 2024-11-12 03:10:14 UTC
Source: https://github.com/geoarrow/geoarrow-r

Help Index


Convert an object to a GeoArrow array

Description

Convert an object to a GeoArrow array

Usage

as_geoarrow_array(x, ..., schema = NULL)

as_geoarrow_array_stream(x, ..., schema = NULL)

Arguments

x

An object

...

Passed to S3 methods

schema

A geoarrow extension schema to use as the target type

Value

A nanoarrow_array.

Examples

as_geoarrow_array(wk::wkt("POINT (0 1)"))

GeoArrow encoded arrays as R vectors

Description

GeoArrow encoded arrays as R vectors

Usage

as_geoarrow_vctr(x, ..., schema = NULL)

Arguments

x

An object that works with as_geoarrow_array_stream(). Most spatial objects in R already work with this method.

...

Passed to as_geoarrow_array_stream()

schema

An optional schema (e.g., na_extension_geoarrow()).

Value

A vctr of class 'geoarrow_vctr'

Examples

as_geoarrow_vctr("POINT (0 1)")

Handler/writer interface for GeoArrow arrays

Description

Handler/writer interface for GeoArrow arrays

Usage

geoarrow_handle(x, handler, size = NA_integer_)

geoarrow_writer(schema)

Arguments

x

An object implementing as_geoarrow_array_stream()

handler

A wk handler

size

The number of elements in the stream or NA if unknown

schema

A nanoarrow_schema

Value

  • geoarrow_handle(): Returns the result of handler

  • geoarrow_writer(): Returns a nanoarrow array

Examples

geoarrow_handle(wk::xy(1:3, 2:4), wk::wk_debug_filter())
wk::wk_handle(wk::xy(1:3, 2:4), geoarrow_writer(na_extension_wkt()))

Inspect a GeoArrow schema

Description

Inspect a GeoArrow schema

Usage

geoarrow_schema_parse(
  schema,
  extension_name = NULL,
  infer_from_storage = FALSE
)

is_geoarrow_schema(schema)

as_geoarrow_schema(schema)

Arguments

schema

A nanoarrow_schema

extension_name

An extension name to use if schema is a storage type.

infer_from_storage

Attempt to guess an extension name if schema is not a geoarrow extension type.

Value

A list of parsed properties

Examples

geoarrow_schema_parse(na_extension_geoarrow("POINT"))

GeoArrow Types

Description

These functions provide GeoArrow type definitions as zero-length vectors.

Usage

geoarrow_wkb(crs = NULL, edges = "PLANAR")

geoarrow_wkt(crs = NULL, edges = "PLANAR")

geoarrow_large_wkb(crs = NULL, edges = "PLANAR")

geoarrow_large_wkt(crs = NULL, edges = "PLANAR")

geoarrow_native(
  geometry_type,
  dimensions = "XY",
  coord_type = "SEPARATE",
  crs = NULL,
  edges = "PLANAR"
)

geoarrow_point(
  dimensions = "XY",
  coord_type = "SEPARATE",
  crs = NULL,
  edges = "PLANAR"
)

geoarrow_linestring(
  dimensions = "XY",
  coord_type = "SEPARATE",
  crs = NULL,
  edges = "PLANAR"
)

geoarrow_polygon(
  dimensions = "XY",
  coord_type = "SEPARATE",
  crs = NULL,
  edges = "PLANAR"
)

geoarrow_multipoint(
  dimensions = "XY",
  coord_type = "SEPARATE",
  crs = NULL,
  edges = "PLANAR"
)

geoarrow_multilinestring(
  dimensions = "XY",
  coord_type = "SEPARATE",
  crs = NULL,
  edges = "PLANAR"
)

geoarrow_multipolygon(
  dimensions = "XY",
  coord_type = "SEPARATE",
  crs = NULL,
  edges = "PLANAR"
)

Arguments

crs

An object representing a CRS. For maximum portability, it should implement wk::wk_crs_projjson().

edges

One of "PLANAR" or "SPHERICAL".

geometry_type

One of "POINT", "LINESTRING", "POLYGON", "MULTIPOINT", "MULTILINESTRING", "MULTIPOLYGON".

dimensions

One of "XY", "XYZ", "XYM", or "XYZM"

coord_type

One of "SEPARATE" or "INTERLEAVED"

Value

A geoarrow_vctr

Examples

geoarrow_wkb()
geoarrow_wkt()
geoarrow_point()

Infer a GeoArrow-native type from a vector

Description

Infer a GeoArrow-native type from a vector

Usage

infer_geoarrow_schema(x, ..., promote_multi = TRUE, coord_type = NULL)

Arguments

x

An object from which to infer a schema.

...

Passed to S3 methods.

promote_multi

Use TRUE to return a MULTI type when both normal and MULTI elements are in the same array.

coord_type

Specify the coordinate type to use if returning

Value

A nanoarrow_schema

Examples

infer_geoarrow_schema(wk::wkt("POINT (0 1)"))

Extension type definitions for GeoArrow extension types

Description

Extension type definitions for GeoArrow extension types

Usage

na_extension_wkb(crs = NULL, edges = "PLANAR")

na_extension_wkt(crs = NULL, edges = "PLANAR")

na_extension_large_wkb(crs = NULL, edges = "PLANAR")

na_extension_large_wkt(crs = NULL, edges = "PLANAR")

na_extension_geoarrow(
  geometry_type,
  dimensions = "XY",
  coord_type = "SEPARATE",
  crs = NULL,
  edges = "PLANAR"
)

Arguments

crs

An object representing a CRS. For maximum portability, it should implement wk::wk_crs_projjson().

edges

One of "PLANAR" or "SPHERICAL".

geometry_type

One of "POINT", "LINESTRING", "POLYGON", "MULTIPOINT", "MULTILINESTRING", "MULTIPOLYGON".

dimensions

One of "XY", "XYZ", "XYM", or "XYZM"

coord_type

One of "SEPARATE" or "INTERLEAVED"

Value

A nanoarrow_schema.

Examples

na_extension_wkb(crs = "OGC:CRS84")
na_extension_geoarrow("POINT")