I have Global Fishing Watch data for the whole world in a dataframe with columns being Lon, Lat, fishing_hours, gear type.
How do I crop the data to my area of interest?
I have tried the following:
# project fishing data
library(sp)
coordinates(fishing_data) = ~ Lon+Lat # this creates a SpatialPointsDataFrame which will create a KDE for each id.
crs <-"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
proj4string(fishing_data) <- crs
# create clipping polygon with extent being the study area
library(raster)
cp <- as(extent(-70, -55, -60, -38), "SpatialPolygons")
crs <-"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
proj4string(cp) <- crs
# clip fishing data by clipping polygon
library(rgeos)
dfc <- gIntersection(df2, cp, byid=TRUE)
However, this takes a very long time to run and / or R crashes.
I do not have any sample data. I do not know how to create MRE for spatial data.