-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
st_write(obj, "file.shp", update = TRUE) gives file name "file.shp.shp" #307
Comments
I'm afraid your expectations were too optimistic. |
Well then isn't this description of the
For reference,
In any case, is the addition of an extra |
This description comes from @Robinlovelace , see #274, and might still reflect the same optimism that update would automatically overwrite. Noone has implemented a delete operation (which gdal supports) so far; The addition of the extra You might get further by using the |
|
This approach has typically had issues on Windows platforms - if you care to look at rgrass7 and earlier attempts to unlink files on Windows that may have been owned by other processes. You need to use the GDAL functions, as in rgdal, and be very careful with destroying a whole directory when dsn is not a file. It is not at all simple to get right cross-platform. |
Please also go through #274 to understand why such a solution can't be part of |
@tim-salabim I applaud any effort to implement this! In the meantime, should the docs be made more consistent with actual behavior? |
@eivindhammers don't misunderstand me, I am not planning to implement this in sf. I merely mean that I have no problems with handling this in my own scripts/functions. |
Just to say: yes that was me who wrote the demonstrably incorrect documentation. Apologies. I did not test on Windows and subsequently realised that does not behave as stated for .geojsons either I don't think. @tim-salabim good timing with you latest comment: I was about to say I would be up for helping you implement that. I think a GDAL delete interface would be best but do not currently have the skill/capacity to do this. Heads up @Nowosad who has also discussed this with me and Edzer. |
st_write(nc, "test.shp", delete_dsn = TRUE) will now first delete data source |
Great stuff. From a user's perspective it may be more useful to have Out of interest, where are GDAL's deleting capabilities/args documented? This is the best I can find (always struggle to find any docs about GDAL - probably not looking hard enough!): http://www.gdal.org/gdalmanage.html |
modifies the default layer name in case of ESRI Shapefile by stripping a trailing .shp. The GDAL driver does this, but in case we don't do it, delete_layer will not work, as the layer name GDAL writes (without .shp) does not match the one we used to pass to GDAL (with the .shp).
We now have tidy versions > library(sf)
Linking to GEOS 3.5.1, GDAL 2.1.3, proj.4 4.9.2, lwgeom 2.3.2 r15302
> nc = read_sf(system.file("shape/nc.shp", package="sf"))
> write_sf(nc, "test.shp")
> write_sf(nc, "test.shp") that are silent and overwrite (have The original construct with |
Nice! Great work, thanks! |
Great stuff! |
Awesome work, that will make life much easier for many people! |
Windows 7 64 bit, MRO 3.3.2, latest Github version of
sf
.returns
where only "test.shp" was expected.
The text was updated successfully, but these errors were encountered: