Skip to main content

Questions tagged [spatstat]

spatstat is a package for the statistical software suite R to conduct spatial point pattern analysis and modeling

Filter by
Sorted by
Tagged with
0 votes
0 answers
17 views

Kcross inhomogenous function in R

I'm trying to compute a Kcross.inhom function for a multiple point patter object with the envelope function in R with the following code envelope_kcross <- envelope(p, ...
Lorenzo Biferale's user avatar
0 votes
0 answers
123 views

When I install package spatstat R doesn't install it

My problem is that I have tried various times to install spatstat, but R never installs it. I get an error message which is attached (doesn't let me attach the image): > install.packages("...
david 007's user avatar
0 votes
1 answer
589 views

How to create a ppp spatstat object from a sf object

I am trying to create a ppp object from a sf object in R. I am using the population-weighted centroids in Minnesota from 2020 census data. You can find the data here: https://www2.census.gov/geo/docs/...
rodrigo franco's user avatar
0 votes
1 answer
482 views

Rasterise a point pattern in R

I have a set of georeferenced points within an area for which I want to know the spatial distribution (sparse/clustered) according to a regular grid. I thought to describe the pattern using the Clark-...
Nico's user avatar
  • 305
0 votes
0 answers
154 views

ks.test in spatstat package

I'm trying to make ks.test on my data in spatstat package. I use ppp function to create my pattern named ppp then when i try this code: ks.test(ppp,"x") as in the documentation it says ...
Dorian Grousset's user avatar
1 vote
0 answers
36 views

Accounting for minimum distance between points when conducting point pattern analyses in spatstat

I've noticed an issue when performing exploratory analyses of my point pattern. When plotting a G function in spatstat, I've noticed G values remain near zero up to an r of around 5 micron [see below ...
plackden's user avatar
1 vote
1 answer
94 views

Tessellation will not display quadrat totals when plotted (spatstat, R)

I have tessellated an image, and am trying to plot the number of quadrats that appear in each tessellated region. I have two problems here: My tessellated image will not plot with my gw_ppp points, ...
s_o_c_account's user avatar
1 vote
1 answer
2k views

Creating a point pattern (ppp) error using SpatStat in R: "Only projected coordinates may be converted to spatstat class objects"

I have a point dataset, and I am taked with filtering out duplicate coordinates, removing all points that are outside of a specified county shapefile, and then creating a ppp points object. However, ...
s_o_c_account's user avatar
0 votes
1 answer
310 views

Extract a network from spatstat to graph object in igraph using R

I am looking for an efficient way to transfer a linear network (class linnet) from spatstat, e. g. library(spatstat); data('chicago'); net <- spatstat.linnet::domain.lpp(chicago) to a 'graph' ...
user avatar
0 votes
1 answer
625 views

Plot points in spastat ppp object

I am new to spatstat package and I am trying to make a point patten map with a shape file and some case points. I was able to plot the shape file plot but I just don't know how to make the points on ...
codedancer's user avatar
2 votes
1 answer
264 views

Calculating the cross-nearest-neighbor distance in spatstat

I wish to calculate the cross-nearest-neighbor distance between two point patterns in spatstat. According to Pr. Sadahiro, the cross-nearest-neighbor distance is defined as: My inputs are sf datasets,...
syre's user avatar
  • 407
0 votes
0 answers
323 views

How do you convert SpatialPoints object to PPP object?

I have a shapefile layer of polygons (houses in a city) that I want to run a kernel density on using the density() function in spatstat in R. To get my polygons as points I turned them into ...
LostinSpatialAnalysis's user avatar
1 vote
0 answers
111 views

R statspat package (or similar pkg) and convert back to spatial objects

I've been testing the waters and doing some basic overview on the statspat package. This is a complex package and would likely require some serious effort to jump in and then get familiar with the ...
Gray's user avatar
  • 151
1 vote
1 answer
680 views

Shapefile vector point to ppp spatstat with polygon windows

I always get error to this when converting shapefile point to ppp spatstat that windowed by a polygon shapefile # polygon that to be window neighborhoods <- st_read("neighborhoods/...
Ichsan's user avatar
  • 165
0 votes
1 answer
149 views

Estimating spatial autocorrelation from counts on linear network [closed]

I'm working with count data sampled along roadways. I would like to estimate the spatial autocorrelation of the counts, but I'm having trouble wrapping my head around how to incorporate the network ...
Sean Hardison's user avatar
1 vote
1 answer
420 views

Error in converting shapefiles into spatstat window

I wish to import shapefiles of the Seoul Capital Area to use as a window in spatstat. The SCA is the combination of the Seoul, Incheon, and Gyeonggi-do level-1 administrative areas of South Korea. I ...
syre's user avatar
  • 407
1 vote
0 answers
32 views

How much W shape effects on the cross correlation of points in R

I am analyzing cross-correlation between these two-point data sets (all the analyses have been performed in R: by using Kcross, Lcross functions). In the first trial, I was using an irregular ...
Kika's user avatar
  • 19
0 votes
0 answers
106 views

The confidence level alfa value for spatial randomness with Ripley K and L function

I have a point set of the spatial distribution of twitter posts relevant to a certain event. I would like to evaluate evidence for clustering or dispersion of points. This is usually performed by ...
Kika's user avatar
  • 19
1 vote
0 answers
45 views

Replicated Point Pattern: Get Density Variance Between Replicated Patterns and Subtract from Composite

I have written a lengthy code that dissects differently shaped/sized windows into recognizable components (individual cells in the image), gets the point density within each cell, then builds a whole ...
James Fischer's user avatar
2 votes
1 answer
1k views

calculate distance of points from centroid

I have a spatialpoints object, and a spatialpolygonsdataframe, composed of rectangular cells, and which the spatialpoints fall into. What I would like is to determine which polygon in the ...
James Fischer's user avatar
1 vote
1 answer
29 views

DSpat::create.lines and spatstat::rlinegrid: Adding too many lines?

Does anybody know of an issue with either DSpat's create.lines or spatstat's rlinegrid? Whenever I use these functions on my Windows (owins), the output has far too many lines. For example, if I run ...
James Fischer's user avatar
1 vote
1 answer
233 views

Connecting spatiallines or SpatialPoints based on minimum distance using R

Does anybody know of a way to create a single polygon (that will eventually be converted to an Owin) from either a spatialpoints object or a spatiallines object? Here is an example of each: Here's ...
James Fischer's user avatar
2 votes
1 answer
180 views

Aligning Multiple Polygons (Based on centroid possibly) [Spatstat, sf, sp]

I'm trying to create a composite/average of multiple similarly shaped polygons. I think the first step is most likely to align them via the centroid of each polygon. Does anybody know of a tool to ...
James Fischer's user avatar
2 votes
2 answers
2k views

QGIS enabling R via plugin

System Ubuntu 19.10, QGIS 3.4 I am trying to utilise R in QGIS for Ripley's K function. The sample R script 'Scatterplot' works with the Processing R Provider plugin, which indicates r-base is ...
Neil's user avatar
  • 53
1 vote
1 answer
230 views

Generating pattern in each of set of polygons using sp (r)?

I have an object of class SpatialPolygonsDataFrame, and for each polygon in the dataframe I have a number of points I would like to generate in that polygon (e.g. I have 130 polygons, and I have a ...
James Fischer's user avatar
3 votes
2 answers
2k views

R (spatstat, sp, sf): Grid a single polygon, divide, alphanumeric labels based on column/row

I am trying to take a polygon and add grid lines over top, then divide the polygon into many polygons based on the grids. I've accomplished this through st_make_grid() and raster::intersect(). The ...
James Fischer's user avatar
1 vote
0 answers
149 views

Multiple Spatial Point Patterns, create "average" heatmap

I am using R's spatstat package to analyze spatial patterns of objects across plant leaves. Let's say I have 10 leaves, each with corresponding X,Y coordinates of the objects and a window in the ...
James Fischer's user avatar
1 vote
1 answer
176 views

Point.in.polygon function in sf package miscalculate the distribution of points

I am using point.in.polygon function in sf package to determine whether a set of data fall within a polygon or not. Here is a snippet of the data and polygon visualization As the figure shows, there ...
HAOYANG Mi's user avatar
1 vote
1 answer
347 views

Convert ppp object to multitpe object

I am working on spatial point pattern analysis using R. I have two sets of coordinates, both defined inside a 32*20 region. I first convert two data sets to ppp objects: Tumor_CD8 <- ppp(...
HAOYANG Mi's user avatar
3 votes
0 answers
270 views

Test the relationship between two point patterns

I have two point patterns obtained from medical images. Points are used to represent cell markers. By visualization, the point pattern A is extremely possible to be a subset of point pattern B. So is ...
Shawn's user avatar
  • 31
0 votes
0 answers
280 views

Generating Pseudo-Absences in spatialEco?

I want to generate pseudo absences based on kernel density estimate from a linear feature spatial line layer, where pseudo absences have a higher probability of being sampled near a line. I have ...
Matt's user avatar
  • 23
1 vote
1 answer
295 views

Adjusting resolution of spatstat::pixellate.psp() output

I am trying to accomplish exactly what is being done in this question: Convert line shapefile to raster, value=total length of lines within cell using spatstat::pixellate.psp() technique (see third ...
mikeLdub's user avatar
  • 1,205
1 vote
1 answer
485 views

Kernel Density Map points rejected as outside window

I am trying to make a kernel density plot of a points shapefile like so: library(rgdal) library(spatstat) library(maptools) points <- readOGR(dsn = "C:\\Documents", layer = "...
Stefano Potter's user avatar
2 votes
0 answers
90 views

One-dimensional data in spatstat

I have data of one-dimensional points (locations in a straight line). I want to check if the cluster poisson process models or Cox models are a good fit for the data. Since my data only has x-...
user2128233's user avatar
0 votes
1 answer
502 views

How to have a Raster output of a ppm model in spastat

I am trying to compare the outputs of species distribution models. My current code uses the following function to calculate TSS scores. TSS_Score<-function(TrueBinary, Raster) { Raster[]<-as....
mlfp88's user avatar
  • 23
1 vote
2 answers
134 views

Error in pairdist calculation

I'm trying to calculate pair distances among the points of my dataset. I have point in EPSG:3857. This is the code I ran: I import the data, then: coordinates(datPb) <- c("X","Y") proj4string(...
user41334's user avatar
3 votes
1 answer
2k views

Removing frame/plot borders from plot.im output

I am plotting point density using the plot.im command in spatstat, and my output always has a frame around the plotted image that becomes thicker when I increase resolution for export. I tried frame=F,...
Ash's user avatar
  • 31
1 vote
1 answer
1k views

Creating polygonal windows for spatial analysis in r

I am attempting to normalize a spatial point pattern using a population density raster in r. My problem is that the function I am trying to run is recognizing the "white space" around the raster I am ...
Michael 's user avatar
14 votes
1 answer
4k views

Calculating road density in R using kernel density? [closed]

I have a large (~70MB) shapefile of roads and want to convert this to a raster with road density in each cell. My initial approach was to directly calculate the lengths of line segments in each cell ...
Matt SM's user avatar
  • 1,851
0 votes
1 answer
636 views

Adding 'marks' to point file in spatstat?

Using help on this site I have already got the following code from where I can perform certain analyses. However, I'd now like to perform analyses on a certain variable (column z) within the point ...
user2224979's user avatar
3 votes
1 answer
1k views

Adding point shapefile layer to polygon shapefile window in R?

I'm new to Spatstat for R and I'm trying to add a point layer to a window I've created from a polygon. I see questions like this have been asked before but I still can't get what I need from the ...
user2224979's user avatar
1 vote
3 answers
2k views

R package spatstat: How to use point process model covariate as factor when pixel image values are numeric

I am trying to model a point process with an image covariate using the ppm() function in the spatstat package in R. I convert my raster to an im object for use with spatstat, and I run into a problem ...
thegowda's user avatar
1 vote
3 answers
4k views

Converting raster to im object for point process model covariate in R?

I am trying to convert a raster object to an .im object for use with a point process model in the spatstat package in R. I begin by creating the raster from a tiff file using the raster() package. No ...
thegowda's user avatar
1 vote
1 answer
3k views

How to find highest kernel density point

I've been using spatstat to analyse point patterns in R. Here's an example to put this in context: library(spatstat) library(maptools) # to convert sp class to ppp Some point data: set.seed(1985) x ...
RobinLovelace's user avatar
0 votes
1 answer
3k views

How can I connect my point pattern shapefile with my polygon window in R?

I would like to do some spatial statistics in R. I have a point layer called '1983' that represents the distribution of one species, and a polygon layer called 'SA-R' that represents the study area. ...
Murphy's user avatar
  • 165
3 votes
1 answer
2k views

Python equivalent of spatstat's spatial point process functions

Is there a free Python package (i.e. PySAL?) that implements the standard summary statistics for spatial point processes, e.g. the F, G, J, and K functions? I'm happy to use R (i.e. spatstat) if that'...
stackoverflax's user avatar
2 votes
1 answer
2k views

R - Crop a pixel image produced by spatstat with a boundary shape

i am using the very good spatial statistic package spatstat to produce probability maps of spatial point patterns. Here is a simple working result from the examples to try out. require(spatstat) ...
Curlew's user avatar
  • 8,180
13 votes
3 answers
8k views

How to get the second nearest neighbor between two point patterns in R?

Is there a way to get the distances for the second nearest neighbor between two point patterns in R? The spatstat package has a function called nncross but it only applies to the nearest neighbors ...
R.K.'s user avatar
  • 17.4k
22 votes
3 answers
5k views

Using R with ArcGIS Desktop?

I've used the integration of R with QGIS, and found it a very uesful tool. Having taken a look at the R toolbox extension for 9 and the extension for 10 it appears they both offer only point ...
om_henners's user avatar
  • 15.7k