I've noticed when I write an sf data.frame from R and open in QGIS, it seems to convert all of the numeric attribute values from integer to float (even though they should be integer). I'm not sure if this is a QGIS or R issue, but has anyone else had this problem?
I'd rather figure out if I'm doing something incorrect instead of simply converting all values to integer before exporting from R.
Below is a reproducible example in R. When the .shp is opened in QGIS, the integer values will be float.
#load built-in nc shapfile
nc <- st_read(system.file("shape/nc.shp", package="sf"))
plot(nc)
# Compute centroids of counties
centroids.nc <- st_centroid(nc)
plot(centroids.nc)
str(centroids.nc)
#export
st_write(centroids.nc, "test_out.shp")
#check in QGIS - sure enough, the integers have converted to float in QGIS
test.in<-st_read("test_out.shp")
#If I load back into R, they look fine; is it a QGIS thing? ```