[R-sig-Geo] memory allocation problem with small PostGIS-layer in readOGR()

Tom Gottfried tom.gottfried at wzw.tum.de
Tue Apr 12 16:54:30 CEST 2011


Hi Roger,

Am 12.04.2011 15:39, schrieb Roger Bivand:
> On Tue, 12 Apr 2011, Tom Gottfried wrote:
>
>> Dear list,
>>
>> since some upgrades of R-packages and GDAL (I'm sorry I can not exactly reproduce which) I got
>> memory allocation problems reading a relatively small PostGIS layer (type POLYGON with 21 polygons):
>>
>>> library(rgdal)
>> Loading required package: sp
>> Geospatial Data Abstraction Library extensions to R successfully loaded
>> Loaded GDAL runtime: GDAL 1.8.0, released 2011/01/12
>> Path to GDAL shared files:
>> Loaded PROJ.4 runtime: Rel. 4.7.1, 23 September 2009
>> Path to PROJ.4 shared files: (autodetected)
>>
>>> readOGR("PG:dbname=myDB", "layer(the_geom)")
>> Error: cannot allocate vector of size 13.9 Gb
>
> Since this has to be debugged on your system, please first use ogr2ogr to convert it to another
> format - this will test the PostGIS driver. You are on Linux, so should have ogr2ogr installed. If
> (unlikely) there are problems with the driver, you may need to check how PostgreSQL, PostGIS, and
> their dependencies were installed, then GDAL and its dependencies.

converting to ESRI-Shapefile with ogr2ogr worked.

> Otherwise, this must be in readOGR() somewhere, so do debug(readOGR) and run the same command
> step-by-step. Start by doing debug(ogrInfo) and ogrInfo("PG:dbname=myDB", "layer(the_geom)"),
> because unless you have set verbose=FALSE and not reported it (unlikely), ogrInfo() called within
> readOGR() should have reported the DSN and layer names, the driver name, etc., before the error if
> the error occurred later Also look at traceback() after the error before trying debug() - this feels
> like ogrInfo() having trouble.

> ogrInfo("PG:dbname=gs_gk_workspace", "weidengs(the_geom)")
Error: cannot allocate vector of size 13.9 Gb
> traceback()
2: .Call("ogrInfo", as.character(dsn), as.character(layer), PACKAGE = "rgdal")
1: ogrInfo("PG:dbname=gs_gk_workspace", "weidengs(the_geom)")

Now entering C-level (?). I think I first have to read this
http://cran.r-project.org/doc/manuals/R-exts.html#Debugging
before continuing.

Thanks!
Tom

>
> Roger
>
>>
>>> sessionInfo()
>> R version 2.12.2 Patched (2011-03-18 r55401)
>> Platform: x86_64-unknown-linux-gnu (64-bit)
>>
>> locale:
>> [1] LC_CTYPE=en_US LC_NUMERIC=C LC_TIME=en_US
>> [4] LC_COLLATE=en_US LC_MONETARY=C LC_MESSAGES=en_US
>> [7] LC_PAPER=en_US LC_NAME=C LC_ADDRESS=C
>> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats graphics grDevices utils methods base
>>
>> other attached packages:
>> [1] rgdal_0.6-33 sp_0.9-79 RODBC_1.3-2
>>
>> loaded via a namespace (and not attached):
>> [1] grid_2.12.2 lattice_0.19-17
>>
>> Any help is appreciated!
>> Thanks,
>> Tom
>>
>>
>

-- 
Technische Universität München
Department für Pflanzenwissenschaften
Lehrstuhl für Grünlandlehre
Alte Akademie 12
85350 Freising / Germany
Phone: ++49 (0)8161 715324
Fax:   ++49 (0)8161 713243
email: tom.gottfried at wzw.tum.de
http://www.wzw.tum.de/gruenland



More information about the R-sig-Geo mailing list