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.

0 votes
1 answer
112 views

Is it possible to pass an SQL query that contains an SQL function to the query parameter of the st_read function in R's sf package? What alternative?

I have a shapefile and I want to load only the observations that satisfy some condition (to avoid unnecessarily loading the whole dataset). To do it using R's sf package, I have to pass to the query ...
DOS's user avatar
  • 55
1 vote
2 answers
122 views

Transparent or uniform colour for outer-most Voronoi polygons in a figure

I'm trying to remove the outer polygons in a Voronoi diagram. The main plot looks like this: require(ggplot2) require(ggvoronoi) set.seed(2023) N <- 80 x <- runif(N) y <- runif(N) df <- ...
p-robot's user avatar
  • 4,784
0 votes
1 answer
136 views

R filling in a matrix with values from spatial data

I have a matrix in R called “habitat” with latitude as the rownames and longitude as the column names. The cells are filled with NA right now. My end goal is to have the whole matrix filled with ...
E Norton's user avatar
2 votes
0 answers
287 views

How to get outline of sf object?

I'm looking for a way to extract/infer a polygon from some sf object, that describes an outline that encompasses valid data. I only have limited experience with sf, so any advice aside from an answer ...
teunbrand's user avatar
  • 36.9k
2 votes
2 answers
148 views

How to plot a map with south up using the ggplot2 and sf packages?

I am trying to plot a map with south up using the packages ggplot2 and sf. I tried the functions coord_flip and scale_y_reverse, but I was not successful. The base code I am using is: library(...
Marcio Cure's user avatar
0 votes
1 answer
108 views

Error with M values and st_zm function in sf package

I have imported a multipolygon shp file containing different forest patches (called 'patch'): patch Then, I have bricked different Sentinel-2 bands for the same region in a raster called 'SenBel' data:...
Max_student's user avatar
1 vote
1 answer
122 views

Aggregate grid cells to larger resolution in sf

Consider a grid cell, where each cell is 10x10. library(sf) grid1 <- st_make_grid() plot(grid1) I would like to create another grid cell, based on grid1, where each cell is 30x30 and consists of ...
Maël's user avatar
  • 50.9k
1 vote
3 answers
78 views

Select random rows until threshold value from other column is reached

I have an SF-object in R. It looks as follows: Type Value Geometry A 1 () A 3 () B 2 () A 1 () C 4 () In the geometry column, the ...
Stevestingray's user avatar
2 votes
1 answer
137 views

How to create a line from 2 sf objects

I have 2 shapefiles that have the same number of rows. I want to create a line for each row. I can't figure out how to do it. Here is my example code library(sf) #> Linking to GEOS 3.11.2, GDAL 3.6....
olivroy's user avatar
  • 821
0 votes
1 answer
194 views

How to create (using R's sf) a spatial data frame whose geometry column is the difference between the geometry columns of other two data frames?

I have two spatial data frames that I've loaded using the sf package in R. In the first data frame I have (61) US counties, while in the second I have a subpart of each of these (61) counties. Both ...
DOS's user avatar
  • 55
0 votes
1 answer
109 views

How to transform a sf table to a stars cube with stars::st_as_stars function?

I want to transform a sf data.frame into a stars cube, and choose the dimensions. But I don't succeed in using the function stars::st_as_stars properly and get what I want. Why do I want to transform ...
Julien PRAMIL's user avatar
0 votes
1 answer
66 views

Weighted aggregation of stars object

I was wondering if it's possible to adjust the following code in such a way that the aggregate() function takes into account the overlapping area between each pixel defined in a stars object and the &...
agila's user avatar
  • 3,630
1 vote
2 answers
116 views

st_transform not accurately projecting connecting lines of a polygon

I am currently having an issue where I am trying to project rectangular polygons onto a map of North America. My issue stems from the fact that I am specifying the polygon in lat/long, then projecting ...
Michael L's user avatar
  • 303
1 vote
1 answer
595 views

Convert a vector grid created with sf::st_make_grid into a raster stack

I have a vector grid created with sf::st_make_grid() with several columns of values. I would like to convert it to a raster stack, with each column of values becoming a layer of the raster stack. I ...
Gilles San Martin's user avatar
0 votes
1 answer
197 views

How to add multiple points to map with tmap in R?

I'm learning how to make maps with R so I'm kinda new to all of this. I'm using tmap to plot a map (you can find the shp here https://www.data.rio/datasets/%C3%A1reas-program%C3%A1ticas-da-sa%C3%BAde/...
Lana Meijinhos's user avatar

15 30 50 per page
1
3 4
5
6 7
133