Learn R Programming

qlcVisualize (version 0.4)

window: Producing windows of class "owin"

Description

These functions are deprecated: use weightedMap instead.

Different ways to easily produce windows of class "owin" from the package "spatstat" are presented here. These are used by voronoi.

Usage

hullToOwin(points, shift, alpha)
mapsToOwin(country, database = "world")
gadmToOwin(country, sub = NULL, level = 0)

Value

All functions return an object of class owin from the package spatstat.

Arguments

points

Set of points that need a window around them. Two column matrix.

shift

The amount of space around the outer points at determining the window.

alpha

Parameter for the 'curviness': lower values show more detail. Passed internally to ahull.

country

Name of the country to obtain borders and turn them into an owin object needed for the function voronoi. For mapsToOwin check map how to specify the names. For gadmToOwin, check https://gadm.org.

database

Database as used by map.

sub, level

Names for Subdivisions of countries as available in the GADM database

Author

Michael Cysouw <cysouw@mac.com>

Details

For hullToOwin, the function ahull is used to make a hull around the points. This is then converted to an "owin" window.

The functions mapsToOwin and GadmToWin use external topogaphic boundaries to produce windows.

Examples

Run this code
if (FALSE) {
# Boundary of the German state "Hessen"
# This will need to access the online GADM database
# and might take some time
boundary <- gadmToOwin("DEU", "Hessen", 1)

# A window does not have to be continuous
random <- mapsToOwin(c("Germany", "Greece"))
plot(random, main = NULL)

# hull around some points
# note influence of alpha and shift
data(hessen)

hull <- hullToOwin(hessen$villages, shift = 0.2, alpha = 1)
plot(hull)
points(hessen$villages)

hull <- hullToOwin(hessen$villages, shift = 0.1, alpha = 0.2)
plot(hull)
points(hessen$villages)
}

Run the code above in your browser using DataLab