[R-sig-Geo] rgdal and MSSQL Server geometries

cmundy Craig.Mundy at utas.edu.au
Thu Apr 4 15:51:58 CEST 2013


Hi Shannon,

The following syntax has worked for me for the past year.

projstring <- CRS('+init=epsg:28355')

##Establish the dsn
# Note: use the odbc tool in Windows to create a dsn for your SQL Server
database beforehand
myMSSQLdsn <-
c("MSSQL:server=mysqlservername;database=mydatabase;trusted_connection=yes")

#Confirm connection is working
ogrListLayers(myMSSQLdsn)

#Reading sp object classes from SQL SERVER
lyr <- c("mssqlserverTablename")
spdf <-readOGR(dsn=myMSSQLdsn, layer=lyr,p4s=CRSargs(projstring))


#Writing sp object classes to SQL SERVER
lyrout= c("NewMSSQLSpatialTableName")
writeOGR(spdfname, dsn=myMSSQLdsn, layer=lyrout, driver="MSSQLSpatial",
layer_options=c("SRID=28355"))


If you haven't created a dsn, this could be a big part of your problem.

Craig



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/rgdal-and-MSSQL-Server-geometries-tp7583193p7583203.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list