Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sf objects are no longer accepted in terra::rasterize #1059

Closed
jldupouey opened this issue Mar 9, 2023 · 2 comments
Closed

sf objects are no longer accepted in terra::rasterize #1059

jldupouey opened this issue Mar 9, 2023 · 2 comments

Comments

@jldupouey
Copy link

jldupouey commented Mar 9, 2023

According to #89, it became possible to use an sf object with ext, rast, crop, extract and rasterize, which was a useful improvement. I recently encountered the following error, which suggests that sf objects are no longer supported by rasterize, at least :

library(terra)
# terra 1.7.18

library(sf)
# Linking to GEOS 3.9.3, GDAL 3.5.2, PROJ 8.2.1; sf_use_s2() is TRUE

f <- system.file("ex/lux.shp", package="terra")
According to https://github.com/rspatial/terra/issues/89, it was now possible to use an `sf` object with `ext`, `rast`, `crop`, `extract` and `rasterize`, which was usefull
vSf <- st_read(f)
# Reading layer `lux' from data source 
#   `C:\Users\jldupouey\AppData\Local\R\win-library\4.2\terra\ex\lux.shp' 
#   using driver `ESRI Shapefile'
# Simple feature collection with 12 features and 6 fields
# Geometry type: POLYGON
# Dimension:     XY
# Bounding box:  xmin: 5.74414 ymin: 49.44781 xmax: 6.528252 ymax: 50.18162
# Geodetic CRS:  WGS 84

r <- rast(v, ncols=75, nrows=100)

z <- rasterize(vSf, r, "NAME_2")
# Error in get(as.character(FUN), mode = "function", envir = envir) : 
#   object 'fun' of mode 'function' was not found


@Nowosad
Copy link
Contributor

Nowosad commented Mar 9, 2023

@jldupouey have you tried the most recent development version of {terra} (see #1054)?

@jldupouey
Copy link
Author

Thanks Nowosad. Sorry for the double posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants