Spatstat - how to compare two temperature spatial domains? - r

I would like to compare a satellite pseudo-image generated by the WRF model and a real satellite image with the R-package named Spatstat. However, I do not know how to begin. I have read that it is possible to carry out a spatial pattern comparison but I do not know which function I should use. I have two temperature images in a predefined domain and I would like to know if the comparison is carried out point-by-point over those images or I have to facilitate the model output and satellite data. In that case, how should I do that? Is there any available script?
Thanks in advance.
Kind regards, Lara.

The spatstat package is designed mainly to analyse spatial patterns of point locations (like the pattern of locations of accidents that occurred in a given year). It does have some basic facilities for comparing pixel images. If A and B are two pixel images, you can do arithmetic by typing e.g. mean(A-B) or mean(abs(A-B)). There are also some image metrics (distances between images) available. Please visit the spatstat.org website for more information.

Related

Artifact correction in spatstat for biological cells point patterns

I am using spatstat to analyze biological cells (dependencies, interactions, etc.) with their centers to generate point patterns. However, I realize the artifact caused due to their sizes in 2D. What are the best ways to correct such artifacts when using K/L, G- functions, etc.? Thanks.
This is still a research question (i.e. a topic of research in statistical methodology).

Adding spatial clustering data in Map by R

I have the results for spatial clustering, in this results I have the id for some cities in USA. I would like to show this clustering results on a nice map. Is this feasible in R?
Yes, this is feasible.
You need to map the city ids to geographical data, then visualize it.
With the extensive drawing capabilities of R, this is not very hard; there are several R packages that will do the heavy lifting, and tutorials to guide you. Just pick whatever package you prefer.
We cannot give you a complete source, of course, because we don't know what kind of ids you have. For example many people use zip codes, others use FIPS ids, etc.

mxnet for per-pixel image classification/regression

I am looking for best-practice or case studies using R's "mxnet" for the pixel-wise classification of multi-band imagery (RGB, mlutispectral/hyperspectral aerial or satellite remote sensing). Indeed there is bunch of best practise in image tagging (e.g. dogs vs cats in huge image archives like imagenet) where the whole image is classified and usually a lot of training data (or pretrained models) are available. However, I do not find anything concerning pixel-wise image classification/regression, where training data typically is a bit more sparse and applications deal e.g. with land cover categories, objects (like cars, buildings etc.) or biophysical variables (biomass, soil wetness, chlorophyll content etc.).
FCN (Fully Conv Network) is the pixel-based segmentation that seem to fit your need.
MXNet has a nice example showing FCN-xs that uses Python, but if you are really into R you should be able to convert it, or just use the pre-trained network that is available in the example.

Point pattern similarity and comparison

I recently started to work with a huge dataset, provided by medical emergency
service. I have cca 25.000 spatial points of incidents.
I am searching books and internet for quite some time and am getting more and more confused about what to do and how to do it.
The points are, of course, very clustered. I calculated K, L and G function
for it and they confirm serious clustering.
I also have population point dataset - one point for every citizen, that is similarly clustered as incidents dataset (incidents happen to people, so there is a strong link between these two datasets).
I want to compare these two datasets to figure out, if they are similarly
distributed. I want to know, if there are places, where there are more
incidents, compared to population. In other words, I want to use population dataset to explain intensity and then figure out if the incident dataset corresponds to that intensity. The assumption is, that incidents should appear randomly regarding to population.
I want to get a plot of the region with information where there are more or less incidents than expected if the incidents were randomly happening to people.
How would you do it with R?
Should I use Kest or Kinhom to calculate K function?
I read the description, but still don't understand what is a basic difference
between them.
I tried using Kcross, but as I figured out, one of two datasets used
should be CSR - completely spatial random.
I also found Kcross.inhom, should I use that one for my data?
How can I get a plot (image) of incident deviations regarding population?
I hope I asked clearly.
Thank you for your time to read my question and
even more thanks if you can answer any of my questions.
Best regards!
Jernej
I do not have time to answer all your questions in full, but here are some pointers.
DISCLAIMER: I am a coauthor of the spatstat package and the book Spatial Point Patterns: Methodology and Applications with R so I have a preference for using these (and I genuinely believe these are the best tools for your problem).
Conceptual issue: How big is your study region and does it make sense to treat the points as distributed everywhere in the region or are they confined to be on the road network?
For now I will assume we can assume they are distributed anywhere.
A simple approach would be to estimate the population density using density.ppp and then fit a Poisson model to the incidents with the population density as the intensity using ppm. This would probably be a reasonable null model and if that fits the data well you can basically say that incidents happen "completely at random in space when controlling for the uneven population density". More info density.ppp and ppm are in chapters 6 and 9 of 1, respectively, and of course in the spatstat help files.
If you use summary statistics like the K/L/G/F/J-functions you should always use the inhom versions to take the population density into account. This is covered in chapter 7 of 1.
Also it could probably be interesting to see the relative risk (relrisk) if you combine all your points in to a marked point pattern with two types (background and incidents). See chapter 14 of 1.
Unfortunately, only chapters 3, 7 and 9 of 1 are availble as free to download sample chapters, but I hope you have access to it at your library or have the option of buying it.

How to compute distances along a network in shapefile? in R

I have a river network in a shapefile (class: "SpatialLinesDataFrame"), with some points on it (see picture below).
I would like to compute the distances between points, but along the rivers. I have been searching a lot and I am not able to find any function that allows directly that.
The closest thing I have found is the function "networkdistance" in the package "secrlinear", however I don't manage to transform my shapefile into the format required to use the function (a "linearmask" object).
Any help with this would be extremely appreciated.
Thanks in advance,
Tina.
I know this is an old thread, but just in case someone runs across this in the future: I just released an R package (riverdist) that deals with this issue, and also provides some tools for network editing and data summaries & visualization. It was written with fisheries work in mind, but could probably be applied to what you're working on, or at least that's the hope!
https://cran.r-project.org/web/packages/riverdist/vignettes/riverdist_vignette.html
Sorry this wasn't more timely -
I think we resolved this problem offline: the geographic coordinates (lat/long) of the shapefile needed to be projected before they could be used in secrlinear. That package approximates the linear network and uses igraph functions for distances.

Resources