All Questions
128
questions
0
votes
2
answers
105
views
Cannot write shapefile to working directory from sp object using rgdal package in R 4.2.3
The rgdal package is not working anymore. I used writeOGR:
writeOGR(occ_sp, species_set[i], driver = "ESRI Shapefile", dsn = dsn, overwrite = TRUE)
but got this error:
Error in writeOGR(...
0
votes
1
answer
166
views
How to calculate near neighbours in sf object with polygon geometry in R?
I have polygon shape data for German postcodes. For those postcode polygon I like to calculate various nearest neighbour measures. I have seen that procedures working with the sp package (using ...
0
votes
0
answers
211
views
Issues with st_intersection or st_difference to cut polygons spread outside USA
I have a following use case to cut/diff the polygons that spread outside the boundary. I am trying to migrate from rgdal package to sf packages as they are expiring. The code below works fine.
...
0
votes
1
answer
526
views
converting sf multipolygon to sp
I have sf object with multipolygons which i need to convert to sp object. It does not seem to work with sf conversion functions.
I tried
library(absmapsdata)
library(sp)
library(sf)
vic_sa4<-...
3
votes
1
answer
271
views
Compute the degrees between pairs of coordinates in R
I am trying to calculate the angle (with 0 positioned west) between each pair of points.
Here below is a representative example of the dataset I have.
data<-data.frame(from_id=c("id1",&...
0
votes
2
answers
934
views
Extract centroid latitude and longitude for each county in the U.S. using R
How can I get a data frame listing each state and county in the U.S. along with the latitude and longitude of the center of each county?
A version of this question has been asked many times over the ...
0
votes
0
answers
84
views
Create non-circular buffer around points (Spatial R)
I have some data that exist in a waterway system river network, and I'm trying to draw a buffer around some points, to see which areas of the water lie within a 10km boat ride.
library(raster)
library(...
0
votes
1
answer
623
views
How to calculate distance between all possible combinations of points within a group
I have a sf object with 68 observation. In each location I have 4 different points, with different PointIDs(SchlagID) but same LocationIDs(FieldID). I want to now calculate the distance between each ...
2
votes
1
answer
724
views
Split a spatial polygon into two polygons with a line
I want to take a line and use it to split a polygon into multiple polygons, or to create two separate named region in the original polygon (if that's possible). The end goal would be having points ...
0
votes
1
answer
73
views
How do I plot lines joining each pair of centroids of polygons in the `tmap`
How do I plot lines joining each pairs of centroids of countries in the tmap? The color (or transparency) of line should represent the the total population of countries joined.
Example of how map ...
1
vote
0
answers
411
views
How to read kml files in R without any error?
I am trying to read the .kml which I downloaded from the link below:
https://data.opencity.in/dataset/delhi-metro-map/resource/delhi-metro-lines-map
However, I keep getting an error.
Here is a snippet ...
2
votes
0
answers
61
views
Parallelizing nested lapply
How best can I parallelize this? year_ras is a spatRaster while sh_fields_base is an sf object.
yearStats <- lapply(year_list, function(year){
year_ras <- terra::rast(paste0(datadir, "/...
1
vote
3
answers
414
views
Create random points based in distance and boundary conditions
In my example, I have:
# Packages
library(sf)
library(ggplot2)
# Create some points
set.seed(1)
df <- data.frame(
gr = c(rep("a",5),rep("b",5)),
x = rnorm(10),
y = rnorm(...
0
votes
1
answer
336
views
R: Legend for geom_polygon() with single value
I'm using ggplot2 for map plots in R. How do I add a legend entry for a layer without a scale, just for a uniform color:
geom_polygon(data = watercourses, fill = "#0055aa", alpha = .5)
I ...
0
votes
1
answer
106
views
Crop and join two spatial data
I have two dataset, the first one (df1) which has latitude and longitude and the second one (usa) is (sf, datafarme).
df1 = structure(list(Latitude = c(44.11, 45.78, 44.49, 46.87, 44.81,
44.11, 44.45,...