首页 > 解决方案 > 计算多边形的平均宽度

问题描述

对于我的研究,我想计算多边形的平均宽度,但我不知道如何做到这一点。我已经尝试使用以下函数计算多边形的面积和长度: p <- st_area(PlasticMap$geometry) s <- st_length(PlasticMap$geometry)

但是,第二个函数没有给出实际的长度值。有人知道要使用哪个功能吗?

带有数据框 PlasticMap 示例的文件 https://www.dropbox.com/t/73LfAju8GczZGH1

structure(list(ï..Segment = c("1", "2", "3"), Karakteristieken = c("", 
"", ""), Potential.Hotspot. = c("", "", ""), Shoppingbags = c(2L, 
0L, 1L), Garbage.bags = c(0L, 0L, 0L), Small.plastic.bags = c(2L, 
0L, 1L), Drinking.bottles..0.5.litre = c(0L, 0L, 0L), Drinking.bottles..0.5.litre.1 = c(0L, 
0L, 0L), Caps.and.lids = c(0L, 0L, 0L), Candy.and.snack.packaging = c(3L, 
0L, 0L), Soft..coffee..cups = c(2L, 0L, 0L), Beer.cups = c(0L, 
0L, 0L), Cups.of.hardplastics = c(1L, 0L, 0L), Cultery = c(0L, 
0L, 0L), Straws = c(0L, 0L, 0L), plastic...50cm = c(0L, 0L, 0L
), Styrofoam..2.5.cm = c(0L, 0L, 0L), Styrofoam.2.5..50.cm = c(0L, 
0L, 0L), Styrofoam..50.cm = c(0L, 0L, 0L), styrofoam.Foodpackagings = c(0L, 
0L, 0L), Styrofoam.cups = c(0L, 0L, 0L), Face.masks = c(0L, 0L, 
0L), Cans = c(0L, 0L, 0L), foodpackagings = c(3L, 3L, 1L), Lighters = c(0L, 
0L, 0L), stationery = c(0L, 0L, 0L), Plates = c(0L, 0L, 0L), 
    Stirring.rods = c(0L, 0L, 0L), plastic.gloves = c(0L, 0L, 
    0L), Buckets = c(0L, 0L, 0L), ivm.planten = c(0L, 0L, 0L), 
    kratten = c(0L, 0L, 0L), tie.wraps = c(0L, 0L, 0L), Tape.en.ductape = c(0L, 
    0L, 0L), Toys = c(0L, 0L, 0L), Fish.related.plastic = c(0L, 
    0L, 0L), Ropes = c(0L, 0L, 0L), firework.related.plastic = c(0L, 
    0L, 0L), Industrial.packaging = c(0L, 0L, 0L), Undefined.hardplastics..2.5.cm = c(0L, 
    0L, 0L), Undefined.hardplastics..2.5.cm.1 = c(0L, 0L, 0L), 
    Undefined.softplastics..2.5.cm = c(1L, 1L, 0L), Undefined.softplastics.2.5.50.cm = c(3L, 
    3L, 0L), Undefined.softplastics..50.cm = c(1L, 0L, 0L), others = c(0L, 
    0L, 0L), total.per.segment = c(18L, 7L, 3L), Segments = c("1", 
    "2", "3"), Name = c("Polygon_0", "Polygon_1", "Polygon_2"
    ), area = structure(c(2119.38551853225, 3434.45557230711, 
    1468.4810865894), units = structure(list(numerator = c("m", 
    "m"), denominator = character(0)), class = "symbolic_units"), class = "units"), 
    geometry = structure(list(structure(list(structure(c(4.49109722517787, 
    4.4911562337762, 4.49141640805065, 4.49153106168303, 4.49167253740557, 
    4.49186430454714, 4.49203863733011, 4.49195012443262, 4.49186429374414, 
    4.49141370423563, 4.49128765121493, 4.49122730691362, 4.49117970040432, 
    4.49109722517787, 52.1590995946512, 52.1591835128946, 52.1589515032474, 
    52.1586981674863, 52.1584958401809, 52.1582754115939, 52.1580434634424, 
    52.1580064397592, 52.1579727070432, 52.158402870485, 52.1587800296503, 
    52.1589455715584, 52.1590324559312, 52.1590995946512, 2.99988603591919, 
    2.99183964729309, 2.40731048583984, 2.53703236579895, 1.7993448972702, 
    1.70235204696655, 2.97568416595459, 2.99991106987, 2.99433088302612, 
    2.24391674995422, 2.64786505699158, 2.88580274581909, 2.9915452003479, 
    2.99988603591919), .Dim = c(14L, 3L))), class = c("XYZ", 
    "POLYGON", "sfg")), structure(list(structure(c(4.49190077173521, 
    4.49207377421667, 4.49240871770789, 4.49300725139818, 4.4934010577792, 
    4.49372217133827, 4.49355394652571, 4.49340447129623, 4.49320135188646, 
    4.4928889903824, 4.49261041976467, 4.49247918108286, 4.49210826381405, 
    4.49190077173521, 52.1579396855016, 52.1580087964557, 52.1577646013457, 
    52.1573467223082, 52.1570604747069, 52.1568833172331, 52.1567672962674, 
    52.1568115202277, 52.1569215657057, 52.1571252005455, 52.1573222410903, 
    52.1574224065549, 52.1577327746443, 52.1579396855016, 2.99563932418823, 
    2.9975118637085, 1.73729801177978, 1.77834272384644, 1.24517893791199, 
    2.65903639793396, 2.55808258056641, 2.06801223754883, 2.05560731887817, 
    2.01417827606201, 1.93208587169647, 1.63398516178131, 2.3523416519165, 
    2.99563932418823), .Dim = c(14L, 3L))), class = c("XYZ", 
    "POLYGON", "sfg")), structure(list(structure(c(4.49376884116707, 
    4.49362131967125, 4.49388015284119, 4.49403236820278, 4.49420335902748, 
    4.49486854686318, 4.49491146220741, 4.49376884116707, 52.1568582770578, 
    52.1567562534508, 52.1566394196781, 52.1565748318623, 52.1565238197631, 
    52.1563498022432, 52.1564518267818, 52.1568582770578, 2.86207246780396, 
    2.7911262512207, 3, 2.99970936775208, 2.99894738197327, 2.91044163703919, 
    2.54315519332886, 2.86207246780396), .Dim = c(8L, 3L))), class = c("XYZ", 
    "POLYGON", "sfg"))), class = c("sfc_POLYGON", "sfc"), precision = 0, bbox = structure(c(xmin = 4.49109722517787, 
    ymin = 52.1563498022432, xmax = 4.49491146220741, ymax = 52.1591835128946
    ), class = "bbox"), z_range = structure(c(zmin = 1.24517893791199, 
    zmax = 3), class = "z_range"), crs = structure(list(input = "WGS 84", 
        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)), sf_column = "geometry", agr = structure(c(ï..Segment = NA_integer_, 
Karakteristieken = NA_integer_, Potential.Hotspot. = NA_integer_, 
Shoppingbags = NA_integer_, Garbage.bags = NA_integer_, Small.plastic.bags = NA_integer_, 
Drinking.bottles..0.5.litre = NA_integer_, Drinking.bottles..0.5.litre.1 = NA_integer_, 
Caps.and.lids = NA_integer_, Candy.and.snack.packaging = NA_integer_, 
Soft..coffee..cups = NA_integer_, Beer.cups = NA_integer_, Cups.of.hardplastics = NA_integer_, 
Cultery = NA_integer_, Straws = NA_integer_, plastic...50cm = NA_integer_, 
Styrofoam..2.5.cm = NA_integer_, Styrofoam.2.5..50.cm = NA_integer_, 
Styrofoam..50.cm = NA_integer_, styrofoam.Foodpackagings = NA_integer_, 
Styrofoam.cups = NA_integer_, Face.masks = NA_integer_, Cans = NA_integer_, 
foodpackagings = NA_integer_, Lighters = NA_integer_, stationery = NA_integer_, 
Plates = NA_integer_, Stirring.rods = NA_integer_, plastic.gloves = NA_integer_, 
Buckets = NA_integer_, ivm.planten = NA_integer_, kratten = NA_integer_, 
tie.wraps = NA_integer_, Tape.en.ductape = NA_integer_, Toys = NA_integer_, 
Fish.related.plastic = NA_integer_, Ropes = NA_integer_, firework.related.plastic = NA_integer_, 
Industrial.packaging = NA_integer_, Undefined.hardplastics..2.5.cm = NA_integer_, 
Undefined.hardplastics..2.5.cm.1 = NA_integer_, Undefined.softplastics..2.5.cm = NA_integer_, 
Undefined.softplastics.2.5.50.cm = NA_integer_, Undefined.softplastics..50.cm = NA_integer_, 
others = NA_integer_, total.per.segment = NA_integer_, Segments = NA_integer_, 
Name = NA_integer_, area = NA_integer_), .Label = c("constant", 
"aggregate", "identity"), class = "factor"), row.names = c(NA, 
3L), class = c("sf", "data.frame"))

标签: rgeospatialspatialsp

解决方案


ST_MaxDistance(geo, geo) 给你直径(两点之间的最大距离),这可能是更好的测量在这里


推荐阅读