r-spatial / spdep

Spatial Dependence: Weighting Schemes and Statistics
https://r-spatial.github.io/spdep/
121 stars 26 forks source link

Enhancement: Add depth and grouping function #21

Closed dmaupin12 closed 5 years ago

dmaupin12 commented 5 years ago

Would it be possible to add a depth variable used to calculate distances between two points? I research the energy industry (oil and gas) where depth is a key variable in measuring the distances between wells. In addition to depth, I would like to group wells by a variable, in my case formation, similar to the group_by command in dplyr. I've attached a file with a small sample of data.

The code below is what i'm currently using.

coordinates(wells)<- ~LonWGS84+LatWGS84 wellsnb<-neighborsDataFrame(dnearneigh(coordinates(wells), d1 = 0, d2 = .2,longlat=T,row.names = wells$UWI10))

[EXAMPLE.xlsx](https://github.com/r-spatial/spdep/files/2577605/EXAMPLE.

Thanks!

David

rsbivand commented 5 years ago

Please no excel files, best GPKG (with 3D points and certainly not unprojected), if not CSV. Note that I am uncertain whether you actually mean to treat depth as a z-coordinate (obviously not longlat), or as an attribute to a well head. I do not see a worked-our use case here. nb and listw objects have specific purposes, but I don't see any reference here to a workflow including modelling a spatially structured random effect. Please forget grouped_by, it is just a passing dialect for tapply and aggregate, and lists should never be coerced to data.frame unless there is a clear motivation. I really do not see how you conceptualise a 3D spatial process in lattice terms (2D + time is easier). Vertical depth has no metric (metres?) and can only be taken as an attribute to the well-head point.

If you work in industry, it is also usual to provide an affiliation (not here nor in your earlier email). If you work in industry, maybe you should get some local help to construct a meaningful example workflow in which a 3D lattice dependency structure is needed. I don't see anything in the literature, but do see plenty of 3D geostatistics and point processes (especially the 3D relative position of points in bioinformatics, soil science and ecology). I think you have neighborsDataFrame from expp which is in ornithology, so not much to do with your case at all. Please provide imput that actually makes sense - 3D neighbours may make sense but need motivating (not your data now), and aggregate/tapply have always been possible (if you drop tidyverse, that is, tidyverse is limiting your ability to express your needs).

rsbivand commented 5 years ago

No use case forthcoming.