Skip to main content
21 votes

Clustering spatial data in R?

Here is a solution based on Find clusters of points based distance rule, but using the distm function from the geosphere package: library(sp) library(rgdal) library(geosphere) # example data from ...
ssanch's user avatar
  • 341
20 votes

Joining polygons in R

Here is a solution using the sf package: library(tidycensus) library(dplyr) library(sf) library(ggplot2) # get data from tindycensus for demonstration (note you need an API key, folow instructions ...
sebdalgarno's user avatar
  • 1,733
20 votes

Statistical tests for spatial line patterns?

This is a difficult question as there just have not been many, if any, spatial process statistics developed for line features. Without seriously digging into equations and code, point process ...
Jeffrey Evans's user avatar
14 votes

Statistical tests for spatial line patterns?

You might want to look into Fréchet distance. I only recently found out about this after a recent question looking for a python implementation. This is a metric for finding spatial similarity of ...
Steven Kay's user avatar
  • 20.5k
10 votes
Accepted

Calculating field AVG from B layer 3 nearest points to each A layer point

Sorry, I can not provide an answer for QGIS 3.4, but for 3.8+, in case you have a chance to update. The tool you need for this is called join attributes by nearest, which was introduced with 3.8. For ...
MrXsquared's user avatar
  • 35.2k
9 votes
Accepted

Getis-Ord Gi* (arcgis 'hotspot analysis') with python?

Check out PySAL: The Python Spatial Analysis Library https://pysal.readthedocs.io/en/latest/
Charlie Parr's user avatar
  • 1,966
8 votes
Accepted

Dividing Polygon into parts which have equal area using R

As I needed something similar, I wrote a small function for R following the steps of this question on "Splitting polygon into equal area polygons using QGIS" I hope this helps somebody, even ...
Geoline's user avatar
  • 96
8 votes
Accepted

Calculating statistics of points within polygons of the same criterion in QGIS

Great question. Welcome to the weird and wonderful world of the aggregate() function. It's very powerful but tricky to learn, I've used it a lot and still have to read the documentation carefully most ...
TeddyTedTed's user avatar
  • 6,190
7 votes

Polygon Shape Similarity using PostGIS?

Have a look at the PostGIS function - ST_HausdorffDistance http://postgis.net/docs/ST_HausdorffDistance.html This is a measure of how similar or dissimilar two shapes are.
mixedbredie's user avatar
  • 1,870
7 votes

Distance between GPS travel route and country border

You can do this using QGIS and OpenStreetMap data, so OpenSource/Open data and free to use. The process includes several steps. Using the online QGIS documentation can help you for the steps. When you ...
Babel's user avatar
  • 73.8k
6 votes

Geometry type issue with st_intersection() between polylines and polygons

The ST_Intersection can produce different geometry-types in one go (image two lines intersecting at one point, returning a point) and likely therefore you are receiving linestrings and ...
tilt's user avatar
  • 3,279
6 votes
Accepted

Optimally thin or subset sample points

There is a function pp.subsample in the spatialEco package that will subset your data using a spatial intensity function. This will, in effect, thin your data to a defined n, using the expected ...
Jeffrey Evans's user avatar
6 votes

Computing annual spatial (zonal) statistics of a NetCDF file for polygons in shape-file

I used this code to get want I wanted: # import packages import xarray as xr import rasterio as rio import geopandas as gpd import rasterstats as rstats # load and read shp-file with geopandas ...
Jannis's user avatar
  • 99
6 votes

Calculating buffer distance for different groups of parallel lines in QGIS

What you want to achieve is basically a kind of "clustering" of lines: grouping lines that are close together. You need one manual decision, a maximum distance up until which lines should be ...
Babel's user avatar
  • 73.8k
6 votes
Accepted

Interpolation with 10 data points

Both methods are "appropriate". IDW basically says "half way between a point valued 6 and a point valued 8 the value is going to be 7", but extended to the distance to multiple ...
Spacedman's user avatar
  • 65.5k
6 votes
Accepted

Computing grid cell statistics using LiDAR point cloud in QGIS

