0

enter image description here

I'm new to R and I'm having trouble plotting this information. I have to set the plot boundary to the following coordinates: xmin: -96.34018 ymin: 30.61613 xmax: -96.33954 ymax: 30.61701. Scale the size of the symbols representing the trees to the DBH of the tree.

Could someone please help me with this

Allan Cameron
  • 147,086
  • 7
  • 49
  • 87
  • 2
    What you tried anything at all yet? Where exactly are you getting stuck. It's best to share you code so far so we can help with mistakes rather than start from scratch. Also please share your data in a [reproducible format](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Picture of data are not helpful for testing because we can't copy/paste the data into R to try stuff out. – MrFlick Mar 07 '22 at 18:46
  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 07 '22 at 22:25

1 Answers1

0

I am also new to the spatial analyses but I played with the data.

Sample code:

library(readr)
library(ggplot2)  
library(dplyr)  
library(rgdal)  
library(raster)  
library(rworldmap) 

(with_world <- ggplot() +
    geom_polygon(data = world, 
                 aes(x = long, y = lat, group = group),
                 fill = NA, colour = "black") + 
    geom_point(data = df,  
               aes(y = Latitude_dd, x = Longitude_dd),colour = "blue", alpha = 0.5, size = 5) +
    coord_quickmap() +  
    theme_classic() +  
    xlab("Longitude") +
    ylab("Latitude") + 
    guides(colour=guide_legend(title="Coordinates")))

Plot:

enter image description here

Sample data:

df<-structure(list(Number = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 
28, 29, 30), Latitude_dd = c(30.6153, 30.61518, 30.61506, 30.615, 
30.61504, 30.61523, 30.6153, 30.61531, 30.61543, 30.61537, 30.61531, 
30.61522, 30.61529, 30.61559, 30.61566, 30.61553, 30.61565, 30.61575, 
30.61582, 30.61598, 30.61531, 30.61531, 30.61535, 30.61522, 30.61514, 
30.61512, 30.61504, 30.61504, 30.61511, 30.61489), Longitude_dd = c(-96.34108, 
-96.34117, -96.34149, -96.34158, -96.34149, -96.34147, -96.34138, 
-96.34131, -96.34146, -96.34151, -96.34155, -96.34171, -96.34176, 
-96.34147, -96.3413, -96.34155, -96.34161, -96.34169, -96.34178, 
-96.34205, -96.34089, -96.34071, -96.34076, -96.34062, -96.34061, 
-96.3407, -96.34069, -96.34069, -96.34092, -96.34091), DBH_in = c(1.31, 
5.22, 1.42, 8.99, 1.19, 13.72, 5.41, 5.24, 5.69, 5.39, 4.81, 
4.49, 18.92, 11.06, 8.24, 8.28, 3.8, 2.32, 2.1, 3.07, 1.83, 3.99, 
5.89, 2.18, 4.73, 2.47, 0.6, 4.22, 2.86, 4.82), DBH_cm = c(3.33, 
13.26, 3.61, 22.83, 3.02, 34.85, 13.74, 13.34, 14.45, 13.69, 
12.22, 11.4, 48.06, 28.09, 20.92, 21.03, 9.65, 5.89, 5.33, 7.8, 
4.65, 10.13, 14.96, 5.54, 12.01, 6.27, 1.52, 10.72, 7.26, 12.24
), Notes = c("A", "A", "A", "A", "A", "A", "A", "A", "A", "A", 
"A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", 
"B", "B", "C", "C", "C", "C", "C")), spec = structure(list(cols = list(
    Number = structure(list(), class = c("collector_double", 
    "collector")), Latitude_dd = structure(list(), class = c("collector_double", 
    "collector")), Longitude_dd = structure(list(), class = c("collector_double", 
    "collector")), DBH_in = structure(list(), class = c("collector_double", 
    "collector")), DBH_cm = structure(list(), class = c("collector_double", 
    "collector")), Notes = structure(list(), class = c("collector_character", 
    "collector"))), default = structure(list(), class = c("collector_guess", 
"collector")), delim = ","), class = "col_spec"), problems = <pointer: 0x029ed310>, row.names = c(NA, 
-30L), class = c("spec_tbl_df", "tbl_df", "tbl", "data.frame"
))
Rfanatic
  • 2,224
  • 1
  • 5
  • 21