Closed wcornwell closed 4 years ago
code from frog project
get_species_fire_summary <- function(species_name) {
message(paste0("Analyzing ", species_name))
load(paste0("Data/range_maps/", gsub(" ", "_", species_name), ".RData"))
range <- range_map %>%
st_as_sf() %>%
st_transform(crs=st_crs(hotspot_points))
points_within_range <- range %>%
st_join(hotspot_points)
overlap_extent_area <- range %>%
st_intersection(extent) %>%
st_area() %>%
sum() %>%
as.numeric()
range_area <- range %>%
st_area() %>%
sum() %>%
as.numeric()
overlap_percentage <- (overlap_extent_area/range_area)*100
dat_summary <- points_within_range %>%
dplyr::select(id, latitude, longitude, temp_kelvin,
power, confidence, datetime) %>%
st_set_geometry(NULL) %>%
mutate(extent_percent_burn=overlap_percentage) %>%
mutate(species=species_name)
return(dat_summary)
}
Psuedo-code steps: save all maps to a figures directory with informative names
ggplot
and geom_sf
on the fire shapefile map
5e. add column for inside/outside using st_join
5f. make a map with points colored by inside/outsideprocessed_data
Hey @wcornwell and @coreytcallaghan, Just getting stuck on 5c. a bit. Do I have to assign a CRS to my ebird data before I make it a sf object? and should st_as_sf() do the trick for this transformation? Thanks, Josh
Nah. Part of making it an sf object. In the st as sf function, should be able to set crs=st_crs(fire_object).
On Mon, Jun 15, 2020, 6:31 PM Josh-Lee1 notifications@github.com wrote:
Hey @wcornwell https://github.com/wcornwell and @coreytcallaghan https://github.com/coreytcallaghan, Just getting stuck on 5c. a bit. Do I have to assign a CRS to my ebird data before I make it a sf object? and should st_as_sf() do the trick for this transformation? Thanks, Josh
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Josh-Lee1/eBird-Fire-Index/issues/3#issuecomment-643984594, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGWSEJVIXDCKVCBXA54FDI3RWXL3TANCNFSM4N5VYICQ .
Yeah I think I understand that line of code but cant get the checklists into an sf object I bump into this error. Error in st_sf(x, ..., agr = agr, sf_column_name = sf_column_name) : no simple features geometry column present
Can you flick me an RDS real quick via email and Ill have a go?
On Mon, Jun 15, 2020, 6:43 PM Josh-Lee1 notifications@github.com wrote:
Yeah I think I understand that line of code but cant get the checklists into an sf object I bump into this error. Error in st_sf(x, ..., agr = agr, sf_column_name = sf_column_name) : no simple features geometry column present
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Josh-Lee1/eBird-Fire-Index/issues/3#issuecomment-643990998, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGWSEJTKWWPHVLGWAEBM3M3RWXNJPANCNFSM4N5VYICQ .
Did that make it past your auto reply?
On Mon., 15 Jun. 2020, 18:45 Corey Callaghan, notifications@github.com wrote:
Can you flick me an RDS real quick via email and Ill have a go?
On Mon, Jun 15, 2020, 6:43 PM Josh-Lee1 notifications@github.com wrote:
Yeah I think I understand that line of code but cant get the checklists into an sf object I bump into this error. Error in st_sf(x, ..., agr = agr, sf_column_name = sf_column_name) : no simple features geometry column present
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub < https://github.com/Josh-Lee1/eBird-Fire-Index/issues/3#issuecomment-643990998 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AGWSEJTKWWPHVLGWAEBM3M3RWXNJPANCNFSM4N5VYICQ
.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Josh-Lee1/eBird-Fire-Index/issues/3#issuecomment-643991997, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOENO3WM7Z427ETCKL3S5IDRWXNQZANCNFSM4N5VYICQ .
This should work:
ebird_points <- st_as_sf(data=baatrimmed, coords=c("LONGITUDE", "LATITUDE"), crs=st_crs(fireshape))
And it appears to work for me:
ggplot() +
geom_sf(data = fireshape, size = 0.1, color = "black", fill = "black") +
geom_sf(data=ebird_points, color="green")+
ggtitle("Fire Boundary Plot") +
coord_sf()
I got this error. cant find Longitude? Error in lapply(x[coords], as.numeric) : argument "x" is missing, with no default
Check the spelling and case of the word...?
On Mon, Jun 15, 2020, 8:26 PM Josh-Lee1 notifications@github.com wrote:
I got this error. cant find Longitude? Error in lapply(x[coords], as.numeric) : argument "x" is missing, with no default
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Josh-Lee1/eBird-Fire-Index/issues/3#issuecomment-644043897, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGWSEJXNDSD5GQTIWMJSU63RWXZL7ANCNFSM4N5VYICQ .
:/
Still nothing? It just worked on my machine.
On Mon, Jun 15, 2020, 8:38 PM Josh-Lee1 notifications@github.com wrote:
:/
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Josh-Lee1/eBird-Fire-Index/issues/3#issuecomment-644049138, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGWSEJWSJMAXZ2MFANMP2HTRWX2XRANCNFSM4N5VYICQ .
Yeah no bingo. Could it have to do with needing to update R? I dont think im on the most recent version.
Did you change any code above that chunk?
Sorry! Need to remove the 'data=' in that code.
Here is everything from that .Rmd into a chunk:
baa <- read_delim("C:/Users/CTC/Desktop/baa", "\t", escape_double = FALSE, trim_ws = TRUE)
colnames(baa) <- gsub(" ", ".", colnames(baa))
library(dplyr)
baatrimmed<- baa %>%
filter(ALL.SPECIES.REPORTED==1, EFFORT.DISTANCE.KM<10, DURATION.MINUTES<300, DURATION.MINUTES>10) %>%
select(SAMPLING.EVENT.IDENTIFIER, LOCALITY.ID, LATITUDE, LONGITUDE, OBSERVATION.DATE) %>%
distinct()
library(sf)
fireshape<- st_read("National_Indicative_Aggregated_Fire_Extent_Dataset_v20200211/National_Indicative_Aggregated_Fire_Extent_Dataset_v20200211.shp")
library(ggplot2)
ggplot() +
geom_sf(data = fireshape, size = 0.1, color = "black", fill = "black") +
ggtitle("Fire Boundary Plot") +
coord_sf()
ebird_points <- st_as_sf(baatrimmed, coords=c("LONGITUDE", "LATITUDE"), crs=st_crs(fireshape))
ggplot() +
geom_sf(data = fireshape, size = 0.1, color = "black", fill = "black") +
geom_sf(data=ebird_points, color="green")+
ggtitle("Fire Boundary Plot") +
coord_sf()
Haha ok sweet well I'll let you know how I go after I finish updating R.
Oh the suspense!!
Yipee! Thanks heaps. I will carry on tomorrow.
So trying to figure out how st_join works, I have this line: st_join(ebird_points, fireshape) It adds another column but is full of N/As. Do I need another argument in the function to tell it inside= true or something? or is there another function to apply? Thanks
I'd recommend looking around on google for different vignettes and/or tutorials.
Sometimes if I can't get something to work, I try to find some very simple play data and wrap my head around something that way first.
Ok thanks. Ill give that a go.
On Wed., 17 Jun. 2020, 18:17 Corey Callaghan, notifications@github.com wrote:
I'd recommend looking around on google for different vignettes and/or tutorials.
Sometimes if I can't get something to work, I try to find some very simple play data and wrap my head around something that way first.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Josh-Lee1/eBird-Fire-Index/issues/3#issuecomment-645227669, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOENO3TC5QUBEMCTFMCX6ADRXB3Z5ANCNFSM4N5VYICQ .