With QGIS 3.32 (see the changelog) you have some native algorithm in the Processing Toolbox (Ctrl+Alt+T), there you can export the point cloud into a raster format, DEM for example and make statistics ...
eurojam's user avatar
  • 11.6k
5 votes
Accepted

Spatial outliers detection in R?

We can run through some straight-forward approaches starting with looking at the modified z-score on the variable of interest (a-spatial) then move to calculating the local z-score and variance within ...
Jeffrey Evans's user avatar
5 votes

Statistical tests for spatial line patterns?

I am suggesting to use approach similar to one explained here. ALGORITHM and naming: a) Name line layer NODES. Compute bearings b) spatially join to itself (one to many) using distance tolerance. ...
FelixIP's user avatar
  • 23.2k
5 votes

Statistical tests for spatial line patterns?

There is in my eyes a problem with the definition of the lines, one that will determine what approaches to use ( some of those mentioned above). If these are OD pairs, and the geometry does not play a ...
MartinT's user avatar
  • 886
5 votes

Access to attribute in rasterlayer in R

You can access this table via levels: > levels(r) [[1]] ID OID Value Count LC_Code Land_Cover Area_Ha 1 0 0 0 25615512 255 No Data 2305400.00 2 1 1 ...
Spacedman's user avatar
  • 65.5k
5 votes

Choosing spatial statistical tool in ArcGIS Desktop?

Spatial Statistics Resources or https://spatialstats.github.io/. This page made in 2010 in the esri blog,But esri update it when a new resource availabled. The ESRI Guide to GIS Analysis, Volume 2. ...
BBG_GIS's user avatar
  • 5,825
5 votes
Accepted

Calculating Moran's I on large point dataframe in R

I had this same problem. I created an R package that calculates the distance matrix on the fly, so it takes much less memory to calculate Moran's I. Its also quite fast. You can find it at github....
Amadou Kone's user avatar
5 votes
Accepted

How to obtain elevation differences between point and raster cell in R

Outline solution: Install the FNN package from CRAN. Use nni = FNN::knnx.index(coordinates(s), coordinates(r), k=1) to get the index in s of the nearest neighbour for each cell coordinate to the ...
Spacedman's user avatar
  • 65.5k
5 votes

Do I necessarily need coordinates for spatial prediction?

The spatial prediction aims at predicting a variable where it has not been observed. Therefore you need to know the coordinates of the location where you make the prediction, even if the coordinates ...
radouxju's user avatar
  • 49.8k
5 votes

Distance between GPS travel route and country border

With QGIS you can use the following processing tools: GPS route as input: Densify by interval (add vertices every 1 m) Extract vertices (create a point layer from the vertices) With country border ...
Bera's user avatar
  • 76.2k
5 votes

Determining who and why certain data was mapped in OpenStreetMap

OSM is a collaborative geographic database, fed by the goodwill of volunteer contributors. Therefore there are no real input specifications (as there might be in a reference database), just guidlines, ...
Atm's user avatar
  • 1,557
4 votes

Interpreting semivariogram with high nugget effect?

I am wondering if someone can explain why the nugget seems so high? Does this mean that even at similar locations, there is still a relatively high degree of difference? Yes, a high nugget effect (...
Andre Silva's user avatar
  • 10.3k
4 votes

Which statistical methods to compare the spatial distribution of two different variables in two raster maps?

tl;dr: pick a segregation measure from the seg package, probably the isp() function as an implementation of White (1983). I'd recommend using an entropy segregation measure. Probably you need some ...
Ma Ba's user avatar
  • 71
4 votes
Accepted

Gstat krige() error: Covariance matrix singular at location [917300,3.6109e+06,0]: skipping

This is caused by the matrix library used by gstat. Historically (gstat was released as open source code in 1997) it used the LDLfactor routine in the meschach library. Around 6 months ago I factored ...
Edzer Pebesma's user avatar
4 votes

Exponential function variogram sill values

Yes, this is correct. When you print the model by typing model.vari you'll see sill values, split up in a nugget component (the offset) and the exponential component. The sum of these two is usually ...
Edzer Pebesma's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible