sqli2sp {SQLiteMap}R Documentation

Read SQLite geometry table into spatial

Description

From SQLite database transforms the source geometries in WKT form to SpatalPolygons, SpatialLines or SpatialPoints object.

Usage

sqli2sp(geoms, gcol, idcol)

Arguments

geoms table contains the WKT geometry field
gcol the geometry field of geoms table
idcol field of geoms table for identification

Value

Returns SpatalPolygons, SpatialLines or SpatialPoints depending on the source geometry type.

Author(s)

Norbert Solymosi <solymosi.norbert@gmail.com>

See Also

sqli2map, sqli.dump, sp package

Examples

sqli.db <- system.file("sqlimaps/sids.db3", package="SQLiteMap")
drv <- dbDriver("SQLite")
con <- dbConnect(drv, dbname = sqli.db)

sql <- 'select sidsmap.gid, sidsmap.geom, sidsattr.* 
  from sidsmap Inner Join sidsattr On sidsattr.sp_id = sidsmap.sp_id 
  order by sidsattr.name'
rs <- dbSendQuery(con, sql)
join.data <- fetch(rs, n = -1)

sids.sp <- sqli2sp(geoms=join.data, gcol='geom', idcol='name')
sids.attr <- data.frame(R74 = join.data$sid74/join.data$bir74, 
  R79 = join.data$sid79/join.data$bir79)
rownames(sids.attr) <- join.data$name
sids.df <- SpatialPolygonsDataFrame(sids.sp, sids.attr)

library(RColorBrewer)
spplot(sids.df, 
  col.regions = colorRampPalette(brewer.pal(9,"OrRd")[1:9])(140))

[Package SQLiteMap version 0.3 Index]