Skip to contents

g_swap_xy() swaps x and y coordinates of the input geometry. Wrapper of OGR_G_SwapXY() in the GDAL API.

Usage

g_swap_xy(
  geom,
  as_wkb = TRUE,
  as_iso = FALSE,
  byte_order = "LSB",
  quiet = FALSE
)

Arguments

geom

Either a raw vector of WKB or list of raw vectors, or a character vector containing one or more WKT strings.

as_wkb

Logical value, TRUE to return the output geometry in WKB format (the default), or FALSE to return as WKT.

as_iso

Logical value, TRUE to export as ISO WKB/WKT (ISO 13249 SQL/MM Part 3), or FALSE (the default) to export as "Extended WKB/WKT".

byte_order

Character string specifying the byte order when output is WKB. One of "LSB" (the default) or "MSB" (uncommon).

quiet

Logical value, TRUE to suppress warnings. Defaults to FALSE.

Value

A geometry as WKB raw vector or WKT string, or a list/character vector of geometries as WKB/WKT with length equal to length(geom). NA is returned with a warning if WKB input cannot be converted into an OGR geometry object.

Examples

g <- "GEOMETRYCOLLECTION(POINT(1 2),
                         LINESTRING(1 2,2 3),
                         POLYGON((0 0,0 1,1 1,0 0)))"

g_swap_xy(g, as_wkb = FALSE)
#> [1] "GEOMETRYCOLLECTION (POINT (2 1),LINESTRING (2 1,3 2),POLYGON ((0 0,1 0,1 1,0 0)))"