
R version 4.0.3 (2020-10-10) -- "Bunny-Wunnies Freak Out"
Copyright (C) 2020 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> suppressPackageStartupMessages(library(rgdal))
> load(system.file("etc/test_dfs.RData", package="rgdal"))
> load(system.file("etc/obj_with_comments.RData", package="rgdal"))
> Ps1_nc <- Ps1
> comment(Ps1_nc) <- NULL
> comment(slot(Ps1_nc, "polygons")[[1]]) <- NULL
> drivers <- c("GeoJSON", "ESRI Shapefile")
> drivers <- drivers[drivers %in% ogrDrivers()$name]
> tfbase <- tempfile()
> for (driver in drivers) {
+ tf <- paste0(tfbase, driver, "P", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(P, data=df9), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("P with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" comment", isTRUE(all.equal(sapply(slot(rP, "polygons"), comment), sapply(slot(P, "polygons"), comment))), "\n")
+ cat(" coords", isTRUE(all.equal(lapply(slot(P, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(P, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ tf <- paste0(tfbase, driver, "Ph", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(Ph, data=df9), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("Ph with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" comment", isTRUE(all.equal(sapply(slot(rP, "polygons"), comment), sapply(slot(Ph, "polygons"), comment))), "\n")
+ cat(" coords", isTRUE(all.equal(lapply(slot(Ph, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(Ph, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ tf <- paste0(tfbase, driver, "Phs", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(Phs, data=df9), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("Phs with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" comment", isTRUE(all.equal(sapply(slot(rP, "polygons"), comment), sapply(slot(Phs, "polygons"), comment))), "\n")
+ cat(" coords", isTRUE(all.equal(lapply(slot(Phs, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(Phs, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ tf <- paste0(tfbase, driver, "MP", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(MP, data=df3), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("MP with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" comment", isTRUE(all.equal(sapply(slot(rP, "polygons"), comment), sapply(slot(MP, "polygons"), comment))), "\n")
+ cat(" coords", isTRUE(all.equal(lapply(slot(MP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(MP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ tf <- paste0(tfbase, driver, "MPh", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(MPh, data=df3), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("MPh with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" comment", isTRUE(all.equal(sapply(slot(rP, "polygons"), comment), sapply(slot(MPh, "polygons"), comment))), "\n")
+ cat(" coords", isTRUE(all.equal(lapply(slot(MPh, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(MPh, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ load(system.file("etc/obj_without_comments.RData", package="rgdal"))
+ if (requireNamespace("rgeos", quietly=TRUE)) {
+ tf <- paste0(tfbase, driver, "aP", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(aP, data=df9), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("aP with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" coords", isTRUE(all.equal(lapply(slot(aP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(aP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ }
+ if (requireNamespace("rgeos", quietly=TRUE)) {
+ tf <- paste0(tfbase, driver, "aPh", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(aPh, data=df9), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("aPh with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" coords", isTRUE(all.equal(lapply(slot(aPh, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(aPh, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ }
+ if (requireNamespace("rgeos", quietly=TRUE)) {
+ tf <- paste0(tfbase, driver, "aMP", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(aMP, data=df3), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("aMP with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" coords", isTRUE(all.equal(lapply(slot(aMP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(aMP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ }
+ if (requireNamespace("rgeos", quietly=TRUE)) {
+ tf <- paste0(tfbase, driver, "aMPh", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(aMPh, data=df3), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("aMPh with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" coords", isTRUE(all.equal(lapply(slot(aMPh, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(aMPh, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ }
+ if (requireNamespace("rgeos", quietly=TRUE)) {
+ tf <- paste0(tfbase, driver, "Ps1", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(Ps1, data=df1), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("Ps1 with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" coords", isTRUE(all.equal(lapply(slot(Ps1, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(Ps1, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ }
+ if (requireNamespace("rgeos", quietly=TRUE)) {
+ tf <- paste0(tfbase, driver, "Ps1_nc", sep=".")
+ writeOGR(SpatialPolygonsDataFrame(Ps1_nc, data=df1), tf, "GeoJSON",
+  driver=driver, verbose=TRUE)
+ #rP <- as(readOGR(tf, "GeoJSON", verbose=FALSE), "SpatialPolygons")
+ rP <- as(readOGR(tf, verbose=FALSE), "SpatialPolygons")
+ cat("Ps1_nc with driver:", driver, "\n")
+ unlink(paste(tf, "*", sep=""), recursive=driver == "ESRI Shapefile")
+ cat(" coords", isTRUE(all.equal(lapply(slot(Ps1, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "coords")), check.attributes=FALSE)), "\n")
+ cat(" holes", isTRUE(all.equal(lapply(slot(Ps1, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), lapply(slot(rP, "polygons"), function(x) lapply(slot(x, "Polygons"), slot, "hole")), check.attributes=FALSE)), "\n")
+ }
+ }
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
P with driver: GeoJSON 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
Ph with driver: GeoJSON 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
Phs with driver: GeoJSON 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 3 wkbMultiPolygon objects
MP with driver: GeoJSON 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 3 wkbMultiPolygon objects
MPh with driver: GeoJSON 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
aP with driver: GeoJSON 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
aPh with driver: GeoJSON 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 3 wkbMultiPolygon objects
aMP with driver: GeoJSON 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 3 wkbMultiPolygon objects
aMPh with driver: GeoJSON 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 1 wkbMultiPolygon objects
Ps1 with driver: GeoJSON 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 1 wkbMultiPolygon objects
Ps1_nc with driver: GeoJSON 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
P with driver: ESRI Shapefile 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
Ph with driver: ESRI Shapefile 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
Phs with driver: ESRI Shapefile 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 3 wkbMultiPolygon objects
MP with driver: ESRI Shapefile 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 3 wkbMultiPolygon objects
MPh with driver: ESRI Shapefile 
 comment TRUE 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
aP with driver: ESRI Shapefile 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Writing 9 wkbPolygon objects
aPh with driver: ESRI Shapefile 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 3 wkbMultiPolygon objects
aMP with driver: ESRI Shapefile 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 3 wkbMultiPolygon objects
aMPh with driver: ESRI Shapefile 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 1 wkbMultiPolygon objects
Ps1 with driver: ESRI Shapefile 
 coords TRUE 
 holes TRUE 
Object initially classed as: wkbPolygon
SFS comments in Polygons objects
Object reclassed as: wkbMultiPolygon
Writing 1 wkbMultiPolygon objects
Ps1_nc with driver: ESRI Shapefile 
 coords TRUE 
 holes TRUE 
> 
> proc.time()
   user  system elapsed 
  3.956   0.066   4.418 
