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
8
votes
3 answers

How to create animation of vehicle moving form A to B along a route?

below is an example of finding route, travel time and travel distance from 'One World Trade Center, NYC' to 'Madison Square Park, NYC' using osrm package in R. (I learnt it from Road Routing in R). The travel time here is 10.37 minutes. I wanted to…
SiH
  • 1,378
  • 4
  • 18
8
votes
1 answer

Find coordinates x distance along linestring

I would like to extract the coordinates of a point at a known distance along the linestring, starting from one end of the linestring. For example: library(sf) path <- st_as_sfc('LINESTRING(10 20, 11 21, 12 21, 13 22)') start_point <-…
8
votes
1 answer

Select multiple items using map_click in leaflet, linked to selectizeInput() in shiny app (R)

I would like to create a leaflet map where you can select multiple polygons and this will update the selectizeInput() in a shiny app. This would including removing a selected polygon, when it is removed in the selectizeInput(). I have slightly…
william3031
  • 1,653
  • 1
  • 18
  • 39
8
votes
4 answers

R: Detect a "main" Path and remove or filter the GPS trace maybe using a kernel?

Is there a way to filter out those parts which don't belong to the main path? As you can see in the picture i would like to remove the crossed out part while keeping the main path. I already tried using zoo/rolling median but without success. I…
Andreas
  • 397
  • 4
  • 18
  • 37
8
votes
3 answers

Creating sf polygons from a dataframe

I have a dataframe containing the coordinates of a set of polygons. This is how I would convert it to a spatialPolygons (package sp) my.df <- data.frame( Plot = c("A", "A", "A", "A", "A", "B", "B", "B", "B", "B"), Corner = c("SW", "NW", "NE",…
canderson156
  • 1,045
  • 10
  • 24
8
votes
0 answers

Error when installing SF in R double free or corruption

The problem I was trying to install SF again in my Ubuntu 18.04 machine, because it was giving me some problems. Since I wanted to start everything clean I tried the following: remove.packages("sf") install.packages("sf") This however resulted in…
Derek Corcoran
  • 3,930
  • 2
  • 25
  • 54
8
votes
1 answer

why does rbind() work and bind_rows() not work in combining these sf objects?

I've got some sf objects I want to combine. I've stripped them down to a single polygon each (rtmp and rtmp2) for the purposes of this question. rbind() and do.call(rbind,...) seem to work fine, but bind_rows() doesn't. Obviously I can work around…
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
8
votes
1 answer

How to update the leaflet map in the selectModUI in a Shiny app?

I would like to update the selectModUI from the mapedit package for different leaflet maps when using Shiny. Below is a working…
www
  • 38,575
  • 12
  • 48
  • 84
8
votes
1 answer

Create Multilines from Points, grouped by ID with sf package

I have a collection of Points, with a LINEID and an ID_SEQ. The LINEID determines the unique Line-IDS, while the ID_SEQ determines the order of the points in a Line-ID. I want to transform Points to Lines, ordered by ID_SEQ and grouped by…
SeGa
  • 9,454
  • 3
  • 31
  • 70
8
votes
1 answer

Do the values returned by rgeos::gCentroid() and sf::st_centroid() differ?

Question Do the values returned by rgeos::gCentroid() and sf::st_centroid() differ? If so, how? Context After reading the relevant commands exported by rgeos section within the r-spatial/sf wiki, I was thrilled to see that I only needed the sf…
Cristian E. Nuno
  • 2,822
  • 2
  • 19
  • 33
8
votes
1 answer

How to convert list of -sf dataframes into single dataframe with geometry per row in R?

I'm trying to convert the output from the code below, which is a list of sfc dataframes into a dataframe in which the columns contain simple feature collections -one polygon per observation. Output from reproducible example and expected output…
adl
  • 1,390
  • 16
  • 36
8
votes
2 answers

Use apply() with a simple features (SF) function

I've written a function to calculate the maximum distance between a centroid and the edge of its polygon, but I can't figure out how to run it on each individual polygon of a simple features ("sf) data.frame. library(sf) distance.func <-…
John J.
  • 1,450
  • 1
  • 13
  • 28
8
votes
1 answer

How to select certain geometries from a geometrycollection after st_intersect?

I am running an intersect of two polygons or other sf objects using the fantastic new sf package. It's similar to this: a <- st_polygon(list(cbind(c(0,0,7.5,7.5,0),c(0,-1,-1,0,0)))) b <-…
rblue030
  • 83
  • 1
  • 3
8
votes
1 answer

Plotting sfc_POLYGON in leaflet

I have a sfc_POLYGON, IHS obtained as a union of a few shapes using the sf package. Geometry set for 1 feature geometry type: POLYGON dimension: XY bbox: xmin: 270194.7 ymin: 2255850 xmax: 279225 ymax: 2265469 epsg (SRID): …
Dhiraj
  • 1,650
  • 1
  • 18
  • 44
8
votes
1 answer

Converting GeoJSON into a Simple Feature in R

I would like to read a spatial dataset from a Socrata repository into R and then convert it into a simple feature object. The dataset consists of capital improvement projects represented as polygons: The data used in the app above is accessible via…
Tiernan
  • 828
  • 8
  • 20