I am retrieving thousands of geometry lines in WKT format from a Microsoft SQL Server database. I would like to plot all of those lines in one map, but I am having some difficulty with the code. How should I modify the following code to reach my goal?
library(RODBC)
png(file="examplex.png", width=600, height=480)
setwd("C:/ArcR")
con <- odbcDriverConnect('driver={SQL Server};server=SERVERNAME;database=DBNAME;trusted_connection=true')
objects_1 <- sqlQuery(con, 'SELECT TOP (1) Shape.STAsText() as ShapeWKT FROM TABLENAME ;')
things <- vector("list", 1)
z = 0
for(line in objects_1$ShapeWKT)
{
{
things[[z+1]]<-readWKT(line)
}
z = z + 1
}
plot(things[[1]])
dev.off()
Yes, the code does refer to only one returned record, but I wanted to start the question with code in working order, for those who may not know the answer, but are still capable of testing possibilities.
things <- vector("list", nrow(objects_1))
– Simbamangu Apr 19 at 17:20