I am trying to use the rasterize function in the R package terra (v.1.6-7) to transfer population values associated with municipalities to a raster. I am doing this for two shapefiles, dipomun00gw.shp
and municipiosPOP.shp
. This is the code:
library(terra)
# Read shapefiles for 2000 and 2010
v_00 <- vect("dipomun00gw.shp")
v_10 <- vect("municipiosPOP.shp")
# create blank rasters using each year's shape file as extent
r_00 <- rast(v_00, res=.01)
r_10 <- rast(v_10, res=.01)
# Rasterize
x_00 <- rasterize(v_00, r_00, "POTO00")
x_10 <- rasterize(v_10, r_10, "POB_10")
#Error: [rasterize] cannot create dataset
For some reason, v_00
rasterizes without any issues, but v_10
produces the an error.
I cannot identify what characteristic of the shapefile municipiosPOP.shp
is causing this error.
Does anyone know what is going on?
Shapefiles can be accessed here.