19
JSS Journal of Statistical Software April 2018, Volume 84, Code Snippet 1. doi: 10.18637/jss.v084.c01 stampr: Spatial-Temporal Analysis of Moving Polygons in R Jed Long University of St. Andrews Colin Robertson Wilfrid Laurier University Trisalyn Nelson Arizona State University Abstract The R package stampr implements functions for analyzing movement in mapped poly- gon data. Methods described in this paper include deriving change events based on spatial relationships, plotting change events, summarizing measures of distance and direction of movement, characterizing changes in polygon shape changes, and characterizing sequences of polygons over time using graphs. Two examples are used to demonstrate the core func- tionality available in the stampr package. Keywords : spatial-temporal, GIS, polygons, R. 1. Introduction Spatial and spatial-temporal analytical methods in many fields have seen considerable devel- opment in recent years. However most methods capture only spatial correlation or covariance structures over polygonal lattice data, or spatial characteristics of point patterns. For polygon and line spatial data, there are fewer methods available for spatial-temporal analysis. In this paper we consider the analysis of spatial-temporal polygon data (termed moving polygons; see Robertson, Nelson, Boots, and Wulder 2007 for example). The analysis of moving polygons is widely applicable to the environmental sciences, for example in the spread of zoonotic in- fectious disease (Morris, Blackburn, Talibzade, Kracalik, Ismaylova, and Abdullahyev 2013), wildlife habitat analysis (Smulders, Nelson, Jelinski, Nielsen, Stenhouse, and Laberee 2012), and spatial changes in land use over time (Mizutani 2012). In geographic information sys- tems (GIS), natural phenomena tend to be geometrically represented as either vector points, lines, polygons (i.e., the object) model, or raster surfaces (i.e., the ´ field model). Yet many phenomena do not readily fall into these categories, such as wildfires, hurricanes, or ecological hotspots, all of which exhibit both object and field characteristics. Analytical methods for characterizing space-time change in such phenomena have been poorly developed in part due to these issues of spatial representation. For polygon-change analysis, methods and compu-

stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

JSS Journal of Statistical SoftwareApril 2018, Volume 84, Code Snippet 1. doi: 10.18637/jss.v084.c01

stampr: Spatial-Temporal Analysis of MovingPolygons in R

Jed LongUniversity of St. Andrews

Colin RobertsonWilfrid Laurier University

Trisalyn NelsonArizona State University

Abstract

The R package stampr implements functions for analyzing movement in mapped poly-gon data. Methods described in this paper include deriving change events based on spatialrelationships, plotting change events, summarizing measures of distance and direction ofmovement, characterizing changes in polygon shape changes, and characterizing sequencesof polygons over time using graphs. Two examples are used to demonstrate the core func-tionality available in the stampr package.

Keywords: spatial-temporal, GIS, polygons, R.

1. IntroductionSpatial and spatial-temporal analytical methods in many fields have seen considerable devel-opment in recent years. However most methods capture only spatial correlation or covariancestructures over polygonal lattice data, or spatial characteristics of point patterns. For polygonand line spatial data, there are fewer methods available for spatial-temporal analysis. In thispaper we consider the analysis of spatial-temporal polygon data (termed moving polygons; seeRobertson, Nelson, Boots, and Wulder 2007 for example). The analysis of moving polygonsis widely applicable to the environmental sciences, for example in the spread of zoonotic in-fectious disease (Morris, Blackburn, Talibzade, Kracalik, Ismaylova, and Abdullahyev 2013),wildlife habitat analysis (Smulders, Nelson, Jelinski, Nielsen, Stenhouse, and Laberee 2012),and spatial changes in land use over time (Mizutani 2012). In geographic information sys-tems (GIS), natural phenomena tend to be geometrically represented as either vector points,lines, polygons (i.e., the object) model, or raster surfaces (i.e., the f́ield model). Yet manyphenomena do not readily fall into these categories, such as wildfires, hurricanes, or ecologicalhotspots, all of which exhibit both object and field characteristics. Analytical methods forcharacterizing space-time change in such phenomena have been poorly developed in part dueto these issues of spatial representation. For polygon-change analysis, methods and compu-

Page 2: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

2 stampr: Spatial-Temporal Analysis of Moving Polygons in R

tational tools for examining changes in spatial polygons through time remain limited, mostnotably in their accessibility to researchers through software tools.With the growing availability of multi-temporal spatial polygon data, there is a clear needfor tools and techniques for space-time analysis of polygons. As such, we developed a newpackage in the statistical computing environment R (R Core Team 2017), the stampr package(Long and Robertson 2018). Package stampr is available from the Comprehensive R ArchiveNetwork (CRAN) at https://CRAN.R-project.org/package=stampr and provides a unifiedimplementation of old and new approaches to spatial-temporal analysis of moving polygons.The stampr package extends the core STAMP methodology presented by Robertson et al.(2007, hereafter referred to as RNBW) for categorizing space-time change in moving polygons.Within the stampr package, we also include a suite of methods for assessing distance anddirectional relationships between moving polygons. We extend the STAMP methodologyto include polygon shape metrics in order to facilitate more in-depth analysis of polygonmovement and change, and introduce a graph representation of space-time change trajectoriesfor examining temporal patterns of spatial change. In all the work here, we consider discretetemporal changes only and leave interpolation of continuous change to future research.The availability of R-based spatial classes and analysis methods has increased substantially inrecent years, owing heavily to the developments of a relatively small number of contributorsworking on spatial packages in R. For more details on R packages available for handlinganalyzing spatio-temporal data see the corresponding CRAN Task View (Pebesma 2017).The foundational spatial classes in R are from the sp package (Pebesma and Bivand 2005)for vector data and the raster package (Hijmans 2017) for raster data. The development ofthe rgeos package (Bivand and Rundel 2017), which implements spatial-overlay operationsin R, has been integral to the development of the functionality presented here. For manyusers who previously relied on proprietary software, the R statistical computing environmenthas become the preferential free and open-source option as it now possesses functionality,historically available only in commercial GIS packages. R is advantageous for many reasons,but notably due to its wide-reaching user-base and the ability to perform statistical analysiswith spatial data through their use of the ‘data.frame’ class. With this in mind, the Rsoftware environment represents an ideal computing environment for reaching potential usersof STAMP in both the natural and social sciences.

