0

I have a big MULTIPOLYGON feature that I can manipulate in sf, but when I try to save it in a Geopackage file from sf I get the message:

Failed to create feature 0 in T_POLIGONOS_HILUCS

and then an error

Error in st_write.sf(..., quiet = quiet, append = append, delete_layer = delete_layer) : 
  failed writing to temporary file C:\Users\goerlich\AppData\Local\Temp\RtmpmCJqiq\fileca058a32e7e.gpkg

The big feature comes from a disolving operation, and I can save it before disolving, but not after.

I wonder if is there a limit on the size of a single feature, because according to the OGC GeoPackage Encoding Standard

The maximum size of a GeoPackage file is about 140TB. In practice a lower size limit MAY be imposed by the filesystem to which the file is written. Many mobile devices require external memory cards to be formatted using the FAT32 file system which imposes a maximum size limit of 4GB.

And my feature is about 1GB.

3
  • It may not be a size but a complexity issue. There are several things to try: 1) do an st_buffer(0) to try and fix and invalid shapes, 2) do a st_buffer() by a very small non-zero amount to try and remove small, insignificant holes between dissolved shapes, 3) st_simplify() to smooth out complex edges, 4) and combination of 1, 2, and 3, though try to always put the st_buffer(0) last.
    – Shawn
    Commented Dec 12, 2022 at 23:27
  • Are you able to save your feature in a different format to disk? What about saving to C:\ directly instead of your temp directory? Just to eliminate some other possible reasons for failing..
    – dimfalk
    Commented Dec 13, 2022 at 7:07
  • Options 1) and 2) of @Shawn doesn`t work. Thanks anyway! Commented Dec 13, 2022 at 21:44

1 Answer 1

2

After spliting the disolving in two features I´m able to save the file in Geopackage format without problems. No Failed to create feature 0... appears.

Since GeoPackage is a SQLite database and reviewing the limits: https://sqlite.org/limits.html, I think that I have exceeded the maximum length of a string, and this was the real problem, more than complexity.

See also an SE related question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.