Closed imprompt closed 5 years ago
This works: test <- data.frame(x=0, y=0, a=1) pgInsert(conn, name=c("public", "test_table1"), data.obj=test) pgMakePts(conn, name = c("public", "test_table1"), srid = 4326)
Hi Malcolm,
I'm not able to replicate the issue. Do you see any messages printed in the R console prior to the hang/crash?
Running using Rscript in a terminal gives the following:
Creating new table...
Using writeWKT from rgeos package...
*** caught segfault ***
address 0x1, cause 'memory not mapped'
Traceback:
1: rgeos::writeWKT(data.obj, byid = TRUE)
2: pgInsertizeGeom(data.obj, geom, create.table, force.match, conn, new.id, row.names, alter.names, partial.match, df.mode, geog)
3: doTryCatch(return(expr), name, parentenv, handler)
4: tryCatchOne(expr, names, parentenv, handlers[[1L]])
5: tryCatchList(expr, classes, parentenv, handlers)
6: tryCatch(expr, error = function(e) { call <- conditionCall(e) if (!is.null(call)) { if (identical(call[[1L]], quote(doTryCatch))) call <- sys.call(-4L) dcall <- deparse(call)[1L] prefix <- paste("Error in", dcall, ": ") LONG <- 75L sm <- strsplit(conditionMessage(e), "\n")[[1L]] w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w") if (is.na(w)) w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L], type = "b") if (w > LONG) prefix <- paste0(prefix, "\n ") } else prefix <- "Error : " msg <- paste0(prefix, conditionMessage(e), "\n") .Internal(seterrmessage(msg[1L])) if (!silent && isTRUE(getOption("show.error.messages"))) { cat(msg, file = outFile) .Internal(printDeferredWarnings()) } invisible(structure(msg, class = "try-error", condition = e))})
7: try(pgi <- pgInsertizeGeom(data.obj, geom, create.table, force.match, conn, new.id, row.names, alter.names, partial.match, df.mode, geog))
8: pgInsert(conn, name = c("public", "test_table2"), data.obj = test)
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault (core dumped)
Same crash when writing spatial polygons when running:
e <- extent(c(0, 100, 0, 100))
e <- as(e, 'SpatialPolygons')
e <- SpatialPolygonsDataFrame(e, data=data.frame(a=1, b=2))
pgInsert(conn, name=c("public", "test_table3"), data.obj=e)
For points I can use the pgMakePts workaround, but for polygons I can't see a way to add a polygons column after writing a non-geometric data frame.
Could it be an issue with your rgeos
package? Try:
library(rgeos)
test <- data.frame(x=0, y=0, a=1)
coordinates(test) <- ~x + y
writeWKT(test)
[1] "POINT (0.0000000000000000 0.0000000000000000)"
If so you may need to check/re-install your system GEOS package.
Thanks. It looks like regos is the problem, but reinstalling did not fix it. So not a problem with rpostgis. Thanks for your help.
If you install the package wkb
, that would allow for limited use of pgInsert
(e.g. for single-part points and polygons). But for all other geometry types, it needs the rgeos
package and you'd still get the error. Good luck!
Working after building the latest system geos from source. Thanks for the package.
Good to see that the problem is solved! @imprompt, for the record, could your give your previous and current versions of geos
here (I understand the problem was not rgeos
but the geos
library directly)? Thanks!
yum install geos: installed v3.4.1, which caused problem installed v3.7.0 from source to fix.
Thanks!
I have RStudio running R v3.5.0 with rpostgis 1.4.1 running under CentOS 7.5 connecting to a postgres DB:
Problem: pgInsert() hangs with no feedback when using spatial data.
What works: test <- data.frame(x=0, y=0, a=1) pgInsert(conn, name=c("public", "test_table1"), data.obj=test)
What doesn't work (hangs or crashes R): coordinates(test) <- ~x + y pgInsert(conn, name=c("public", "test_table2"), data.obj=test)
The database has the postgis extension What would be the best way to diagnose the problem?