[R-sig-Geo] rgdal and MSSQL Server geometries
Shannon E. Albeke
salbeke at uwyo.edu
Thu Apr 4 18:20:39 CEST 2013
Craig, thanks for the idea. I did create a DSN using ODBC as well as using an explicit string connection. Both give me the same result of: 'Cannot open data source'
Thus, I am thoroughly confused because I can connect to the SQL Server via all of my other methods (RODBC) and software with no issues. I am wondering if there is something with rgdal that is having a miscommunication with the proper drivers. If so, I really do not know how to solve the issue. Hopefully some other ideas will surface from the r-sig-geo list that can provide additional troubleshooting that I can try.
Cheers,
Shannon
-----Original Message-----
From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of cmundy
Sent: Thursday, April 04, 2013 7:52 AM
To: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] rgdal and MSSQL Server geometries
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.
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
More information about the R-sig-Geo
mailing list