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.

sf is a new R package for handling and analyzing spatial data in R. While various R packages are available that provide classes and methods for spatial data (e.g. sp, rgdal and rgeos), sf, which is developed by Edzer Pebesma and others, is intended to gradually replace the well known sp package. The motivation behind this package is to provide a complete, standardized implementation of simple features in R, with links to GDAL, GEOS and Proj.4.

1940 questions
0
votes
1 answer

Displace GPS coordinates of sf point features by vector of offsets in R

Okay, so I'm building on a previous question. I've got an original set of data, and I'm following a specific protocol (that I need to follow for IRB reasons) to offset these randomly. Each point has it's own randomly generated offset. For reference,…
0
votes
0 answers

Randomly displace GPS points by 1) drawing random angle from original point and 2) random distance up to 5 kilometers in R with sf package

I've got a set of gps points from survey data where I need to randomly displace gps points taken at community centers according to a specific, prescribed protocol in order to maintain anonymity. That protocol is For every point, Convert the…
0
votes
1 answer

Getting spatial polygon intersections, excluding borders

I am trying to find which City Council districts represent which zip codes in NYC by using the sf library and leaflet. I have spatial polygons for both council districts and zip codes. My problem is that whenever I try to find the intersection…
0
votes
0 answers

How can I clip a shapefile to my raster using R?

I am trying to mask a raster to a shapefile boundary, but I am getting an error. How can I correctly perform this mask? The raw data can be found here, entitled "data_for_question.txt." It is formatted so that users can copy and paste (from the web…
0
votes
1 answer

How to create a polygon/combine polygons that cross the 180 meridian dateline

I'm trying to create a polygon that has longitudinal limits as 150, -170, i.e. crosses the 180 meridian dateline. I've tried: x = c(-170, -170, 150, 150) #long limits y = c(-25,-57,-57,-25) #lat limits polygon = cbind(x, y) %>% st_linestring()…
Elisa
  • 1
  • 1
0
votes
1 answer

Kriging with gstat in R: Resulting object is blank with no interpolated values

I have kriged a dataset with the gstat package in R, but it has produced an empty variable as a result. I have 1,167 measurement points within a field, and I am trying to interpolate them across 3,464 interpolation points within the same field. How…
ihb
  • 292
  • 9
  • 27
0
votes
2 answers

How to use mapply/sapply/lapply to run st_distance in R

I have two sf points datasets (let's say DtA and DtB). I want to use the function st_distance to measure the straight line distance between each point in DtA and each point in DtB. For example, DtA have 3 points and DtB have 2 points. It should get…
Freeego
  • 135
  • 6
0
votes
1 answer

How to find region-level geometry in sf package in R

I want to plot a geospatial map using sf and plotly package. However, I don't have country-level data, only region-level data (Asia, Europe, Latin America, etc.). This is the mock-up of the dataset I will be working on, I'm looking for a way to…
0
votes
1 answer

Exporting QGIS Shapefiles into R: How to ensure polygon types are saved as factors and not levels?

Deleted my previous question as I realized this is the crux of the issue I am having. I am using the siland package in R to create the optimal buffer size where effect size is greatest from my observation points for each of 7 landcover variables I…
Lara13
  • 1
  • 1
0
votes
1 answer

How to fill data gaps with random coordinates from a polygon?

I have a data set of whale sightings with some coordinate gaps but associated with areas of reference, of which I have coordinate limits. I've used these limits to create a polygon restricted to the marine environment (using library ‘sf’) for each…
Elisa
  • 1
  • 1
0
votes
1 answer

How can plot my own data in a grid in a map sf but return vacum

I am trying to summarize some statistics in the grid that I made, however something fails when I try to do it. This is my data head(catk) Simple feature collection with 6 features and 40 fields Geometry type: POINT Dimension: XY Bounding box: …
0
votes
1 answer

Trouble installing package "sf" in R (Big Sur)

I tried to install the sf package because it is a dependency for tidycensus, which is the package I'd like to use. I am using a Mac with Big Sur. Per the Github for r-spatial, I tried following the installation instructions here but no dice. My…
TCW
  • 25
  • 9
0
votes
1 answer

How to calculate the centroid of a polygon shape file in r

I have this dataset: https://public.opendatasoft.com/explore/dataset/georef-netherlands-postcode-pc4/export/?location=6,52.1564,5.29337&basemap=jawg.light I need to upload it to R and extract the centroid of the polygons in terms of longitude and…
Victor Nielsen
  • 443
  • 2
  • 14
0
votes
1 answer

if else with multiple condition in for loop

I would like to run a for loop over sf with multiple conditions. if value of current column=100, then remains as 100; if value from last column >0, then value of current column = value of last column minus 10; else, value = 0 data input For…
0
votes
1 answer

How to replace values that correspond to polygons by NA?

I have a raster and a shapefile: library(cartography) library(sf) library(raster) r <- raster(matrix(rnorm(10*12), nrow=10), xmn = -180, xmx= 180, ymn = -90, ymx= 90) mtq <- st_read(system.file("gpkg/mtq.gpkg", package="cartography"), quiet =…
Tpellirn
  • 660
  • 4
  • 11
1 2 3
99
100