Pointprocess modelling with the sp and spatstat packages
Some simple examples of importing spatial data from text files, converting between R datatype, creation of a point process model and evaluating the model. Input data sources are: soil pit locations with mollic and argillic diagnostic horizons (mollicpedons.txt and argillicpedons.txt), and a simplified outline of Pinnacles National Monument (pinn.txt). The outline polygon is used to define a window in which all operations are conducted.
The 'sp' package for R contains the function spsample(), can be used to create a sampling plan for a given region of interest: i.e. the creation of n points within that region based on several algorithms. This example illustrates the creation of 50 sampling points within Pinnacles, according to the following criteria: regular (points are located on a regular grid), nonaligned (points are located on a nonaligned gridlike pattern), random (points are located at random), stratified (collectively exhaustive, see details here).
The 'spatstat' package for R contains several functions for creating pointprocess models: models describing the distribution of point events: i.e. the distribution of tree species within a forest. If covariate data is present (i.e. gridded precipitation, soil moisture, aspect, etc.) these covariates can be incorporated into the pointprocess model. Without covariate data, the model is based on an spatial distribution estimator function. Note that the development of such models is complicated by factors such as edgeeffects, degree of stochasticity, spatial connectivity, and stationarity. These are rather contrived examples, so please remember to read up on any functions you plan to use for your own research. An excellent tutorial on Analyzing spatial point patterns in R was recently published.
Helpful links
Spatstat Quick Reference
Print Version with Links


Note: This code should be updated to use the slot() function instead of the '@' syntax for accessing slots!
Load required packages and input data (see attached files at bottom of this page)
Using the functions from the 'sp' package create a polygon object from the pinn.txt coordinates
Generate a sampling plan for 50 sites using regular grid, nonaligned grid, random, and random stratified approaches
Convert 'sp' class objects to 'spatstat' analogues note the use of 'slots'
Plot and summarize the new combined set of pedon data
Convert the sampling design points (from above) to 'spatstat' objects and plot their density
Simple, and probably flawed attempt to use a pointprocess model for the pedon data Third order polynomial model for the distribution of pedons with a mollic epipedon. See manula page for ppm() for detailed examples.
Pointprocess model diagnostic references from the spatstat manual
Baddeley, A., Turner, R., Moller, J. and Hazelton, M. (2005) Residual analysis for spatial point processes. Journal of the Royal Statistical Society, Series B 67, 617–666.
Stoyan, D. and Grabarnik, P. (1991) Secondorder characteristics for stochastic structures connected with Gibbs point processes. Mathematische Nachrichten, 151:95–100.
Attachments:
Software
 General Purpose Programming with Scripting Languages
 LaTeX Tips and Tricks
 PostGIS: Spatially enabled Relational Database Sytem
 PROJ: forward and reverse geographic projections
 GDAL and OGR: geodata conversion and reprojection tools
 R: advanced statistical package
 Access Data Stored in a Postgresql Database
 Additive Time Series Decomposition in R: Soil Moisture and Temperature Data
 Aggregating SSURGO Data in R
 Cluster Analysis 1: finding groups in a randomly generated 2dimensional dataset
 Color Functions
 Comparison of Slope and Intercept Terms for MultiLevel Model
 Comparison of Slope and Intercept Terms for MultiLevel Model II: Using Contrasts
 Creating a Custom Panel Function (R  Lattice Graphics)
 Customized Scatterplot Ideas
 Estimating Missing Data with aregImpute() {R}
 Exploration of Multivariate Data
 Interactive 3D plots with the rgl package
 Making Soil Property vs. Depth Plots
 Numerical Integration/Differentiation in R: FTIR Spectra
 Plotting XRD (XRay Diffraction) Data
 Using lm() and predict() to apply a standard curve to Analytical Data
 Working with Spatial Data
 Customizing Maps in R: spplot() and latticeExtra functions
 Converting AlphaShapes into SP Objects
 Some Ideas on Interpolation of Categorical Data
 Visual Interpretation of Principal Coordinates (of) Neighbor Matrices (PCNM)
 Visualizing Random Fields and Select Components of Spatial Autocorrelation
 Generation of Sample Site Locations [sp package for R]
 Target Practice and Spatial Point Process Models
 Ordinary Kriging Example: GRASSR Bindings
 Pointprocess modelling with the sp and spatstat packages
 Simple Map Creation
 Comparison of PSA Results: Pipette vs. Laser Granulometer
 GRASS GIS: raster, vector, and imagery analysis
 Generic Mapping Tools: high quality map production