2. STAMP framework for space-time analysis of polygonsMetric spatial relationships are not well defined between multiple polygons (Liu and Deng2002). As such, polygon spatial relations and resultant spatial analyses are typically confinedto topological relationships defined by point-set topology (boundary and interior areas ofintersection and non-intersection; see Egenhofer and Franzosa 1991). The complexity ofpolygon features makes characterizing the spatial relationships between polygons a challenginganalytical task. Furthermore, the lack of a more sophisticated framework for the spatialanalyses of polygonal data and the paucity of analytical tools in both commercial and opensource GIS software limits the full exploitation of the geometric properties of the data. Inthe context of moving polygons, metric relations (e.g., Hausdorff distance), are useful todescribe changes in edges or polygon centroids. When aggregated over multiple time periods,changes in distance and direction of movement are descriptive of the change over time in theunderlying spatial process.

Page 3: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 3

The two basic metric spatial relations between moving polygons are the distance (relatedto velocity) and direction of movement. Distance and direction may be computed betweenpolygon centroids or edges. A confounding issue in quantifying distance and directional rela-tionships in moving polygons is that changes to polygon shape and size occur simultaneouslywith movement (e.g., a wildfire or hurricane). Interestingly, the application domains whereanalysis of moving polygons is typically required often lie at the interface of discrete objectsand continuous fields, described as field-objects (Cova and Goodchild 2002). Field-objectscan be dynamic in location, shape, orientation, internal homogeneity, and size, making evalu-ation of metric relations between them cumbersome due to interacting simultaneous changesin these properties.

2.1. Spatial-temporal analysis of moving polygons (STAMP)Building upon the original works of Sadahiro and Umemura (2001), RNBW laid the ground-work for a more quantitative approach to analyzing space-time change in moving polygons.RNBW implemented an event-based framework for categorizing polygon movement eventsbased on the intersection of t1 and t2 polygons, and a distance threshold (dc) used to definewhether two (or more) polygons are related (termed groups) between t1 and t2. Groupedpolygons are then evaluated within a hierarchical system used to delineate various polygonmovement events in order to semantically describe polygon movements. At the broadesthierarchical level (level 1) STAMP categorizes three event types, stable (areas that exist inboth times), generation (areas in t2 only), and disappearance (areas in t1 only). At level 2,categories include stable (as before), expansion (generation events adjacent to stable events),contraction (disappearance events adjacent to stable events), and displaced disappearanceand displaced generation events. At level 3, the distance threshold is used to further refinethe STAMP displacement designations. Stable, contraction, and expansion events remainunchanged, but disjointed disappearance and generation events are further classified intosub-events based on their proximity and relationship to the other polygon event types (seeTable 2 in RNBW for a more detailed description). Finally, level 4 of the framework describesmulti-polygon events which include union of two or more polygons into one (i.e., merging),division of one polygon into two or more (i.e., splitting), or both occurring simultaneously.Using a simple two-time period synthetic dataset available in the stampr package, we willdemonstrate the variety of scenarios that can be studied under the STAMP event frameworkin the stampr package.We begin by running the stamp function in order to generate a change object of class‘SpatialPolygonsDataFrame’ that describes change according to the STAMP event frame-work. These data represent simulated fire perimeter polygons from two time periods.

R> library("stampr")R> data("fire1", package = "stampr")R> data("fire2", package = "stampr")

The function requires temporally unique identifiers to be stored in a column called ID inthe ‘SpatialPolygonsDataFrame’ object passed to the function. We will create this prior torunning the stamp function

R> fire1$ID <- 1:nrow(fire1)R> fire2$ID <- (max(fire1$ID) + 1):(max(fire1$ID) + nrow(fire2))

Page 4: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

4 stampr: Spatial-Temporal Analysis of Moving Polygons in R

a) Level 1

DISASTBLGENR

b) Level 2

DISACONTSTBLEXPNGENR

c) Level 3

DISADISP1CONVCONCCONTSTBLEXPNFRAGDIVRDISP2GENR

d) Level 4

N/AUNIONDIVISIONBOTH

Figure 1: Example of STAMP framework hierarchy of events, a) Level 1, b) Level 2, c) Level3 and d) Level 4.

R> ch <- stamp(fire1, fire2, dc = 1, direction = FALSE, distance = FALSE,+ shape = FALSE)

