SHARE
TWEET

Untitled

a guest Jun 20th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. > library(gstat)
  2. > library(readxl)
  3. > library(sp)
  4. > library(rgdal)
  5.      
  6. data <- read.csv("C:/Users/sbs/Desktop/Study/RA/Accident analysis/New folder/Iowa total crashes 2013_cleaned.csv", header = TRUE, sep =",")
  7. plot(data)
  8. attach(data)
  9.  
  10. > class(data)
  11.  
  12. [1] "data.frame"
  13.  
  14. > coordinates(data) <- ~XCOORD+YCOORD
  15.  
  16. > class(data)
  17.  
  18. [1] "SpatialPointsDataFrame"
  19. attr(,"package")
  20. [1] "sp"
  21.  
  22. > variogram1<- variogram(FATALITIES~1, data)
  23. > plot(variogram1)
  24.  
  25. > fit.variogram1<- fit.variogram(variogram1, vgm(0.002, "Exp"))
  26.  
  27. > plot(variogram1, fit.variogram1, cutoff = 300000, pch =20, col ="red")
  28.  
  29. > fit.variogram1
  30.  
  31.   model       psill    range
  32. 1   Exp 0.007896732 13527.15
  33.      
  34. > x<- readOGR("H:/p/Road_Network_Info/road_fish_lable.shp")
  35.  
  36. OGR data source with driver: ESRI Shapefile
  37. Source: "H:pRoad_Network_Inforoad_fish_lable.shp", layer: "road_fish_lable"
  38. with 5006 features
  39. It has 1 fields
  40. Integer64 fields read as strings:  Id
  41.  
  42. > plot(x)
  43.  
  44. > class(x)
  45.  
  46. [1] "SpatialPointsDataFrame"
  47. attr(,"package")
  48. [1] "sp"
  49.      
  50. > krige(FATALITIES~1, data, x, fit.variogram1)
  51.  
  52. [1] NA
  53. [1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
  54. Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim,  :
  55.   var1 : data item in gstat object and newdata have different coordinate reference systems
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top