https://github.com/Cidree/rpostgis
rpostgis: R Interface to a 'PostGIS' Database
https://github.com/Cidree/rpostgis
postgis postgresql-database rstats-package
Last synced: 7 months ago
JSON representation
rpostgis: R Interface to a 'PostGIS' Database
- Host: GitHub
- URL: https://github.com/Cidree/rpostgis
- Owner: Cidree
- Created: 2015-12-18T15:10:29.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-27T16:01:29.000Z (over 1 year ago)
- Last Synced: 2024-04-14T20:10:26.268Z (about 1 year ago)
- Topics: postgis, postgresql-database, rstats-package
- Language: R
- Homepage: http://cidree.github.io/rpostgis/
- Size: 21.5 MB
- Stars: 77
- Watchers: 4
- Forks: 15
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - Cidree/rpostgis - rpostgis: R Interface to a 'PostGIS' Database (R)
README
## rpostgis
The `rpostgis` package provides an interface between R and
[`PostGIS`](https://postgis.net/)-enabled
[`PostgreSQL`](https://www.postgresql.org/) 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:
``` r
pak::pak("rpostgis")
```## Installation of the development versions
A stable version of the package is always available on the project’s
[GitHub page](https://github.com/Cidree/rpostgis), and may be ahead of
the CRAN version. To install it, use the following command:``` r
pak::pak("Cidree/rpostgis")
```For the latest (possibly unstable) development version, use:
``` r
remotes::install_github("Cidree/rpostgis", ref = "dev")
```## Getting started
`rpostgis` relies on a working connection provided by the `RPostgreSQL`
package to a PostgreSQL database, e.g.:``` r
conn <- RPostgreSQL::dbConnect(
drv = "PostgreSQL",
host = "localhost",
dbname = "",
user = "",
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):``` r
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:``` r
pgListGeom(conn, geog = TRUE)
pgListRast(conn)
```To terminate the session, close and clear the connection with:
``` r
RPostgreSQL::dbDisconnect(conn)
```## Documentation
Full documentation with the complete list of functions of the package
can be found on `rpostgis`
[homepage](http://cidree.github.io/rpostgis/).