pgisRasterizeTable: Rasterize a PostGIS vector table

Description Usage Arguments References Examples

View source: R/rasters.R

Description

Rasterize a PostGIS vector table.

Usage

1
pgisRasterizeTable(conn, tbl, name, xref = NULL, yref = NULL, scale = 1000)

Arguments

conn

a PostgreSQLConnection object.

tbl

character; name of the input vector table to rasterize.

name

character; name of the output raster table.

xref

numeric; x coordinate of reference pixel bottomleft corner. If NULL (default), the center of the extent is taken.

yref

numeric; y coordinate of reference pixel bottomleft corner. If NULL (default), the center of the extent is taken.

scale

numeric; size of the raster pixels, in meters (default: 1000).

References

https://nronnei.github.io/blog/2017/03/creating-rasters-from-scratch-in-postgis/ http://geospatialelucubrations.blogspot.com/2014/05/a-guide-to-rasterization-of-vector.html

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
library(spData)
library(RPostgreSQL)
library(sf)
data(seine)
Sys.sleep(10)
conn = dbConnect(drv=dbDriver("PostgreSQL"), host="localhost", port=5432,
                dbname="foodflows", user="milo", password="postgres")
sf::dbWriteTable(conn, name="seine", seine, overwrite=TRUE)
Sys.sleep(10)
pgisRasterizeTable(conn, "seine", "seine_rast")
Sys.sleep(10)
rast = pgisGetRaster(conn, "seine_rast", flip=TRUE)
raster::plot(rast)

MiloMonnier/postgisr documentation built on Feb. 16, 2021, 8:03 p.m.