Closed cdjemiel closed 4 years ago
You have to transform it to an sf
object, currently is an sp
https://r-spatial.github.io/sf/reference/st_as_sf.html
Thank you,
In fact you have to use an sf object as input.
library(cartography)
library(sf)
#> Linking to GEOS 3.7.1, GDAL 2.4.0, PROJ 5.2.0
library(raster) ##Load the Raster Library
#> Le chargement a nécessité le package : sp
france_metro = getData('GADM', country='FRA', level=2)
france_metro_sub = subset(france_metro, NAME_2=="Allier" | NAME_2=="Haute-Loire")
# from sp object to sf object
reg <- st_as_sf(france_metro_sub)
# project object from WGS84 to Lambert 93
# to ease the fine tuning of getPencilLayer() if needed
reg_p <- st_transform(reg, 2154)
reg_pencil = getPencilLayer(reg_p, size = 1000)
plot(st_geometry(reg_p))
plot(st_geometry(reg_pencil), add = T)
Created on 2020-04-28 by the reprex package (v0.3.0)
Thank you very much for your quick reply.
It's perfect !
Hi,
First of all, congratulations on this package which will be an essential tool for me in the coming weeks. I am new to geostatistics but I am more and more interested in it as part of my postdoc.
I want to do a map using the getPencilLayer() function from a formal class spatialpolygonsdataframe object. However I have the following error message
Can you tell me if it's possible to use an object like this for with this function and can you suggest me some tips ?
Here is my code: