| line2poly | R Documentation | 
Function for basic geometry calculations on polyline features, within an overlapping destination polygon layer.
line2poly(
  linez,
  polyz,
  poly_id,
  measurez = c("length", "density", "distance"),
  outvar_name = "line",
  unitz = "km",
  reproject = TRUE,
  na_val = NA,
  verbose = TRUE
)
| linez | Source polyline layer.  | 
| polyz | Destination polygon layer. Must have identical CRS to  | 
| poly_id | Name of unique ID column for destination polygon layer. Character string. | 
| measurez | Desired measurements. Could be any of "length" (sum of line lengths by polygon), "density" (sum of line lengths divided by area of polygon) and/or "distance" (distance from each polygon to nearest line feature). Default is to report all three. Character string or vector of character strings. | 
| outvar_name | Name (root) to be given to output variable. Default is  | 
| unitz | Units of measurement (linear). Defaul is  | 
| reproject | Temporarily reproject layers to planar projection for geometric operations? Defaul is  | 
| na_val | Value to be assigned to missing values (line lengths and densities only). Defaul is  | 
| verbose | Print status messages and progress? Default is  | 
An sf polygon object, with summary statisics of linez features aggregated to the geometries of polyz.
If measurez = "lengths", contains fields with suffixes
 "_length". Sum of line lengths within each polygon, in km or other units supplied in unitz.
If measurez = "density", contains fields with suffixes
 "_length". Sum of line lengths within each polygon, in km or other units supplied in unitz.
 "_area". Area of each polygon, in km^2 or the square of linear units supplied in unitz.
 "_density". Sum of line lengths divided by area of each polygon, in km/km^2 or other units supplied in unitz.
If measurez = "distance", contains fields with suffixes
 "_distance". Distance from each polygon to nearest line feature, in km or other units supplied in unitz.
If measurez = c("length","density","distance") (default), contains all of the above.
# Road lengths, densities and distance from polygon to nearest highway
## Not run: 
data(hex_05_deu)
data(highways_deu1992)
out_1 <- line2poly(linez = highways_deu1992,
                   polyz = hex_05_deu,
                   poly_id = "HEX_ID")
plot(out_1["line_length"])
plot(out_1["line_density"])
plot(out_1["line_distance"])
## End(Not run)
# Replace missing road lengths and densities with 0's, rename variables
## Not run: 
out_2 <- line2poly(linez = highways_deu1992,
                   polyz = hex_05_deu,
                   poly_id = "HEX_ID",
                   outvar_name = "road",
                   na_val = 0)
plot(out_2["road_length"])
plot(out_2["road_density"])
plot(out_2["road_distance"])
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.