rpostgis provides an interface between R and
PostgreSQL databases to transparently transfer spatial data. Both
vector (points, lines, polygons) and raster data are supported in read
and write modes. Also provides convenience functions to execute common
You can install the latest released version from CRAN:
You can then use
update.packages() to update to the latest CRAN version.
For the latest (possibly unstable) development version, use:
install_github("mablab/rpostgis", ref = "dev")
rpostgis relies on a working connection provided by the
RPostgreSQL package to a PostgreSQL database, e.g.:
conn <- RPostgreSQL::dbConnect("PostgreSQL", host = "localhost", dbname = "<DB_NAME>", user = "<USER>", password = "<PASSWORD>")
Once the connection is established, the first step is to check if the
PostGIS already installed (and install it if it's not
If the function returns
TRUE, the database is ready and functional.
You can check the geometries and rasters present in the database with:
pgListGeom(conn, geog = TRUE) pgListRast(conn)
To terminate the session, close and clear the connection with:
Full documentation with the complete list of functions of the package
can be found on
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.