rpostgis v1.4.3

0

Monthly downloads

0th

Percentile

R Interface to a 'PostGIS' Database

Provides an interface between R and 'PostGIS'-enabled '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 procedures in 'PostgreSQL/PostGIS'.

Readme

rpostgis

CRAN Project Status: Active - The project has reached a stable, usable state and is being actively developed. CRAN Status Project Status: Active - The project has reached a stable, usable state and is being actively developed.

rpostgis provides an interface between R and PostGIS-enabled 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 procedures in PostgreSQL/PostGIS.

Installation of the released versions

You can install the latest released version from CRAN:

install.packages("rpostgis")

You can then use update.packages() to update to the latest CRAN version.

Installation of the development versions

A stable version of the package is always available on the project's GitHub page, and may be ahead of the CRAN version. To install it, use the devtools:

library(devtools)
install_github("mablab/rpostgis")

For the latest (possibly unstable) development version, use:

install_github("mablab/rpostgis", ref = "dev")

Getting started

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>")

Note: as of rpostgis 1.4.3 the RPostgres::Postgres() driver is also allowed for connection objects; however, this should be considered experimental and is not recommended for most use cases.

Once the connection is established, the first step is to check if the database has PostGIS already installed (and install it if it's not the case):

pgPostGIS(conn)

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:

RPostgreSQL::dbDisconnect(conn)

Documentation

Full documentation with the complete list of functions of the package can be found on rpostgis homepage.

Functions in rpostgis

Name Description
dbIndex Create an index.
pgPostGIS Check and create PostGIS extension.
dbWriteDataFrame Write/read in data frame mode to/from database table.
pgSRID Find (or create) PostGIS SRID based on CRS object.
dbSchema Check and create schema.
pgGetPts Load a PostGIS point geometry from a PostgreSQL table/view into R.
pgGetPolys Load a PostGIS polygon geometry from a PostgreSQL table/view into R.
pgCheckGeom Check if geometry or geography column exists in a table, and return the column name for use in a query.
dbVacuum Vacuum.
dbVersion Returns major.minor version of PostgreSQL (for version checking)
dbTableInfo Get information about table columns.
pgGetSRID Get SRID(s) from a geometry/geography column in a full table
pgGetRast Load raster from PostGIS database.
pgInsert Inserts data into a PostgreSQL table.
pgInsertizeGeom Format R data objects for insert into a PostgreSQL table.
dbTableNameFix Format input for database schema/table names.
pgGetGeomQ Load geometries from a full query and return a Spatial* object
rpostgis R interface to a PostGIS database.
pgGetLines Load a PostGIS linestring geometry from a PostgreSQL table/view into R.
pgWriteRast Write raster to PostGIS database table.
dbBuildTableQuery Builds CREATE TABLE query for a data frame object.
pgGetBoundary Retrieve bounding envelope of geometries or rasters.
pgListGeom List geometries/rasters
pgGetGeom Load a PostGIS geometry from a PostgreSQL table/view/query into R.
pgMakePts Add a POINT or LINESTRING geometry field.
dbComment Comment table/view/schema.
dbAsDate Converts to timestamp.
dbExistsTable Check if a PostgreSQL table/view exists
dbDrop Drop table/view/schema.
dbColumn Add or remove a column.
dbGetDefs Get definitions for data frame mode reading
dbConnCheck Check if a supported PostgreSQL connection
bs Return indexes for an exact number of blocks for a raster
dbAddKey Add key.
No Results!

Last month downloads

Details

Date 2019-11-19
SystemRequirements 'PostgreSQL' with 'PostGIS' extension
License GPL (>= 3)
LazyData true
URL https://mablab.org/rpostgis/index.html
BugReports https://github.com/mablab/rpostgis/issues
RoxygenNote 7.0.0
NeedsCompilation no
Packaged 2019-11-20 01:15:09 UTC; david
Repository CRAN
Date/Publication 2019-11-20 06:10:02 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/rpostgis)](http://www.rdocumentation.org/packages/rpostgis)