mardi 15 décembre 2015

R low performance when writing to SQLite

I observe a very low performance when writing spatial data to "SQLite" via writeOGR() in R. In the code below writing 10.000 testpoints takes approx.2 minutes, but 0.3sec when using "ESRI Shapefile".

Is this an expected behavior of the R-function and are there options to speed this up? Thanks for any help.

System: Ubuntu 15.04, R 3.2.2

    ###running Example
    library(foreign)
    library(rgdal)

    #Testdata
    count<-10000 #define size
    d.data<-data.frame(meter_x=runif(count,2490000,2825000), 
    meter_y=runif(count,1090000,1295000), col1=runif(count,1,100000))

    #create spatial points
    coordinates(d.data)<- ~ meter_x + meter_y  
    proj4string(d.data)=CRS("+init=epsg:2056")

    #compare shapefile to sqlite
    #NOTE:'overwrite_layer=TRUE' gets ignored for SQLite and needs manual delete
    system.time(writeOGR(d.data, dsn="./test.sqlite",layer="test",driver= "SQLite",overwrite_layer=TRUE)) #test SQLITE
    system.time(writeOGR(d.data, dsn=".",layer="test",driver = "ESRI Shapefile",overwrite_layer=TRUE)) #test Shapefile

Aucun commentaire:

Enregistrer un commentaire