Spatial

Assign rows to a group based on spatial neighborhood and temporal criteria in R

喜欢而已 提交于 2019-12-07 20:16:50
问题 I have an issue that I just cannot seem to sort out. I have a dataset that was derived from a raster in arcgis. The dataset represents every fire occurrence during a 10-year period. Some raster cells had multiple fires within that time period (and, thus, will have multiple rows in my dataset) and some raster cells will not have had any fire (and, thus, will not be represented in my dataset). So, each row in the dataset has a column number (sequential integer) and a row number assigned to it

Drawing equidistant points from the sides of a polygon

喜你入骨 提交于 2019-12-07 15:17:16
问题 I am drawing a polygon with the following vertices x y -0.02208709 -0.039161304 0.01184081 -0.020268029 0.04578401 -0.001351904 0.02210236 0.039176396 -0.01185226 0.020252146 -0.04578784 0.001352696 using the following code plot(x,y) polygon(x,y) points(mean(x),mean(y),col="red") Now I want to plot 50 equally-spaced points along the sides of polygon. Any suggestion how to do it? 回答1: You can do this with spsample from the sp package. First we'll load the library and read in your vertices.

directional testing of spatial clustering by distance from source

試著忘記壹切 提交于 2019-12-07 14:56:04
问题 I have a spatial dataset of animal locations, as (x,y) points around a source (circular pattern with 5 km radius). I need to test whether the points are clustered (or repulsed) around the source relative to farther from the source, while accounting for directionality. Things I tried: checked out nearest neighbour and Ripley's K - could not figure out how to incorporate distance from source or directionality (plus, it looks like Ripley's is expecting a rectangular window, whereas mine is

Dapper Spatial Geography Type

余生长醉 提交于 2019-12-07 14:08:59
问题 I'm cooking up some spatial examples and have decided to give Dapper a go, although EF has spatial support, and I'm loving having control over my SQL again (Thanks Sam & Marc). However, I need to be able to have POCO's that support the DbGeography class. For example : public class BuriedTreasure { public int PirateId { get; set; } public DbGeography MarksTheSpot { get; set; } } My Google foo has been letting me down and the closest match I can find is this question, though it only caters for

Error in predicting raster with randomForest, Caret, and factor variables

空扰寡人 提交于 2019-12-07 13:13:20
问题 I am trying to predict a raster layer with randomForest and the caret package, but fail when I introduce factor variables. Without factors, everything works fine, but as soon as I bring a factor in, I get the error: Error in predict.randomForest(modelFit, newdata) : Type of predictors in new data do not match that of the training data. I have created some sample code below that walks through he process. I present it in a few steps for transparency and to provide a working example. (To skip

spatial data / compute metrics on neighbors in R

谁说我不能喝 提交于 2019-12-07 11:58:50
问题 I have the 2D spatial data in the form (xBin, yBin, value). e.g.: DT = data.table(x=c(rep(1,3),rep(2,3),rep(3,3)),y=rep(c(1,2,3),3),value=100*c(1:9)) For each bin I want to compute the sum of variable "value" over all neighboring bins. A bin is considered a neighbor if both of its indices - x and y are within one unit from the current bin e.g. for x=2, y=2, I want to compute valueNeighbors(x=2,y=2) = value(x=1,y=1)+value(1,2)+value(1,3) +value(2,1)+value(2,3) +value(3,1)+value(3,2)+value(3,3)

Mysql: ST_Contains with borders to detect if multipolygon contains point

穿精又带淫゛_ 提交于 2019-12-07 10:55:02
问题 I use mysql spatial functions. I have to understand if points lies withing multipolygon. Initially I used MBRContains but it works in a strange way, so I faced the following error: Mysql function MBRContains is not accurate My next step was switching to the functions ST_Contains . But I found out that if I use polygon(from multipolygon) vertex as argument - function returns false but I want to unclude all multipolygon borders. P.S. I found that where are function: ST_Touches(g1, g2) Two

Computing p.values in spatial econometric models: why are there inconsistencies between summary() and texreg()?

痴心易碎 提交于 2019-12-07 09:25:25
问题 I am estimating some spatial econometric models that contain both a spatial autoregressive term rho and a spatial error term lambda. In attempting to communicate my results I was using the texreg package, which accepts the sacsarlm models I am working with. I noticed, however, that texreg is printing p-values for the rho and lambda parameters that are identical. Texreg appears to be returning the p-value found in the model@LR1$p.value slot of the model object. The parameters rho and lambda

create hexagonal cells grid using lat/lon coordinates

那年仲夏 提交于 2019-12-07 08:21:51
问题 I would like to create a spatial grid with hexagonal cells using WGS84 coordinates (ie cells defined by 2 coordinates X=Latitude and Y=Longitude) So, this is what I was thinkin about : library(ggplot2);library(hexbin) X<-seq(-10,20,by=0.1) # create coordinates vectors X and Y Y<-seq(35,65,by=0.1) z<-rnorm(301,0.5,1) df<-as.data.frame(cbind(X,Y,z)) # create data frame with a z value for each cells (X,Y) pl<-ggplot2(data=mat,aes(x=X,y=Y,z=z))+stat_summury_hex(fun=function(x) sum(x)) plot(pl)

How to add lines of longitude and latitude on a map using ggplot2?

风格不统一 提交于 2019-12-07 08:17:15
问题 I am now plotting the map of Canada using ggplot2 . Because the default projection method is "aea"(Albers Equal Area), so the longitude and latitude are straight lines on the map. I wonder how I can display the longitude and latitude in the form of "110W, 100W, 90W" and "50N, 60N, 70N" on the map. They should be curves. Thanks a lot. The arcgis shapfile is downloaded from https://www.arcgis.com/home/item.html?id=dcbcdf86939548af81efbd2d732336db library(ggplot2) library(rgdal) countries<