[R-sig-Geo] problem writing GML file

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Sun Feb 21 22:49:50 CET 2010

On Sun, Feb 21, 2010 at 9:28 PM, Michael Denslow
<michael.denslow at gmail.com> wrote:
> Dear r-sig-geo,

> I was able to make a SpatialPointsDataFrame just fine with the
> following commands.
>> library(rgdal)
>> coordinates(floras) = c('long.cent.W','lat.cent.N')
>> class(floras)
> [1] "SpatialPointsDataFrame"
> attr(,"package")
> [1] "sp"
> but when I run writeOGR, I get an error
>> writeOGR(floras,paste(getwd(),'florasTEST.gml',sep='/'),'floras', driver = 'GML')
> Error in writeOGR(floras, paste(getwd(), "florasTEST.gml", sep = "/"),  :
>  unknown data type

That's weird - writeOGR looks like it should output the type and class
of the column when it gets this problem:

else stop(paste(dfcls[i], dftof[i], "unknown data type"))

 - unless you're on a different version. Try running writeOGR in debug
mode - do:


then run your writeOGR function call. Hit return to step a line at a
time, and inspect variables. Or how about cutting some of your
variables out and seeing what fixes it/breaks it?

your sp object only seemed to have factors, numbers, and logicals and
so writeOGR shouldnt have any problem with it...


blog: http://geospaced.blogspot.com/
web: http://www.maths.lancs.ac.uk/~rowlings
web: http://www.rowlingson.com/
twitter: http://twitter.com/geospacedman
pics: http://www.flickr.com/photos/spacedman

More information about the R-sig-Geo mailing list