Questions tagged [spatstat]

spatstat is an R package for analysing spatial data, mainly Spatial Point Patterns.

spatstat is an R package for analysing spatial data, mainly Spatial Point Patterns. It also supports three-dimensional point patterns, and space-time point patterns in any number of dimensions. The package contains over 1000 functions for plotting spatial data, exploratory data analysis, model-fitting, simulation, spatial sampling, model diagnostics, and formal inference. Data types include point patterns, line segment patterns, spatial windows, pixel images and tessellations.

Resources:

441 questions
14
votes
2 answers

Voronoi diagram polygons enclosed in geographic borders

I am trying to create Voronoi polygons (aka Dirichlet tessellations or Thiessen polygons) within a fixed geographic region for a set of points. However, I am having trouble finding a method in R that will bound the polygons within the map borders.…
Bryan
  • 1,771
  • 4
  • 17
  • 30
12
votes
4 answers

finding point of intersection in R

I have 2 vectors: set.seed(1) x1 = rnorm(100,0,1) x2 = rnorm(100,1,1) I want to plot these as lines and then find the intersection points of the lines, also if there are multiple points of intersection then I want to locate each of them. I have…
SBS
  • 159
  • 1
  • 2
  • 8
10
votes
2 answers

plotting and coloring data on irregular grid

I have data in the form (x, y, z) where x and y are not on a regular grid. I wish to display a 2D colormap of these data, with intensity (say, grey scale) mapped to the z variable. An obvious solution is to interpolate (see below) on a regular…
baptiste
  • 75,767
  • 19
  • 198
  • 294
7
votes
4 answers

How do I generate data where points are 'repelled' if they land within a certain proximity to another point?

I'm using runifdisc to plot random points on a disc, but I don't want those points to land within a certain proximity of the other points. The points are currently parsed into squares and triangles. I'm using the spatstat package. Is there a way to…
Taiku
  • 333
  • 1
  • 8
6
votes
3 answers

R - Plotting Hexagon Tessellations

I'd like to generate some square plots that have arrays of hexagons inside of them, like drawn here. I'd like to plot both regular (geometrically regular) and abnormal hexagon tessellations, so I don't think tools from the "sp" package will work. …
Nathan
  • 323
  • 3
  • 13
6
votes
1 answer

How to generate spatial points with a pattern

I am doing some work where I need to generate both a) random spatial points b) non-random spatial points, over a polygon i.e. for b) the points probability depends on for example an East-West gradient, or distance from some point source or something…
user2498193
  • 1,072
  • 2
  • 13
  • 32
6
votes
2 answers

R package "spatstat": How do you get standard errors for non-smooth terms in a poisson process model (function: ppm) when use.gam=TRUE?

In the R package spatstat (I am using the current version, 1.31-0) , there is an option use.gam. When you set this to true, you can include smooth terms in the linear predictor, the same way you do with the R package mgcv. For example, g <-…
Macro
  • 1,450
  • 1
  • 10
  • 18
5
votes
1 answer

Finding euclidean distance in R{spatstat} between points, confined by an irregular polygon window

I'm trying to find the euclidean distance between two points, confined by an irregular polygon. (ie. the distance would have to be calculated as a route through the window given) Here is an reproducible example: library(spatstat) #Simple example of…
user3389288
  • 992
  • 9
  • 30
4
votes
2 answers

Use sf polygon object as window in spatstat

Hello all potential helpers, I have a SpatialPolygonDataFrame object obtained from the tigris package and I would like to use it as a polygonal window in the creation of a ppp object. Here is what I tried: # Needed…
SavedByJESUS
  • 3,262
  • 4
  • 32
  • 47
4
votes
1 answer

Functions Causing Objects to Disappear

This is a very strange situation that I've come across. Basically, I'm trying to fit a cumulative distribution function to the G function of my data. After doing so, I want to plot the the model and the original data, and output this as PDF. I'll…
MikeZ
  • 345
  • 1
  • 4
  • 15
3
votes
2 answers

pseudo-random pattern with fixed density and exclusion zone

I wish to create a 2D set of N points (typically 1e2 - 1e4) in a square with the following constraints: there should be a minimal distance between all points (hard core exclusion zone) the number of points filling the square is given in advance (or…
baptiste
  • 75,767
  • 19
  • 198
  • 294
3
votes
1 answer

Searching for a way to use `linearKEuclid` and corresponding functions of `spatstat`

My goal is to analyse simple point patterns on linear networks with respect to Euclidean distance instead of shortest-path distance implemented in linearK and related functions of spatstat and its sub packages. Browsing through the web I found the…
Dabbler
  • 33
  • 3
3
votes
1 answer

Calculating 95% confidence intervals for a weighted median over grouped data in dplyr

I have a dataset with several groups, where I want to calculate a median value for each group using dplyr. The data are weighted, and the weights need to be taken into account in calculating the median. I found the weighted.median function from…
Joe
  • 3,831
  • 4
  • 28
  • 44
3
votes
2 answers

Convert sf to unmarked ppp

I wish to convert an sf object to an unmarked ppp. (Conversion from sf to ppp is now supported, according to this post.) library(sf) #Initialise sf object pp <- structure(list(X = c(959207.877070254, 959660.734838225, 951483.685462513, …
syre
  • 902
  • 1
  • 7
  • 19
3
votes
1 answer

R - Spatstat - Nearest neighbour searching by ID using data table

I have two large dataframes called intersections (representing intersections of a street system) and users (representing users of a network) as follows: intersections has three columns: x,y and label_street. They respectively represent the position…
QLG
  • 77
  • 5
1
2 3
29 30