A similar question was asked in another thread and they suggested
using st_transform if it is a data.file class but R doesn't recognise
that function. What could be the problem in this case?
There are two different, incompatible spatial data types in R with two different, packages with differently-named functions to work with them.
The older types use the sp
and rgdal
packages, and create data called things like "SpatialPolygonsDataFrames". You use spTransform
to transform those.
The newer types use the sf
package, and use functions beginning st_
to work on them, such as st_transform
to change coordinate systems.
You have tried to use an sp
function on an sf
data object, hence the error:
unable to find an inherited method for function ‘spTransform’ for signature ‘"sf", "CRS"’
Without knowing exactly how you got an sf
object (threeStates
) or what you intend to do with it its hard to give an exact way for you to proceed here. But to convert from sp
to sf
you can so st_as_sf(something)
, and to convert the other way from sf
to sp
you can do as(thing, "Spatial")
.
So...
install the sf
package with install.packages("sf")
and then after doing library(sf)
then:
spTransform(as(threeStates,"Spatial"), CRS(fire@crs@projargs))`
might get you past this (although we have no idea what fire
is...)