I am currently working with multiple shapefiles in R and working towards rasterizing them using a combination of functions from sf
,terra
and stars
. However, I noticed while reading in a shapefile that terra::vect()
and sf::st_read()
are providing me with different extents for the same shapefile. Please see below.
terra::vect(shapefile1)
class : SpatVector
geometry : polygons
dimensions : 538, 3 (geometries, attributes)
extent : -180, 180, -90, 90 (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 (EPSG:4326)
names : id class gridcode
type : <int> <chr> <int>
values : 1 settlements 2
2 settlements 2
3 settlements 2
sf::st_read(shapefile1)
Reading layer `1870-settlements' from data source
`data\spatial\1870-settlements.shp'
using driver `ESRI Shapefile'
replacing null geometries with empty geometries
Simple feature collection with 538 features and 3 fields (with 1 geometry empty)
Geometry type: POLYGON
Dimension: XY
Bounding box: xmin: 76.492 ymin: 11.22461 xmax: 77.00837 ymax: 11.53395
Geodetic CRS: WGS 84
Why am I getting this discrepancy? Such an error surely impacts future analyses.
Edit: Adding a link to the file - https://drive.google.com/drive/u/2/folders/1uDVQt1F64rUTfCXclwr-sM-oFjyJ2NwV
replacing null geometries with empty geometries
and it would be very helpful if you could share your file (even if privately)