The order of arguments in the stamp function is important; it must be an object of class‘SpatialPolygonsDataFrame’ from t1, followed by t2. The returned object ch has class‘SpatialPolygonsDataFrame’ with specific fields describing the events and changes betweenthe two time periods.

R> head(ch@data)

ID1 ID2 LEV1 LEV2 LEV3 LEV4 GROUP AREA0 1 NA DISA CONT CONT N/A 1 0.0629909431 2 NA DISA DISA CONC N/A 1 0.0047333822 1 16 STBL STBL STBL N/A 1 0.0799199393 NA 16 GENR EXPN EXPN N/A 1 0.1302188474 NA 17 GENR GENR FRAG N/A 1 0.0144485035 3 NA DISA CONT CONT N/A 2 0.176832399

Figure 1 presents the mapping of several different event classes using the stamp.map function.These event classes form the basis for all additional analyses of space-time change.We can then explore local changes through event summaries

R> chSum <- stamp.group.summary(ch)R> chSum <- chSum[chSum$nEVENTS > 1, ]

Page 5: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 5

●●●

0 20 40 60 80 100

020

4060

8010

0

% Expansion

% C

ontr

actio

n

Figure 2: Plotting proportional change in expansion and contraction events

R> plot((chSum$aEXPN / chSum$AREA) * 100, (chSum$aCONT / chSum$AREA) * 100,+ xlab = "\% Expansion", ylab = "\% Contraction", pch = 20,+ ylim = c(0, 100), xlim = c(0, 100), cex = 2)

which in Figure 2 shows that one polygon group has higher proportional contraction, whilethree others have higher proportional expansion. A balance of expansion and contractionwould indicate movement across the landscape. We will now investigate further the spatialrelationships between polygons from neighboring time periods.

3. Metrics for quantifying space-time change

3.1. Number, area, and shape indices

RNBW first characterized changes between two polygons using global change indices whichcan be used to describe the changes in number and area of polygons contained in t1 and t2polygon groups (see Table 4 in RNBW). Further, we identify a set of shape indices, mostlyfrom the spatial ecology literature (McGarigal and Marks 1995), that are useful for measuringvarious properties of polygon shapes. Shape indices implemented include perimeter-arearatio, fractal dimension, shape index, and linearity index (information on how each index iscalculated can be found in the package documentation, or see McGarigal and Marks 1995).Each index can be used to evaluate shape-related change alongside the distance and directionalindices in order to better contextualize the changing dynamics of moving polygons.Inherent in these event-based change descriptors are more complex changes over time, forexample splitting and merging of polygons. Polygons that split or merge through time inducecomplexities into their distance and directional relationships due to changing the spatialcontext within which two (or more) polygons are compared. For example, Stell and Worboys(2011) provided recently the theoretical basis for computing relations for splitting and mergingpolygons using adjacency trees, with focus on the relationship between polygons (in the

Page 6: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

6 stampr: Spatial-Temporal Analysis of Moving Polygons in R

foreground) and a background region. We will extend the implementation to handle distanceand direction between level 4 events in future releases.

3.2. Spatial relationships of polygons: Distance and direction

Methods for quantifying distance relationships in polygon sets have developed largely fromknown analytical problems encountered in computational geometry (e.g., De Berg, Van Krev-eld, Overmars, and Schwarzkopf 2008) and other disciplines. In practice, the calculation ofdistance indices between polygons can be relatively straightforward, and is often simplifiedby decomposing a polygon (consisting of vertices and edges) into a point-set (i.e., just thevertices) in order to perform calculations. Even more simplistic methods represent the poly-gon as a single point (e.g., centroid) in order to calculate distances. This facilitates relativelystraightforward algebra for computing distance relationships. However, given the complexspatial shapes that can arise in polygon analysis, simple distance metrics can be confoundedby changes in polygon shape.Conversely, algorithms for performing polygon directional analysis need to take advantageof the specific properties associated with polygons and their directional relationships. Theformal properties of a directional relationship between two polygons in the plane are identifiedby Peuquet and Zhang (1987) as follows:

I. it is binary;

II. it is semantic inverse;

III. the area of acceptance of a specified direction increases with distance;

IV. the area of acceptance of a specified direction increases with the dimension in the facingdirection of the reference polygon in relation to the target polygon.

The first property states that a directional relationship can only involve two polygons, andthe second states that the reverse of a given relation is also true. For example, in Figure 3a,if polygon A is north of polygon B, then polygon B is south of polygon A. However, polygonswith complex shapes and directional relationships may challenge this convention. For examplein Figure 3b polygon A is both north and east of polygon B. The third and fourth propertiesrequire more careful consideration for implementation and interpretation.As stated previously in property 3 (distance property), the distance between two polygons im-pacts the interpretation of directional relationships between them. For example, in Figure 3b,polygon A is east of polygon B, but the entirety of polygon B is also south of polygon A.This situation is made more complex when different types of distances between two simplepolygons are considered.Polygon shape, size and orientation are additional spatial properties associated with polygonsshown to impact distance and directional relationships (Miller and Wentz 2003). These aresummarized in property 4 (shape property) which states that the directional relationship isimpacted by the ratio of the facing dimensions between the reference and target polygons(Figure 3c). When this ratio is high, the directional relationship is high, and when this ratiois low, the directional relationship is more ambiguous. This is illustrated in Figure 3c, wherethe directional relation of polygon A being north of polygon B is stronger than the relation ofpolygon C being south of polygon B. Figure 3c combines these properties of distance and shape

