Skip to content
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

Misleading warning #306

Closed
Nowosad opened this issue Apr 17, 2017 · 5 comments
Closed

Misleading warning #306

Nowosad opened this issue Apr 17, 2017 · 5 comments

Comments

@Nowosad
Copy link
Contributor

Nowosad commented Apr 17, 2017

In the last few weeks, I've came across this warning message when I've been writing data to .shp file - Value [SOME_VALUE] of field big_number of feature [SOME_VALUE] not successfully written. Possibly due to too larger number with respect to field width. However, a new file (and a new object) looks the same as the old one. Reproducible example below:

> nc = st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
> nc$big_number = seq(100000, 9900100000, 100000000)
> st_write(nc, 'nc2.shp')
Writing layer `nc2.shp` to data source `nc2.shp` using driver `ESRI Shapefile`
features:       100
fields:         15
geometry type:  Multi Polygon
There were 50 or more warnings (use warnings() to see the first 50)
> warnings()[1]
Warning message:
In CPL_write_ogr(obj, dsn, layer, driver, as.character(dataset_options),  ... :
  GDAL Message 1: Value 100100000 of field big_number of feature 1 not successfully written. Possibly due to too larger number with respect to field width
> nc2 = st_read('nc2.shp', quiet = TRUE)
> identical(nc$big_number, nc2$big_number)
[1] TRUE
@edzer
Copy link
Member

edzer commented Apr 19, 2017

The warning is emitted by gdal, not by sf; I could silence the warning generator before writing, but that would also suppress helpful warnings, maybe not such a good idea.

Does this also occur when you write to GPKG? (we live in post-shapefile era)

@Nowosad
Copy link
Contributor Author

Nowosad commented Apr 19, 2017

Nope, it works fine with GPKG.
Btw - I want to think that we live in a post-shapefile era, but probably it's still way ahead...

@edzer
Copy link
Member

edzer commented Apr 19, 2017

It's up to you.

@edzer
Copy link
Member

edzer commented Apr 19, 2017

rgdal::writeOGR gives the same warnings; there's little we can do in R to ease the pain caused by shapefiles.

@edzer
Copy link
Member

edzer commented Apr 23, 2017

This is a known problem of the GDAL shapefile driver, hence I close it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants