You can use purrr::map
function instead of loop:
Data:
data_list <- list(sf1 = structure(list(geometry = structure(list(structure(c(2.3111662,
48.840346), class = c("XY", "POINT", "sfg"))), class = c("sfc_POINT",
"sfc"), precision = 0, bbox = structure(c(xmin = 2.3111662, ymin = 48.840346,
xmax = 2.3111662, ymax = 48.840346), class = "bbox"), crs = structure(list(
input = "WGS84", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]]"), class = "crs"), n_empty = 0L)), row.names = c(NA,
-1L), sf_column = "geometry", agr = structure(integer(0), .Label = c("constant",
"aggregate", "identity"), class = "factor", .Names = character(0)), class = c("sf",
"tbl_df", "tbl", "data.frame")), sf2 = structure(list(geometry = structure(list(
structure(c(2.36571460340002, 2.3655857662182, 2.36547329046861,
2.36542516193229, 2.36528545258358, 2.36512653636567, 2.3648060350023,
2.36424260145439, 2.36387560297359, 2.36366713159424, 2.36334443947327,
2.36322695208547, 2.36317764205549, 2.36318437079076, 2.36321528700506,
2.36326729012258, 2.36331020083956, 48.8776400092826, 48.8774711513306,
48.8773023799338, 48.8772238828371, 48.8770522688551, 48.8768904454866,
48.8765622871995, 48.8759189703608, 48.8754916354644, 48.8752575997409,
48.8748871565497, 48.874683281842, 48.8744788703593, 48.8742630655848,
48.8740761681905, 48.8739487391069, 48.8738959065238), .Dim = c(17L,
2L), class = c("XY", "LINESTRING", "sfg"))), class = c("sfc_LINESTRING",
"sfc"), precision = 0, bbox = structure(c(xmin = 2.36317764205549,
ymin = 48.8738959065238, xmax = 2.36571460340002, ymax = 48.8776400092826
), class = "bbox"), crs = structure(list(input = "WGS84", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"geodetic latitude (Lat)\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"geodetic longitude (Lon)\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]]"), class = "crs"), n_empty = 0L)), row.names = 1L, class = c("sf",
"data.frame"), sf_column = "geometry", agr = structure(integer(0), .Label = c("constant",
"aggregate", "identity"), class = "factor", .Names = character(0))))
Code:
library(tidyverse)
list_adj <- map(1:length(data_list), function(x) data_list[[x]] %>%
st_crs()) # Replace st_crs() by anything, that is for the example.
names(list_adj) <- map(1:length(data_list), function(x) names(data_list)[[x]])
Output:
$sf1
Coordinate Reference System:
User input: WGS84
wkt:
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]]
$sf2
Coordinate Reference System:
User input: WGS84
wkt:
GEOGCRS["WGS 84",
DATUM["World Geodetic System 1984",
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
ID["EPSG",4326]]