Page 7: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 7

Figure 3: Example diagrams for properties of directional relationships in polygons: a) seman-tic inverse, b) distance property, c) area of acceptance property.

Figure 4: Distance relationships between polygons: a) centroid distance, b) Hausdorff dis-tance.

to demonstrate their combined impact on directional relationships. In stampr we provide twopolygon distance methods that facilitate the calculation of distance measurements betweenmoving polygon objects.

Centroid distance

stamp.distance(ch, dir.mode = "Centroid")

The centroid distance is the simplest and most straightforward index for quantifying themovement distance of two polygons. Simply put, the centroid distance is the spatial distancebetween the centroid of two polygons (Figure 4a). The centroid distance can be evaluatedbetween the grouped t1 and t2 polygons, or across the individual STAMP events.

Hausdorff distance

stamp.distance(ch, dir.mode = "Hausdorff")

Page 8: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

8 stampr: Spatial-Temporal Analysis of Moving Polygons in R

The Hausdorff distance is a metric distance used in a variety of applications for comparing thedistance between two point-sets (Figure 4b). In application to measuring polygon distanceimplemented here, the Hausdorff distance measures the maximum distance between the corre-sponding edges of two polygons. The Hausdorff distance is more sensitive to changes in shapethan the centroid distance. Other applications have also adapted the Hausdorff distance as ametric with varied success, for example in evaluating the similarity of moving point objects(Zhang, Huang, and Tan 2006; Shao, Cai, and Gu 2010). The Hausdorff distance is definedas

H(P1, P2) = max[h(P1, P2), h(P1, P2)],

where

h(P1, P2) = maxj∈J [mini∈I [d(P1,i, P2,j)]]),

with i and j the indices along the boundaries of the two polygons P1 and P2 respectively,and d a distance operator (e.g., the Euclidean distance). The Hausdorff distance can beinterpreted as a measure of separation, the maximum distance separating the two polygons.The Hausdorff distance can be applied to the grouped t1 and t2 polygons, or to individualSTAMP events. Variations of the Hausdorff distance can also be used, for example the forwardmax-min distance from t1 to t2 polygons.We provide a suite of four methods for describing directional change with moving polygons.Some of these methods were compared over polygons in previous work (Robertson and Nelson2008).

Centroid angle

stamp.direction(ch, dir.mode = "CentroidAngle")

The simplest and most straightforward method for polygon directional analysis is the centroidangle method, which measures the angle between two polygon centroids (Figure 5a). In thecontext of STAMP, one can measure the distance between the t1 polygon centroid, and thecentroid of each stamp movement event to investigate the direction of each movement eventtype. Similarly, one can measure the distance between the centroid of grouped t1 and t2polygons to get a single index of direction for each polygon group.

Cone method

stamp.direction(ch, dir.mode = "ConeModel")

The cone method for directional analysis was proposed by Peuquet and Zhang (1987). Inthis approach, an inverted triangle originates from the centroid of the t1 polygon, typicallywith an interior angle of 90◦ for the ndir = 4 cardinal directions (Figure 5b) or 45◦ for thendir = 8 cardinal directions. The number of cones can be modified to any number, with theinterior angle then calculated appropriately. The area of the t2 polygon lying inside each ofthe cones is computed (and can be converted to percentages if desired). Often it is useful

Page 9: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 9

Figure 5: Directional relationships between moving polygons: a) centroid angle, b) conemethod, c) modified cone method, d) minimum bounding rectangle method. The methodsin b), c) and d) are considered area-based directional methods and compute the area of eachstamp event within each directional region.

to identify the cone with the maximum area to identify the main directional relation. Thecone method clearly satisfies the distance property (property III earlier), as distance fromthe reference polygon increases, the area of acceptance, or area associated with each possibledirection also increases due to the shape of the cone. The cone method is straightforward tocompute and interpret, and can be easily visualized. The cone method can be evaluated onthe t1 and t2 polygon groups, or on the individual STAMP event polygons.

Modified cone method

stamp.direction(ch, dir.mode = "ModConeModel")

The cone method was modified by RNBW to better accommodate irregularly shaped polygonsand scenarios where multiple polygons overlap. Like the cone method, the modified conemethod starts with the centroid of the t1 polygons (Figure 5c). The bounding box aroundthe union of the t1 and t2 polygons is then used as a reference for extending either ndir = 4 orndir = 8 uneven cones. If ndir = 4 cones are extended outward to the corners of the boundingbox. If ndir = 8 then cones are extended outward to the intersection points along the edgeof each side of the bounding box. Thus, while still incorporating the distance property, thisapproach also attempts to incorporate the shape property by adjusting the geometry of thecone based on the shapes and orientation of the reference and target polygons. RNBW made

Page 10: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

10 stampr: Spatial-Temporal Analysis of Moving Polygons in R

further modifications using generalized Voronoi diagrams for partitioning special cases, suchas when there are multiple stable events within a single STAMP group. The modified conemethod can be applied to t2 polygons as a group, or on the individual STAMP event polygons.

