#5908 closed defect (invalid)
regression writing for GeoJSON driver
Reported by: | cmbarbu | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | default | Version: | unspecified |
Severity: | major | Keywords: | gdal, rgdal |
Cc: |
Description
I have been using the R rgdal package for a year. I was writing fine using GeoJSON with rgdal and gdal but today I updated gdal and rgdal and I was not able to write anymore. The rgdal package could not open a file anymore.
After downgrading from GDAL 1.11.1 to GDAL 1.10.1 is is working as before.
I don't know how to reproduce the bug directly using gdal directly but the error I get is:
Erreur dans writeOGR(dat, layer = "dummy", file, driver = "GeoJSON", dataset_options = "azeraze") :
GDAL Error 3: Cannot open file '1apop18p_per_sqMilesbuf0mn.geojson'
where "file" is the file name in the error message.
Attachments (1)
Change History (7)
comment:1 by , 9 years ago
Priority: | high → normal |
---|
by , 9 years ago
Attachment: | vagrantGeoJSONwriteBug.zip added |
---|
folder to set up virtual machine reproducing the bug
comment:2 by , 9 years ago
I can try to reproduce the bug without R but I don't know how to write directly. I contacted rgdal dev team but no response for now.
Attached a vagrant file to setup a virtual machine allowing to reproduce the bug very quickly from scratch. Hereafter the detailed process to setup the virtual machine (copy from the README in the zip file):
#------------------------- # Install and start the VM #------------------------- # install virtualBox (https://www.virtualbox.org/wiki/Downloads) # install vagrant from http://www.vagrantup.com/downloads # then start the machine by tiping in this folder: vagrant up # it might take some time the first time (here 3mn) as it downloads/install everything
#------------------------- # to reproduce the bug #------------------------- # ssh access: vagrant ssh
# start R R # copy paste the following test in the R console library("rgdal") cities <- readOGR(system.file("vectors", package = "rgdal")[1], "cities")
is.na(cities$POPULATION) <- cities$POPULATION == -99 summary(cities$POPULATION) td <- tempdir() if(nchar(Sys.getenv("OSGEO4W_ROOT") > 0)) {
OLDPWD <- getwd() setwd(td) td <- "."
}
writeOGR(cities, layer="cities", "cities.geojson",driver="GeoJSON",dataset_options = "azeraze")
comment:3 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
OK, I've taken the time to reproduce with your above instructions.
The issue is quite subtle. Basically writeOGR() calls ogrCheckExists("cities.geojson") to check first if the file exists before creating a new dataset, and in the 1.11 version the OGR GeoJSON driver will emit an error message that this file doesn't exists, whereas previous version didn't emit an error message. rgdal catches this error as a fatal one and doesn't go to the writing step. This should be fixed in rgdal.
Meanwhile you have an easy workaround : add check_exists = FALSE as a parameter to writeOGR(). (Other workaround is to avoid the .json / .geojson extension in the filename, but that's not a good one)
In trunk (GDAL 2.0dev), the GeoJSON driver no longer emits an error message since the open procedure has been revised again. So I don't see any further action needed here on GDAL side (not really keen in changing that in the 1.11 branch at that point)
comment:5 by , 9 years ago
Please report to the rgdal developers that their ogrcheckExists() function should be tolerant to errors potentially emitted by GDAL
Not sure what we can do about that ticket in GDAL without any direct way of reproducing. Should be investigated on rgdal side first. Perhaps report to them.