[R-sig-Geo] Error in readOGR / ogrInfo

Roger Bivand Roger.Bivand at nhh.no
Thu Oct 21 20:06:36 CEST 2010


On Thu, 21 Oct 2010, Ben Madin wrote:

> G'day all,
>
> I am having a problem with using the rgdal function readOGR, but the error message actually relates to using ogrInfo.
>
>> backgroundmap <- readOGR("PG:dbname=gms user=benmadin password=xdi4frt", "seaplus_countries")
> Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding = input_field_name_encoding) :
>
> 	GDAL Error 1: No field definitions found for 'seaplus_countries', is it a table?
>> ogrInfo("PG:dbname=gms user=benmadin password= xdi4frt", "seaplus_countries", input_field_name_encoding=UTF-8)
> Error in ogrInfo("PG:dbname=gms user=benmadin password= xdi4frt", "seaplus_countries",  :
>
> 	GDAL Error 1: No field definitions found for 'seaplus_countries', is it a table?
>
>
> Yet when I use ogrInfo from the command line it shows me the information :
>
> warrambat:~ benmadin$ ogrinfo "PG:dbname=gms user=benmadin password= xdi4frt"
> INFO: Open of `PG:dbname=gms user=benmadin password= xdi4frt'
>      using driver `PostgreSQL' successful.
>
> rows deleted
>
> 20: public.country (Multi Polygon)
> 21: public.seaplus_countries (Multi Polygon)
> 22: public.worldboundaries (Multi Polygon)
>
> and I can load the layer and display it in QGIS or uDig.
>
> The problem occurs both in the GUI and the command line versions of R.
>
>> sessionInfo()
> R version 2.11.1 Patched (2010-09-30 r53084)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] en_AU.UTF-8/en_AU.UTF-8/C/C/en_AU.UTF-8/en_AU.UTF-8
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] rgdal_0.6-28 sp_0.9-72
>
> loaded via a namespace (and not attached):
> [1] grid_2.11.1     lattice_0.19-13
>
> I have tried this with a number of postgis tables in different databases, and it is not working. I am trying to re-run code that has previously worked fine, but I am on a new computer and using R2.11 and a more recent version of rgdal.
>
> My first question is - what does the error message mean?
>

I don't run PostGIS, so cannot tell, nor OSX. Is the table named as given 
(what does the "public." prefix mean)? Can you use ogrinfo to examine the 
table itself rather than the list of tables? I assume that you know what 
you are doing; PostGIS is not something I know about.

> My second question - why is it occurring in R, but not (apparently) a 
> problem outside of R?

Most likely the OGR drivers in the GDAL shared object used by rgdal are 
not the same as those used by ogrinfo, QGIS, etc., elsewhere. How did you 
install rgdal - as a binary package (from where) or as a source package? 
If the latter, do you have multiple GDAL shared objects on your system?

>
> My third question - am I on the right list?

Yes.

Roger

>
> cheers
>
> Ben
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list