Package 'rgeopat2'

Title: Additional Functions for 'GeoPAT' 2
Description: Supports analysis of spatial data processed with the 'GeoPAT' 2 software <https://github.com/Nowosad/geopat2>. Available features include creation of a grid based on the 'GeoPAT' 2 grid header file and reading a 'GeoPAT' 2 text outputs.
Authors: Jakub Nowosad [aut, cre] , Space Informatics Lab [cph]
Maintainer: Jakub Nowosad <[email protected]>
License: MIT + file LICENSE
Version: 0.4.0
Built: 2025-02-09 02:59:29 UTC
Source: https://github.com/nowosad/rgeopat2

Help Index


British Isles

Description

A dataset containing the British Isles outline map

Usage

british_isles

Format

An object of class sf (inherits from data.frame) with 1 rows and 1 columns.

Source

The rnaturalearth package


Grid polygon creator

Description

Creates a polygon of a GeoPAT 2 grid based on the grid header

Usage

gpat_create_grid(x, brick = FALSE)

Arguments

x

A filepath to the GeoPAT 2 grid header file

brick

TRUE/FALSE; should a new grid polygon have a brick topology

Value

sf

Examples

header_filepath = system.file("rawdata/Augusta2011_grid100.hdr", package="rgeopat2")
my_grid = gpat_create_grid(header_filepath)
my_grid_brick = gpat_create_grid(header_filepath, brick = TRUE)

plot(my_grid)
plot(my_grid_brick, add = TRUE, border = "red", lwd = 3)

Parse a header of a GeoPAT 2 grid file

Description

Extracts basic information from a geoPAT 2 grid header file

Usage

gpat_header_parser(x)

Arguments

x

A filepath to the GeoPAT 2 grid header file

Value

data_frame


Read a GeoPAT distance matrix

Description

Read a GeoPAT distance matrix into R

Usage

gpat_read_distmtx(x)

Arguments

x

A filepath to the geoPAT 2 distance matrix file

Value

dist

Examples

distmtx_filepath = system.file("rawdata/Augusta2011_matrix_grid.csv", package="rgeopat2")
my_distmtx = gpat_read_distmtx(distmtx_filepath)

Read a GeoPAT 2 text output

Description

Read a text output of the GeoPAT 2 functions into R

Usage

gpat_read_txt(x, signature = NULL)

Arguments

x

A filepath to the GeoPAT 2 text file

signature

A signature used to create the GeoPAT 2 text output (supported signatures: "lind", "linds", "ent", and "ts")

Value

data.frame

Examples

polygon_filepath = system.file("rawdata/Augusta2011_polygon.txt", package = "rgeopat2")
my_polygon = gpat_read_txt(polygon_filepath)

# points_filepath = system.file("rawdata/Augusta2011_points.txt", package = "rgeopat2")
# my_points = gpat_read_txt(points_filepath)

# lind_filepath = system.file("rawdata/Augusta2011_lind.txt", package = "rgeopat2")
# my_lind = gpat_read_txt(lind_filepath, signature = "lind")

# linds_filepath = system.file("rawdata/Augusta2011_linds.txt", package = "rgeopat2")
# my_linds = gpat_read_txt(linds_filepath, signature = "linds")

# grid_filepath = system.file("rawdata/Augusta2011_grid100.txt", package = "rgeopat2")
# my_grid = gpat_read_txt(grid_filepath)

# gridlinds_filepath = system.file("rawdata/Augusta2011_grid_linds.txt", package = "rgeopat2")
# my_grid = gpat_read_txt(gridlinds_filepath, signature = "linds")

# gridts_filepath = system.file("rawdata/barent_ts_grd.txt", package = "rgeopat2")
# my_gridts = gpat_read_txt(gridts_filepath, signature = "ts")

Grid polygon creator (without a header)

Description

Creates a polygon of a GeoPAT grid based on a given parameters

Usage

gpat_st_make_grid(x, n = c(10, 10), brick = FALSE)

Arguments

x

An object of class sf or sfc

n

An integer of length 1 or 2, number of grid cells in x and y direction (columns, rows)

brick

TRUE/FALSE; should a new grid polygon have a brick topology

Value

sf

References

Based on the st_make_grid function from the sf package

Examples

## Not run: 
library(sf)
nc = st_read(system.file("shape/nc.shp", package="sf"))

my_grid = gpat_st_make_grid(nc)
my_grid$id = 1:100

grid_centroids = st_centroid(my_grid) %>%
  st_coordinates(grid_centroids) %>%
  as_data_frame() %>%
  mutate(id = 1:100)

ggplot() +
  geom_sf(data = my_grid) +
  geom_text(data = grid_centroids, aes(x = X, y = Y, label = id)) +
  theme_void()

## End(Not run)