Skip to content
Prev 18335 / 29559 Next

Bug in writeOGR MSSQLSpatial driver?

On Thu, 23 May 2013, cmundy wrote:

            
This can be seen by comparing SVN revisions in the R-forge rgdal project:

https://r-forge.r-project.org/scm/viewvc.php/pkg/R/ogr_write.R?root=rgdal&r1=408&r2=468

As you can see, writeOGR() takes the row.names of the object, coerces them 
to integer (because OGR only uses long integer FIDs), and if any are NA, 
should replace them with default integer. You'll see the typo in line 135. 
These are then inserted using the C code.

https://r-forge.r-project.org/scm/viewvc.php/pkg/src/OGR_write.cpp?root=rgdal&r1=394&r2=468

I've committed the fix to R-forge (revision 473), but for now as a 
work-around that should avoid the bug, assign character row names that 
converts to integer without NA to:

row.names(polyunion90df) # shows the input value
row.names(polyunion90df) <- "<integers as strings>" # one for each row
row.names(polyunion90df) # check that it got assigned
as.integer(row.names(polyunion90df)) # check that it isn't NA but integer

Hope this helps,

Roger