Questions tagged [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.

1040 questions
0
votes
2 answers

r units error when using Hmisc and sf packages

I get an error when I try to get the units attribute on a field, after I load the sf package. Below is a reproducible example. library(Hmisc) fail.time <- c(10,20) units(fail.time) <- "Day" library(sf) units(fail.time) <- "Day" Error:…
user3357059
  • 976
  • 11
  • 25
0
votes
2 answers

R combine two lists of sfc_polygons

Hej, I have two lists of polygons. The first one is a list of 1 polygon (circle) The second is a list of 260 polygons (260 rectangles). See the first picture (two lists of polygons). Now I want to keep all the rectangles that are touched by the…
Pit Strehl
  • 11
  • 1
0
votes
1 answer

Ploting a Buffer Around a Point on a Map - R SF

I've been trying to plot a buffer around a point on a map but when I do the buffer doesn't appear in the right place like this. Faulty R Map The correct location is in California. Here's my…
0
votes
2 answers

Retain only two-dimensional components in sf data.frame

I have a similar setup as in this question. In my case, however, I've got an sf data.frame that contains a mix of different geometry types, some POLYGONs, some GEOMETRYCOLLECTIONs like so: a <-…
RoyalTS
  • 7,796
  • 7
  • 45
  • 90
0
votes
1 answer

Accessing Simple Feature geometry column for density calculation

I work with spatial data and I am used to work with Spatial* objects. I recently started using sf package and it seems to make life easier in some cases. However I have a trouble when trying to work with raster package. In kde2d function I need to…
0
votes
1 answer

sf plot, key not showing correctly R

I've been trying to plot a shapefile using sf package plot function but I get this: (The shapefile can be found here: https://drive.google.com/open?id=1AKMP9i549xESStN-R59UUU80OmkXy1XM) sf <-…
noriega
  • 368
  • 1
  • 6
  • 17
0
votes
2 answers

Filter shapefile polygons by area

I have the following boundary dataset for the United Kingdom, which shows all the counties: library(raster) library(sp) library(ggplot) # Download the data GB <- getData('GADM', country="gbr", level=2) Using the subset function it is really easy…
Michael Harper
  • 11,715
  • 2
  • 51
  • 69
0
votes
1 answer

Apply using characters

I'm working with sf objects and I have a question about applying user-defined functions to data frames. This is a silly example, but it is similar to what I'm trying to do with a more complicated problem. I have a data frame called names that has…
user21359
  • 436
  • 3
  • 13
0
votes
0 answers

R sf package order of library loading matters when using Rscript

It appears that the order of loading packages matters when using Rscript with the sf library. library(sf) library(methods) showMethods("coerce") will not contain from="sf", to="Spatial" from="Spatial", to="sf" in the output, and the function…
user2711915
  • 2,223
  • 1
  • 15
  • 17
0
votes
1 answer

maps 3.2.0 package (r): how to put in the same plot multiple regions of a dataset?

I need the map of the lombardy region, in Italy. When I run map("italy") however I can see that the dataset is divided at the province level, not the regional one. Lombardy is composed by 12 provinces. I can get the map of Milan (city and province)…
Pigna
  • 2,322
  • 3
  • 21
  • 44
0
votes
0 answers

R leaflet load-data zoom bounds

I have a shiny app with a large sf of lines I would like to view it only at zoom 15 and to load only the visible part library(leaflet) library(shiny) library(dplyr) library(sf) #random multilinestring polyline_test <-st_multilinestring() ui <-…
Felipe
  • 623
  • 7
  • 19
0
votes
1 answer

How to pass along a user selected column header so that those variables can be shown in a leaflet popup

I would like the user to be able to select what variable they see on a popup in a leaflet map. It works when the variables are hard coded. However something is wrong with passing on a column header. Here is a reproducible example below, you'll…
sbell423
  • 83
  • 10
0
votes
1 answer

How can I do 3D distance calcs using the R "simple features" library `sf`?

I have just recently started using nice and the relatively new library(sf). It's nice to see that points and lines can have Z coordinates. For example: > st_linestring(rbind(c(0,0,0),c(1,1,1))) LINESTRINGZ(0 0 0, 1 1 1) However, it seems clear…
jtolle
  • 6,803
  • 2
  • 23
  • 49
0
votes
1 answer

read multiple `.shp` file as one object?

how to read multiple .shp file as one object? I want to read simply like under the code. nc <- st_read(dsn = "nc", layer = c("nc1","nc2")) what is the best method to read multiple files as a object? library(sf) nc <-…
ogw
  • 283
  • 1
  • 2
  • 12
0
votes
0 answers

R function will not coerce sf data.table

I am trying to coerce only certain columns in my sf data.table from character to numeric. When I write the code out without a function it works. columns <- c("STATEFP", "COUNTYFP", "TRACTCE", "BLKGRPCE", "GEOID", "ALAND", "AWATER", "INTPTLAT",…
sbell423
  • 83
  • 10