| sqli2sp {SQLiteMap} | R Documentation |
From SQLite database transforms the source geometries in WKT form to SpatalPolygons, SpatialLines or SpatialPoints object.
sqli2sp(geoms, gcol, idcol)
geoms |
table contains the WKT geometry field |
gcol |
the geometry field of geoms table |
idcol |
field of geoms table for identification |
Returns SpatalPolygons, SpatialLines or SpatialPoints depending on the source geometry type.
Norbert Solymosi <solymosi.norbert@gmail.com>
sqli2map, sqli.dump, sp package
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))