Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > library(gstat)
- > library(readxl)
- > library(sp)
- > library(rgdal)
- data <- read.csv("C:/Users/sbs/Desktop/Study/RA/Accident analysis/New folder/Iowa total crashes 2013_cleaned.csv", header = TRUE, sep =",")
- plot(data)
- attach(data)
- > class(data)
- [1] "data.frame"
- > coordinates(data) <- ~XCOORD+YCOORD
- > class(data)
- [1] "SpatialPointsDataFrame"
- attr(,"package")
- [1] "sp"
- > variogram1<- variogram(FATALITIES~1, data)
- > plot(variogram1)
- > fit.variogram1<- fit.variogram(variogram1, vgm(0.002, "Exp"))
- > plot(variogram1, fit.variogram1, cutoff = 300000, pch =20, col ="red")
- > fit.variogram1
- model psill range
- 1 Exp 0.007896732 13527.15
- > x<- readOGR("H:/p/Road_Network_Info/road_fish_lable.shp")
- OGR data source with driver: ESRI Shapefile
- Source: "H:pRoad_Network_Inforoad_fish_lable.shp", layer: "road_fish_lable"
- with 5006 features
- It has 1 fields
- Integer64 fields read as strings: Id
- > plot(x)
- > class(x)
- [1] "SpatialPointsDataFrame"
- attr(,"package")
- [1] "sp"
- > krige(FATALITIES~1, data, x, fit.variogram1)
- [1] NA
- [1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
- Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim, :
- var1 : data item in gstat object and newdata have different coordinate reference systems
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement