pgisCreateRaster: Create a raster into PostGIS

Description Usage Arguments Examples

View source: R/rasters.R

Description

Creates into PostGIS database a raster covering a given extent, with a given pixel size (scale).

Usage

1
pgisCreateRaster(conn, tbl, extent, scale = 1000)

Arguments

conn

a PostgreSQLConnection object.

tbl

character; name of the created table (default: rastertest).

extent

spatial extent covered by the raster. Can be either a bbox class objet, a sf object, or the name of a PostGIS table (default: NULL).

scale

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
library(spData)
library(sf)
library(RPostgreSQL)
library(raster)
data(seine) # CRS is in meters
# Create a raster of 5km resolution pixel covering french seine river
conn = dbConnect(drv=dbDriver("PostgreSQL"), host="localhost", port=5432,
                dbname="foodflows", user="milo", password="postgres")
pgisCreateRaster(conn, "rastertest", extent=seine, scale=5000)
# Check
rast = pgisGetRaster(conn, "rastertest")
values(rast) = rnorm(ncell(rast))
plot(rast)
plot(st_geometry(seine), add=TRUE)
dbDisconnect(conn)

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