[R-sig-Geo] Minor rgdal tip: Use geometry column name to access PostGIS inherited tables

Lee Hachadoorian Lee.Hachadoorian+L at gmail.com
Wed Jan 1 21:16:27 CET 2014


I was using rgdal to load a PostGIS table which is a child table in a 
partitioning scheme. (Common setup, see e.g. §3.1.3 in PostGIS in 
Action.) I kept getting the message "Layer not found". It turns out that 
in this case you can't use the table name as the layer name, you have to 
use "table_name(geometry_column_name)".

Perhaps this is already widely known, but it is difficult to Google and 
behaves differently from OGR. Even though both ogrinfo (the GDAL/OGR 
utility) and ogrListLayers (the R function) will find child tables and 
list them in the "table_name(geometry_column_name)" form, ogrinfo and 
ogr2ogr support accessing the layer just using "table_name", as long as 
that is the single geometry column in the table. ogrInfo (the R 
function) and readOGR require appending the geometry column name.

Best,
--Lee

-- 
Lee Hachadoorian
Assistant Professor in Geography, Dartmouth College
http://geospatial.commons.gc.cuny.edu
http://freecity.commons.gc.cuny.edu



More information about the R-sig-Geo mailing list