Questions tagged [r-sp]
An R package for spatial data. Questions on spatial data might be better asked on https://gis.stackexchange.com
r-sp
686
questions
0
votes
0
answers
42
views
How to convert projected coordinates back to lat and long
I am working with lat long coordinates in R. First I need to transform my coordinates to zone 17 and then add some buffer to them. For that I used next code (the data used is in orig_coords ):
library(...
2
votes
1
answer
81
views
How to avoid margins with wide spplot?
I am generating graphics with spplot and I have margin problems.
library(sp)
library(grid)
library(gridExtra)
demo(meuse, ask = FALSE, echo = FALSE)
p = spplot(meuse, c("zinc"), aspect=0.1)
...
0
votes
1
answer
32
views
Fill NA values in SpatialPixelsDataFrame: equivalent to terra::focal?
I try to fill NA cells in a SpatialPixelsDataFrame based on mean values from neighbouring cells. I wonder if there is any automatized approach equivalent to the focal function in terra (see here).
...
0
votes
0
answers
64
views
Add adjacency matrix in Voronoi
The data x and y represent the geographic coordinates of the centroids of cities 1 to 8:
> df <- data.frame(
+ ID = 1:8,
+ x = c(4.0, 7.0, 2.5, 8.0, 3.0, 5.0, 6.0, 7.0),
+ y = c(8, 9, 4, 5,...
0
votes
2
answers
100
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
86
views
Plotting the Frequency of Observations in States in R
I would like to plot the frequency of observations in our data seen in each state.
Here is the data:
structure(list(fips = c("02", "04", "05", "06", "08&...
1
vote
0
answers
31
views
How can I use libraries within a parallelized function with ply?
Novice programmer here. I am trying to use plyr's ldply function and doParallel to speed up a process, but my function uses the libraries terra and sp. My limited understanding of parallel processing ...
1
vote
1
answer
123
views
sp::gridded equivalent in sf
I am updating my code so that sp functions are being replaced with comparable sf functions (due to the r-spatial evolution). There are some functions I am struggling to replace. I often take rasters, ...
0
votes
0
answers
54
views
Ordinary kriging returns a prediction frame with identical predictions at every location
So I have two datasets with latitude, longitude and depth in them and I am trying to krige them so that I create a very high resolution bathymetric map for a study I am conducting. I am using the ...
0
votes
1
answer
165
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 ...
2
votes
1
answer
271
views
Is there an sf (or df) based alternative to kernelUD to estimate bivariate normal kernel density?
I am switching from sp to sf but have some analysis which uses kernelUD from adehabitatHR which requires my data to be SpatialPoints. Is there an equivalent which does not use sp, perhaps instead ...
0
votes
0
answers
207
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
49
views
R Spatial Information Aggregation
I am trying to build a mapping function with R, using the dplyr, sp and rgdal packages. To start with, I'll describe the data. I have downloaded the shapefile of the entire world from opendatasoft.com....
0
votes
1
answer
522
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
269
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",&...