1

我有村里某些地点的坐标。每个坐标都意味着我在那里取样。进行研究后,我发现一个测试是阳性的,另一个是阴性的。我想在地图上显示它。该表有一列“注释”,其中包含从 1 到 5 的数字。根据值,点的颜色应该会发生变化。为此,我使用了以下公式

my.df <- read.table(text="
longitude    latitude    note    name
75.317249    42.181918    5      D-01
75.316526    42.181163    5      D-01
75.317272    42.180741    1      N18AT01
75.317112    42.180024    5      D-01
75.317945    42.179996    5      D-01
75.318105    42.180327    5      D-01
75.318368    42.180437    5      D-01
75.318809    42.18116     5      D-01
75.319228    42.181068    1      N18AT02
75.320193    42.180452    5      D-01
75.320343    42.180352    1      N18AT03
75.320589    42.180272    1      N18AT04
75.322318    42.179844    1      N18AT05
75.323058    42.180092    5      D-01
75.323619    42.180545    1      N18AT06
75.323545    42.181142    1      N18AT07
75.323191    42.180965    5      D-01
75.322639    42.180886    1      N18AT08
75.321639    42.181038    4      N18AT09
75.321198    42.180693    5      D-01
75.321395    42.181233    5      D-01
75.3211      42.181462    1      N18AT10
75.319793    42.181997    4      N18AT11
75.318936    42.181964    5      D-01
75.32157     42.182443    1      N18AT12
75.322034    42.182258    3      D-01
75.322739    42.181873    5      D-01
75.32305     42.181991    1      N18AT13
75.324114    42.181683    2      N18AT14
75.324413    42.182389    1      N18AT15
75.324661    42.182426    5      D-01
75.325592    42.182185    4      N18AT16
75.326529    42.181774    5      D-01
75.32754     42.181101    4      N18AT17
75.327406    42.180947    5      D-01
75.326976    42.180899    1      N18AT18
75.327337    42.180554    5      D-03
75.327026    42.18008     3      N18AT19
75.327017    42.178938    1      N18AT20
75.326822    42.178524    2      N18AT21
75.327856    42.178314    5      D-01
75.328515    42.178022    1      N18AT22
75.32865     42.178548    4      N18AT23
75.329241    42.17802     5      D-01
75.330568    42.177277    4      N18AT24
75.333297    42.176426    1      N18AT25
75.334344    42.176361    5      D-01
75.335403    42.175511    3      N18AT26
75.336494    42.176149    5      D-01
75.336253    42.176882    1      N18AT27
75.336313    42.17767     5      D-03
75.335409    42.17839     1      N18AT28
75.332945    42.179434    5      D-01
75.331246    42.18019     1      N18AT29
75.329559    42.18017     2      N18AT30
75.32858     42.179969    1      N18AT31
75.32833     42.180402    5      D-01
75.32626     42.179303    1      N18AT32
75.325616    42.178956    5      D-01
75.324871    42.178909    4      N19AT33
75.319063    42.184572    1      N18AT34",
                    header=TRUE)

# Convert data frame to sf object
my.sf.point <- st_as_sf(x = my.df, 
                        coords = c("longitude", "latitude"),
                        crs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +clr=note")
# simple plot
plot(my.sf.point)


# interactive map:
library(mapview)
mapview(my.sf.point)```

As a result, dots appear on the map, but they have the same colour 
4

0 回答 0