in the last weeks I got inconsistent results using vector layers in R using the terra package.
For example, using this dataset: http://www.soest.hawaii.edu/pwessel/gshhg/gshhg-shp-2.3.7.zip
A month ago I performed these actions (I used GSHHS_f_L1.shp but this problem happened with several layers in the zip file):
library(terra)
xx<-vect('~/GSHHS_f_L1.shp')
plot(xx)
is.valid(xx)
TRUE
The plot and everything else worked fine
One week ago I did it again using the same layer. The plot worked fine, but
is.valid(xx)
FALSE
yy<-makeValid(xx)
is.valid(yy)
TRUE
and again, everything worked fine.
However, the last days I got this error (same layer) that I still can’t solved
is.valid(xx)
Error: IllegalArgumentException: Points of LinearRing do not form a closed linestring
yy<-makeValid(xx)
Error: IllegalArgumentException: Points of LinearRing do not form a closed linestring
After this, the plot is the only action that works. I try the common solution of creating a 0-buffer, but I got the same error.
I updated terra and downloaded the zip file again, but nothing change.
I know of some alternatives using sf, but I feel very comfortable with terra and I want to know if there is a solution using this package.
I’m using R 4.4.0, terra 1.7.78 in a laptop Linux Ubuntu 22.04.4 LTS. The only change in the last weeks was that I installed the package gower from github.
Any recommendation will be very appreciated