I am trying to execute following code to get nearest distance:
df1 <- fread("df1.csv")
df2<- fread("df2.csv")
#converting geometry column data in df1 from wkb to multilinestring:
df1$geometry <- sf::st_as_sfc(structure(as.list(df1$geometry), class = "WKB"), EWKB=TRUE)
#Gelocate:
MSF <- st_as_sf(df2, coords = c("Longitude","Latitude"))%>% sf::st_set_crs(4326)
MSF <- MSF %>% dplyr::mutate(nearest_geometry = df1[st_nearest_feature(geometry, df1), ]$geometry)
But it gives the following error:
Error in `stopifnot()`:
! Problem while computing `nearest_geometry = wkb_data[st_nearest_feature(geometry, wkb_data),
]$geometry`.
Caused by error:
! st_crs(x) == st_crs(y) is not TRUE
For your information, the geometry column data in df1 was initially like:
df1$geometry :"0105000020E61000002100000001020000000D0000002EBF61F61BB355C09CE8FB1AD30E424034E6D51712B355C04815A8F5EA0E............"
then I converted wkb format to multilinestring:
df1$geometry:"list(c(-122.396182945493, -122.396169444649, -122.396161..."