Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [r-sf]

The motivation behind the `sf` package is to provide a complete, standardized implementation of simple features in R, with links to GDAL, GEOS and Proj.4. There is a also https://gis.stackexchange.com/ for spatial R questions.

1 vote
1 answer
98 views

Transform a dataframe with list-columns of coordinates into multiple multipolygons

I have a dataframe where every line is a list of coordinates of a neighbourhood; t <- structure(list(lng = list(c(-43.265319264, -43.265206066, -43.265037676, -43.264643583, -43.2645450269999, -43....
Pedro Leo's user avatar
0 votes
1 answer
78 views

'unable to find an inherited method for function ‘costDistance’ for signature' error while trying to do a friction weighted connectivity analysis

The purpose What I am trying to achieve: I am trying to calculate the friction weighted connectivity values of the polygons in a shapefile using a friction raster. The shapefiles symbolize habitats ...
Time_Bottle's user avatar
0 votes
1 answer
63 views

How to preserve holes when combining contours into polygons via R?

Part of the workflow for my project requires creating contours from a raster. I am able to generate the contours using raster::rasterToContour and can convert to a polygon using the sf package in R, ...
DDaye's user avatar
  • 15
2 votes
2 answers
114 views

Replace plot points with polygons

I am trying to create a plot where instead of using points to represent data, I use the outline of administrative boundaries. The below code illustrates where I am up to. Just a simple ordered scatter ...
flee's user avatar
  • 1,315
0 votes
1 answer
98 views

Why does apply seem to drop the CRS?

The title really sums up my question. Apply seems to drop the CRS, but other functions don't. What is the best way to calculate a geographic function on a vector of points? library(tidyverse) library(...
Alex Krohn's user avatar
-1 votes
1 answer
63 views

Count shapefile length (line) in each polygon of another shapefile (grid)

I am trying to quantify the length of a road network, on each cell of a lattice grid. Both my road network and my lattice grid are shapefiles, a polyline and a polygon respectively. I would like to ...
user8780's user avatar
3 votes
1 answer
106 views

Error when subsetting sfc objects with explicit binary predicate

I don't understand why the last two examples in the following code chunk fail library(sf) #> Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE p1 <- st_sfc(st_point(c(0, 0))) ...
agila's user avatar
  • 3,630
1 vote
0 answers
119 views

How do I generate the correct volume contour from a raster using sf, spatialEco, and terra?

I am interested in using R packages spatialEco and terra to generate some kernel density estimates with data of varying weights so that I can export contour shapefiles for mapping. I'm currently ...
DDaye's user avatar
  • 15
4 votes
2 answers
104 views

reverse st_transform for real-world coordinates

I have a process that rotates specific sf objects, and this works well for rendering, both in ggplot2 and plotly. However, in shiny apps we need to take a user's click and do something useful with it, ...
r2evans's user avatar
  • 159k
0 votes
1 answer
73 views

Logical expressions for spatial geometry and polygon attributes

I want to subset a list of polygons based on (1) whether or not they intersect other polygons in the list in space and (2) an attribute of the polygon that describes time (e.g., when the polygon was ...
gregor-fausto's user avatar
2 votes
1 answer
179 views

Same code (using R's dplyr, stringr, and sf) produces different results when using different package versions

I am trying to run the same R code using computers that different versions of packages, but in one of them the code works and in the other it produces an error. Specifically, I downloaded files from ...
DOS's user avatar
  • 55
1 vote
0 answers
162 views

How to solve error message " Error in if (file == "") stop("'file' must be non-empty string") : the condition has length > 1" while saving .rds?

My code looks like that and works fine so far: # Iterate over each row in the result for (i in seq_along(inter2012)) { # Extract the indices of intersecting points for the i-th polygon indices <...
tim's user avatar
  • 11
2 votes
0 answers
212 views

Insert spatial data into a duckdb table from R

I would like to insert data containing a spatial geometry into a duckdb table that contains a geometry column, but I am receiving an error. Create the table using duckdb command line duckdb ~/duck.db ...
Ben Carlson's user avatar
  • 1,175
1 vote
0 answers
457 views

Installing `terra` or `sf` R package using Conda

I would like to install the terra or sf R package in a Conda environment (on a Linux HPC). The following error appears if I install it from within R: # remotes::install_github("rspatial/terra&...
Ahmed El-Gabbas's user avatar
0 votes
1 answer
73 views

Problem creating dynamic Alpha Hull for multiple groups

how are you? I would like your help, please, to create alpha polygons in R for different groups. I would like these polygons to be separated by my "species" column. I understand that the ...
Álvaro Scuack's user avatar

15 30 50 per page