Cidree / rpostgis

rpostgis: R Interface to a 'PostGIS' Database
http://cidree.github.io/rpostgis/
77 stars 14 forks source link

Error in pgCheckGeom(conn, name, geom) #11

Closed shanakap closed 5 years ago

shanakap commented 6 years ago

Hi, Thanks for creating this package which looks very useful. Unfortunately I have got this error trying to use this package,

VOA_ValsLond <- pgGetGeom(con, "VOA_Vals_Lsoa_Lond_g",geom = "geom")
Error in pgCheckGeom(conn, name, geom) : 
  Table/view 'public.VOA_Vals_Lsoa_Lond_g' is not listed in geometry_columns or geography_columns.

I am sure the geom column is fine because I have linked the postgis to QGIS and it maps the table without any issues. Any suggestions to correct this?

dnbucklin commented 6 years ago

Hi @shanakap ,

Without knowing any additional information, it would appear that your table is in a different schema than (public)? If that is the case, you need to provide (schema, table) to name , e.g. name = c("schema_name", "VOA_Vals_Lsoa_Lond_g") )

You can list all tables in the database that you can import using pgListGeom(con).

David

shanakap commented 6 years ago

Hi @dnbucklin,

Thanks for the reply. I checked into that and this is what i get by using pgListGeom(con);

schema_name    table_name             geom_column     geometry_type           type
  public      voa_vals_lsoa_lond_g        geom           MULTIPOLYGON         GEOMETRY

Is there something do with the MULTIPOLYGON type?

dnbucklin commented 6 years ago

It appears the table name is all-lowercase; table/schema names in Postgres (and rpostgis) are case-sensitive, so you will need to provide the name exactly as it is stored in the database: (name = "voa_vals_lsoa_lond_g").

shanakap commented 6 years ago

Brilliant!! You are correct!

Just a suggestion : may be when running pgGetGeom(), check if the name exists using pgListGeom() to provide a more meaningful description in the error statement.

Any thanks for this package. Cheers.