Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # example of reading regular data table from Postgres using RPostgresSQL library
  2. library(RPostgreSQL)
  3. con <- dbConnect(PostgreSQL(), host="localhost", port="5432", user="username", password="password", dbname="db_name")
  4. result <- dbGetQuery(con, statement = "SELECT * FROM table1, table2 WHERE table1.key = table2.key")
  5. head(result)
  6.  
  7. library(rpostgis)
  8. conn <- dbConnect(PostgreSQL(), host="localhost", port="5432", user="postgres", password="postgres", dbname="sp_db")
  9. dbSchema(conn, name = 'sp_db')
  10. dbTableInfo(conn, "sp_table")
  11. my_spdf<-pgGetGeom(conn, name="sp_table", geom = "wkb_geometry")
  12. head(my_spdf@data)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement