rpostgis-package {rpostgis}R Documentation

rpostgis: R Interface to a PostGIS Database

Description

The rpostgis package provides an interface between R and PostGIS-enabled PostgreSQL databases, allowing seamless transfer of spatial data. It supports both vector (points, lines, polygons) and raster data for reading and writing. Additionally, it offers convenience functions to perform common operations within PostgreSQL/PostGIS.

Features

Getting Started

1. Loading the package and connecting to a database To begin, load the rpostgis package and establish a connection to a PostgreSQL database:

library(rpostgis)
con <- dbConnect("PostgreSQL", dbname = "<dbname>", host = "<host>",
                 user = "<user>", password = "<password>")

Example:

con <- dbConnect("PostgreSQL", dbname = "rpostgis", host = "localhost",
                 user = "postgres", password = "postgres")

2. Checking and Installing PostGIS Verify if PostGIS is installed on the database. If not, it will attempt to install it:

pgPostGIS(con)

This function should return TRUE invisibly when PostGIS is installed and ready for use.

3. Closing the Database Connection After finishing your work, make sure to close the connection:

dbDisconnect(con)

List of Functions

To view a list of all available functions in rpostgis, use:

library(help = "rpostgis")

Additional Notes

Author(s)

Maintainer: Adrián Cidre González adrian.cidre@gmail.com (ORCID)

Authors:

See Also

Useful links:


[Package rpostgis version 1.6.0 Index]