Diff to HTML by rtfpessoa

Files changed (1) show
{orig → migrated}/dismap_mod.R RENAMED
@@ -4,14 +4,15 @@
4
4
  ###################################################
5
5
  ### code chunk number 7: dismap.Rnw:183-191
6
6
  ###################################################
7
- library(maptools)
7
+ library(sp)
8
+ library(sf)
8
9
  library(spdep)
9
10
  nc_file <- system.file("shapes/sids.shp", package="spData")[1]
10
- llCRS <- CRS("+proj=longlat +datum=NAD27")
11
- nc <- readShapePoly(nc_file, ID="FIPSNO", proj4string=llCRS)
12
- rn <- sapply(slot(nc, "polygons"), function(x) slot(x, "ID"))
11
+ nc <- as(st_read(nc_file), "Spatial")
12
+ row.names(nc) <- as.character(nc$FIPSNO)
13
+ slot(nc, "proj4string") <- as(st_crs("EPSG:4267"), "CRS")
13
14
  gal_file <- system.file("weights/ncCR85.gal", package="spData")[1]
14
- ncCR85 <- read.gal(gal_file, region.id = rn)
15
+ ncCR85 <- read.gal(gal_file, region.id = row.names(nc))
15
16
 
16
17
 
17
18
  ###################################################
@@ -453,15 +454,12 @@
453
454
  ###################################################
454
455
  sidsgam <- opgam(data=as(nc, "data.frame"), radius=30, step=10, alpha=.002)
455
456
  gampoints <- SpatialPoints(sidsgam[,c("x", "y")]*1000,
456
- CRS("+proj=utm +zone=18 +datum=NAD27"))
457
+ as(st_crs("EPSG:4267"), "CRS"))
457
458
 
458
459
 
459
460
  ###################################################
460
461
  ### code chunk number 85: dismap.Rnw:2539-2543
461
462
  ###################################################
462
- library(rgdal)
463
- ll <- CRS("+proj=longlat +datum=NAD27")
464
- gampoints <- spTransform(gampoints, ll)
465
463
  gam.layout <- list("sp.points", gampoints)
466
464
 
467
465
 
@@ -586,4 +584,9 @@
586
584
  print(spplot(nmf, c("SPBAYESX"), at=ats, col.regions=cols(length(ats)-1),
587
585
  col="grey", sp.layout=spl, main="Spatial effects"))
588
586
 
587
+ (sI <- sessionInfo()) # check: no sp?
588
+
589
+ "rgdal" %in% c(names(sI$otherPkgs), names(sI$loadedOnly))
590
+ "rgeos" %in% c(names(sI$otherPkgs), names(sI$loadedOnly))
591
+ "maptools" %in% c(names(sI$otherPkgs), names(sI$loadedOnly))
589
592