Minimum bounding rectangle method

stamp.direction(ch, dir.mode = "MBRModel")

The minimum bounding rectangle (MBR) method (Skiadopoulos, Giannoukos, Sarkas, Vas-siliadis, Sellis, and Koubarakis 2005) computes the area of movement in 9 quadrants based onthe geometry of the t1 polygon. The bounding box of the t1 polygon is used to delineate thecentral quadrant of an unevenly spaced 3×3 lattice (Figure 5d). Each border of the boundingbox is extended outward (ad infinitum) to delineate the 8 outer quadrants for each of the 8cardinal directions. The area of the t2 polygon in each of the 9 quadrants is calculated. TheMBR method can be evaluated on t2 polygons as a group, or on the individual STAMP eventpolygons.

3.3. Graph analysis of polygon sequences

Linking polygons from neighboring time periods through their spatial relationships affordsthe ability to create connected sequences of polygons that are part of a common change event(or set of events). In Sadahiro (2001), these sequences are termed spatio-temporal histories.Sadahiro (2001) also introduced the graph representation of these sequences through thedirected graph, where nodes represented polygons and edges a spatial relationship betweenpolygons at different time periods. The directed graph of polygon change events can be usedto summarize changes in size, distance, direction, or shape change over many time periods.As well, we have recently explored applying graph measures as new tools for characterizingdifferent polygon change processes, an approach discussed in Robertson (2016).

3.4. Data

Two datasets are included in the stampr package to facilitate testing and understanding ofthe methods. These are described below.

Hurricane Katrina

The Hurricane Katrina data were obtained from the NOAA H*Wind data product, whichprovides a gridded measurement of wind speed covering the hurricane region at 3 hour timesteps (Powell, Houston, Amat, and Morisseau-Leroy 1998, http://www.rms.com/models/hwind/legacy-archive). Hurricanes can be categorized using the Saffir-Simpson wind scale,which is based on wind speed. The Saffir-Simpson wind scale ranges from tropical storm(≥ 39 mph) to class 5 hurricane (≥ 157 mph). To delineate polygon boundaries of hurricaneKatrina, we identified the 39 mph isotach (line of equal wind speed) from the NOAA H*Winddata, which represents wind-speeds in a regular grid (raster) format. Data are available forevery three hours from 21:00 on Friday 2005-08-26 to 21:00 on Monday 2005-08-29. Forsimplicity, we included the eye of the hurricane as contained within the hurricane polygon,despite the fact that this area of the hurricane will typically have a much lower wind speed.

Page 11: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 11

●●●●●●●●●●●●●●●●●●●●●

●●●●●●

●●●

●●●

15

20

25

30

35

−90 −80

lon

lat

Figure 6: Hurricane Katrina moving polygon data (at selected time points) and trajectorydata showing the movement of hurricane Katrina between Friday 2005-08-26 and Monday2005-08-29.

Thus, the hurricane Katrina dataset represents the hurricane boundary polygon at each of 33time points covering this 3-day period, along with the trajectory of the eye of the hurricane(Figure 6).

Mountain pine beetle hotspots

The mountain pine beetle dataset were obtained from helicopter GPS mapping of clustersof pine trees infested with mountain pine beetle in western Canada. Mountain pine beetlesare a tree-killing insect that emerge from egg galleries in the phloem tissue of the tree’s barkeach year to attack new trees (Safranyik and Carroll 2006). As the tree begins to die, thetree foliage turns red, providing an indication of where the beetles were the previous year(Wulder, Dymond, White, Leckie, and Carroll 2006). In the late 1990s and early 2000s,the largest mountain pine beetle outbreak ever recorded occurred in western Canada. Thepoint observations of attacked tree-clusters were converted to “hotspot” polygons through

Page 12: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

12 stampr: Spatial-Temporal Analysis of Moving Polygons in R

Fri Sat Sun Mon Tue

050

150

250

Are

a (k

m2 x

100

0)Katrina polygonStableDisappearanceGeneration

Figure 7: Changes in area through time of hurricane Katrina polygons along with STAMPevents stable, generation, and disappearance.

kernel density thresholding in order to track how the infestation is spreading from year-to-year (Nelson and Boots 2008). Through spatial-temporal analysis of hotspot movement wecan better understand processes driving the epidemic.

4. Applied polygon change analysis using stampr

4.1. Hurricane Katrina analysis

We performed STAMP analysis with the hurricane Katrina data, computing the STAMPevents along with each distance index described above. We demonstrate how STAMP anal-ysis can inform on polygon-movement for a spatial process changing over time. With thehurricane Katrina data we can see distinct periods of generation (early Saturday and Sun-day) corresponding with the times when the change in polygon area is greatest (steep positiveslope of the Katrina polygon area line Figure 7). We also identify that disappearance is largestas hurricane Katrina dissipates late Monday, and the size of the storm area begins to drop.Comparing between the two polygon-based distance metrics (centroid and Hausdorff distance)we notice that in general the Hausdorff distance is larger than the centroid distance (Figure 8).Directional analysis reveals that the centroid angle method and the area-based directionmethods produce different outputs, leading to differing inferences in some cases. We comparethe centroid angle with the area-weighted mean direction method of the three area-basedmeasures for hurricane Katrina at each time-frame (Figure 9).

4.2. MPB analysis

The Katrina example shows how multi-temporal polygon analysis can be performed using thestampr package for a single event changing over time. The MPB data provides an exampleof stampr application for analysis of many polygons, i.e., 711 polygons over 8 time periods.The MPB data represent two infestations, which are distinguished in the REGION variable inthe dataset. We have used rose diagrams to identify the dominant directions of expansionand contraction events which correspond to different aspects of movement. We investigated

Page 13: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 13

Fri Sat Sun Mon Tue

050

100

150

200

Dis

tanc

e (k

m)

Centroid distanceHausdorff distanceTrajectory (eye) distance

Figure 8: Distance of movement of hurricane Katrina using three different distance metrics:centroid distance, Hausdorff distance, and the trajectory (eye of the hurricane) distance.

Fri Sat Sun Mon Tue

−0.

50.

00.

51.

0

Cos

(θ)

Centroid angleTrajectory (eye) angle

Figure 9: Direction (cosine-transformed) of movement of hurricane Katrina comparing thecentroid angle method to the trajectory (eye of the hurricane) angle. See also Figures 10 and12 for more directional analysis.

directional trends in the north and south independently, examining how the directional dis-tribution of expansion and contraction events changed over time (Figures 10 and 11). We seethat the dominant direction was in the east-west direction in both regions, likely resultingfrom wind patterns. We also see a significant southward expansion event in change period 6in the southern study area (Figure 11).We visualize the spatial-temporal relationships in the MPB northern range data using thedirected graph in Figure 12. Each set of nodes on the same value of the x-axis is a map ofpolygons, and edges are determined by the spatial relationships specified by the parametersof the stamp function, in this case with the distance threshold set to 2 km. The directedgraph can be used to either analyze the structural properties of the evolution of the outbreak,or to identify specific events of interest. Here we queried the graph by degree to highlightnodes (i.e., polygons) with a high degree of interaction with polygons the next year, based on

Page 14: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

14 stampr: Spatial-Temporal Analysis of Moving Polygons in R

Figure 10: Directional analysis of expansion and contraction events in northern region overseven change intervals (labeled 1–7) using a 4 direction cone model.

Figure 11: Directional analysis of expansion and contraction events in southern region overseven change intervals (labeled 1–7) using a 4 direction cone model.

the number of events. Orange nodes in Figure 12 are those with at least 4 interactions withother polygons, and red nodes are polygons with 6 or more. These nodes represent infestationfragmentations or coalescences occurring where landscape scale infestation polygons relate tomany smaller infestation polygons the next year. We can then identify where geographicallysuch events are occurring to investigate further. Such information about spatial relationshipscan provide insight into the spread dynamics represented in the datasets, especially in largepolygon databases.

Page 15: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 15

●●

●●

●●

●●●

●●●

●●

●●●●

●●●

●●

●●

●●

●●

●●

●●●

●●●

●●

●●●

●●

●●●●●

●●●●

●●

●●●●●

●●

●●●

●●

●●●

●●●

●●

●●

●●

●●●

●●

●●●●●

●●●

●●

●●●

●●

●●

●●

●●

●●●

●●

●●

●●

●●

●●●●●●

●●

●●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●●

●● ●●

●●

●●●●

●●●

●●

●●

●●

●●

●●

●●

●●● ●●●

●●●

●●

●●

●●

●●

●● ●● ●

●●

●●●●

●●●

●●

45

616

8

67

69

70

7173

72

78

798384

89

108

153154

262

265

267

294

302

272

276

337

338

339

340341344346

342

343

348

350

450

451

452453

454

455

456

457

458

459461

462

463

464

465

466

467

477478

493

506

469

472

473

474

476

555557

558

561

564

565

570

572

574

577

583

587

588

590

591

593595

596

599

601

556

101314

21

22

23

11

12

18

20

24

293033

35

32

34

36

4238394344

19

26

80

86

82

85

88

92

91

939895

97

109100

101102103105106

111

113115

117118120

7577

119

170

173

176186190

199

201

203208211

175

177

178

185

189

179181

187188

196192197

193

194198

195

204

202

206209210213

207215214

216218

220

221

222

224

226228

163

212

219

277

269

278

280

285

281284

286

289

290

291295

293296297

298

299300

303304

305

306

307

310

263

264266

271

275301

352

356

370376392395

400

353354

355

357364368

365

366377

379

380381

382

383

384385

386

388

390

391393

396

397

398402

403

401

405

345

389

399

404

406

479

481

484

495489

491

497

499

504

500502

507

508

512

511

515

448449 559560

562

569

571

575

578

582

581584589592

594598

600

602

603604

566568

573

576

597

74

165168

167

200

217

363

358

684

646

657

660

638639

642

110

112

114

116121122

184191

205

223225227

283

270273

274

282

279

288

308

309

361

369

373

371

375

360394

470

471

482

480

483

485486

496

503505

460510585547

644

645

653

655

658

664

666

667668672675

680

683

686685687

649650

662

679

Figure 12: Directed graph of northern region polygon spatial relationships, labeled by polygonID. High degree nodes are highlighted where multiple polygons are interacting at neighboringtime periods.

5. DiscussionSTAMP analysis enables a finer understanding of the spatial processes associated with movingpolygons. Specifically STAMP facilitates the categorization of 11 different types of movementevents (see RNBW), which provide information for evaluating the processes generating ob-served polygon movements. The STAMP categorizations are enhanced through distance anddirectional analysis, which adds geographical context to movement event analysis. For exam-ple, in the hurricane Katrina analysis we are able to clearly identify times and directions ofmovement when the hurricane was speeding up (high generation area in Figure 7) and slowingdown (high disappearance area in Figure 7). These inferences are corroborated when com-pared with the Hausdorff distance metric (Figure 8), and would not have been observed using

Page 16: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

16 stampr: Spatial-Temporal Analysis of Moving Polygons in R

a traditional point-based analysis of hurricane trajectories. In the MPB example, we wereable to compare directional change distributions, and isolate a specific event where infestationfragmentation occurred. These examples provide just a flavor of the types of analysis thatcan be accomplished with the STAMP framework as implemented in the stampr package.There exist opportunities for new methods and techniques for polygon movement analysis.One of the main limitations of polygon movement analysis is that there is often no singularresult with respect to either distance or directional relationships. The lack of a formal truthmakes interpreting the results application specific, highlights the need for an exploratory dataanalysis approach, and requires analysts to carefully evaluate which methods align best withtheir study objectives. Future developments would benefit from considering null distributionsof movement indices for hypothesized change types, which could then be used to assess thesignificance of observed events.Within the stampr package we have included a range of methods for performing distanceand direction analysis on polygon movements. The tools we have implemented represent thestate-of-the-art for polygon movement analysis. However, we see opportunities for continueddevelopment of spatial-temporal polygon analysis methods. As new methods are documentedwe can add these to the package function set. Finally, we hope that the stampr packagecontinues to build on the suite of spatial methods available within R, attracting a wide rangeusers to polygon-based spatial analysis techniques.

6. ConclusionsMovement research in geographic information science is proliferating due to new datasets andthe growing complexities of data (Long and Nelson 2013). The multi-method approach topolygon change analysis employed here is valuable in that it produces a broader understandingof the underlying movement dynamics, and facilitates comparisons between methods whendissimilar results are achieved. Here we highlight an example using the movement of hurricaneKatrina and demonstrate the value of a polygon-based approach when contrasted with themore common trajectory-based analyses, and an analysis of landscape scale forest infestationspread. Future research should look to expand the application of polygon movement analysisnow that these computational tools are readily available, as well as extending the methodologyto incorporate spatial simulation models and other forms of spatial representation into theevent-based framework implemented here. There are many application areas where polygonchange analysis has been ignored (due to limited methods and tools) or where more simplisticapproaches have been favored (based purely on polygon centroids). The development of aspatial toolkit for polygon change analysis, the stampr package, will reinvigorate researchinto performing spatial-temporal analysis of moving polygons.

References

Bivand R, Rundel C (2017). rgeos: Interface to Geometry Engine – Open Source (GEOS). Rpackage version 0.3-26, URL https://CRAN.R-project.org/package=rgeos.

Cova T, Goodchild M (2002). “Extending Geographical Representation to Include Fields of

Page 17: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 17

Spatial Objects.” International Journal of Geographical Information Science, 16(6), 509–532. doi:10.1080/13658810210137040.

De Berg M, Van Kreveld M, Overmars M, Schwarzkopf OC (2008). Computational Geometry:Algorithms and Applications, chapter Computational Geometry, pp. 1–17. 3rd edition.Springer-Verlag. doi:10.1007/978-3-540-77974-2.

Egenhofer MJ, Franzosa RD (1991). “Point-Set Topological Spatial Relations.” Inter-national Journal of Geographic Information Systems, 5(2), 161–176. doi:10.1080/02693799108927841.

Hijmans RJ (2017). raster: Geographic Data Analysis and Modeling. R package version 2.6-7,URL https://CRAN.R-project.org/package=raster.

Liu W, Deng M (2002). “Spatial Relations between Area Objects under Metric Spaces.” InSymposium on Geospatial Theory, Processing and Applications, pp. 1–11. Ottawa.

Long J, Robertson C (2018). stampr: Spatial Temporal Analysis of Moving Polygons. Rpackage version 0.2, URL https://CRAN.R-project.org/package=stampr.

Long JA, Nelson TA (2013). “A Review of Quantitative Methods for Movement Data.”International Journal of Geographical Information Science, 27(2), 292–318. doi:10.1080/13658816.2012.682578.

McGarigal K, Marks BJ (1995). Fragstats: Spatial Pattern Analysis Program for QuantifyingLandscape Structure. US Dept. of Agriculture, Forest Service, Pacific Northwest ResearchStation, Portland.

Miller HJ, Wentz EA (2003). “Representation and Spatial Analysis in Geographic InformationSystems.” The Annals of the Association of American Geographers, 93(3), 574–594. doi:10.1111/1467-8306.9303004.

Mizutani C (2012). “Construction of an Analytical Framework for Polygon-Based Land UseTransition Analyses.” Computers, Environment and Urban Systems, 36(3), 270–280. doi:10.1016/j.compenvurbsys.2011.11.004.

Morris LR, Blackburn JK, Talibzade A, Kracalik I, Ismaylova R, Abdullahyev R (2013). “In-forming Surveillance for the Lowland Plague Focus in Azerbaijan Using a Historic Dataset.”Applied Geography, 45, 269–279. doi:10.1016/j.apgeog.2013.09.014.

Nelson TA, Boots B (2008). “Detecting Spatial Hot Spots in Landscape Ecology.” Ecography,31(5), 556–566. doi:10.1111/j.0906-7590.2008.05548.x.

Pebesma E (2017). CRAN Task View: Handling and Analyzing Spatio-Temporal Data. Ver-sion 2017-07-03, URL https://CRAN.R-project.org/view=SpatioTemporal.

Pebesma EJ, Bivand RS (2005). “Classes and Methods for Spatial Data in R.” R News, 5(2),9–13.

Peuquet D, Zhang CX (1987). “An Algorithm to Determine the Directional RelationshipBetween Arbitrarily-Shaped Polygons in the Plane.” Pattern Recognition, 20(1), 65–74.doi:10.1016/0031-3203(87)90018-5.

Page 18: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

18 stampr: Spatial-Temporal Analysis of Moving Polygons in R

Powell MD, Houston SH, Amat LR, Morisseau-Leroy N (1998). “The HRD Real-Time Hurri-cane Wind Analysis System.” Journal of Wind Engineering and Industrial Aerodynamics,77–78, 53–64. doi:10.1016/s0167-6105(98)00131-7.

R Core Team (2017). R: A Language and Environment for Statistical Computing. R Founda-tion for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.

Robertson C (2016). “Space-Time Topological Graphs.” In International Conference onGIScience Short Paper Proceedings, volume 1, pp. 256–259. Montreal.

Robertson C, Nelson T (2008). “A Comparison of Methods for Computing Cardinal Di-rectional Relations of Polygons.” In Spatial Knowledge and Information Canada 2008,volume 1, pp. 60–61. Fernie.

Robertson C, Nelson T, Boots B, Wulder MA (2007). “STAMP: Spatial-Temporal Analysisof Moving Polygons.” Journal of Geographical Systems, 9(3), 207–227. doi:10.1007/s10109-007-0044-2.

Sadahiro Y (2001). “Exploratory Method For Analyzing Changes In Polygon Distributions.”Environment and Planning B: Urban Analytics and City Science, 28(4), 595–609. doi:10.1068/b2752.

Sadahiro Y, Umemura M (2001). “A Computational Approach for the Analysis of Changesin Polygon Distributions.” Journal of Geographical Systems, 3(2), 137–154. doi:10.1007/pl00011471.

Safranyik L, Carroll A (2006). “The Biology and Epidemiology of the Mountain Pine Beetlein Lodgepole Pine Forests.” In The Mountain Pine Beetle, a Synthesis of Biology, Man-agement, and Impacts on Lodgepole Pine, pp. 3–66. Natural Resources Canada, CanadianForest Service, Pacific Forestry Centre, Victoria.

Shao F, Cai S, Gu J (2010). “A Modified Hausdorff Distance Based Algorithm for 2-Dimensional Spatial Trajectory Matching.” In 2010 5th International Conference on Com-puter Science and Education (ICCSE), pp. 166–172. Hefei. doi:10.1109/iccse.2010.5593666.

Skiadopoulos S, Giannoukos C, Sarkas N, Vassiliadis P, Sellis T, Koubarakis M (2005). “Com-puting and Managing Directional Relations.” IEEE Transactions on Knowledge and DataEngineering, 17(12), 1610–1623. doi:10.1109/tkde.2005.192.

Smulders M, Nelson TA, Jelinski DE, Nielsen SE, Stenhouse GB, Laberee K (2012). “Quan-tifying Spatial-Temporal Patterns in Wildlife Ranges Using STAMP: A Grizzly Bear Ex-ample.” Applied Geography, 35(1–2), 124–131. doi:10.1016/j.apgeog.2012.06.009.

Stell J, Worboys M (2011). “Relations Between Adjacency Trees.” Theoretical ComputerScience, 412(34), 4452–4468. doi:10.1016/j.tcs.2011.04.029.

Wulder MA, Dymond CC, White JC, Leckie DG, Carroll AL (2006). “Surveying MountainPine Beetle Damage of Forests: A Review of Remote Sensing Opportunities.” Forest Ecologyand Management, 221(1–3), 27–41. doi:10.1016/j.foreco.2005.09.021.

Page 19: stampr: Spatial-TemporalAnalysisofMoving Polygonsin R · 2018. 4. 29. · Network(CRAN)athttps: ... RNBW implemented an event-based framework for categorizing polygon movement events

Journal of Statistical Software – Code Snippets 19

Zhang Z, Huang K, Tan T (2006). “Comparison of Similarity Measures for Trajectory Clus-tering in Outdoor Surveillance Scenes.” In 18th International Conference on Pattern Recog-nition (ICPR’06), volume 3, pp. 1135–1138. Hong Kong. doi:10.1109/icpr.2006.392.

Affiliation:Colin RobertsonDepartment of Geography and Environmental StudiesWilfrid Laurier UniversityWaterloo, ON, CanadaE-mail: [email protected]: http://thespatiallab.org/

Journal of Statistical Software http://www.jstatsoft.org/published by the Foundation for Open Access Statistics http://www.foastat.org/

April 2018, Volume 84, Code Snippet 1 Submitted: 2016-11-03doi:10.18637/jss.v084.c01 Accepted: 2017-06-12