sf

Shiny deployment error: upgrade GEOS to 3.6.0 or later while installing package ‘lwgeom’

余生颓废 提交于 2020-07-22 06:12:43
问题 I have a shiny app that runs fine on my computer. I use packages sf , leaflet , and tmap . One of these requires the package lwgeom as a dependency. While installing the package lwgeom , shiny deployment gives me the following error message. What is GEOS ? And how can I upgrade GEOS to 3.6.0 or later? Building R package: lwgeom (0.2-4) /mnt/packages/build /mnt * installing to library ‘/opt/R/4.0.0/lib/R/library’ * installing *source* package ‘lwgeom’ ... ** package ‘lwgeom’ successfully

r - Convert output from sf::st_within to vector

吃可爱长大的小学妹 提交于 2020-07-06 12:33:50
问题 Im trying to use the sf package in R to see if sf object is within another sf object with the st_within function. My issue is with the output of this function which is sparse geometry binary predicate - sgbp and I need a vector as an output so that I can use the dplyr package afterwards for filtering. Here is a simplified example: # object 1: I will test if it is inside object 2 df <- data.frame(lon = c(2.5, 3, 3.5), lat = c(2.5, 3, 3.5), var = 1) %>% st_as_sf(coords = c("lon", "lat"), dim =

How to calculate centroid of polygon using sf::st_centroid?

狂风中的少年 提交于 2020-07-05 06:57:51
问题 I am trying to manipulate some Brazilian Census data in R using the new "sf" package. I am able to import the data, but I get an error when I try to create the centroids of the original polygons library(sf) #Donwload data filepath <- 'ftp://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_de_setores_censitarios__divisoes_intramunicipais/censo_2010/setores_censitarios_shp/ac/ac_setores_censitarios.zip' download.file(filepath,'ac_setores_censitarios.zip') unzip('ac

How to obtain hexagonal type sample from st_sample (R package sf)?

痴心易碎 提交于 2020-06-29 06:52:42
问题 I want to create some sample points from an area. The points have to give an impression of density. I want them not to be random, to avoid people thinking they are "real" observations. I want them to be hexagonal distributed across the area. How to get such a sample? st_sample with type = "hexagonal" does not do the trick. A reproducible example: library(sf) nc <- st_read(system.file("shape/nc.shp", package="sf")) # this works: nc_samples_random <- st_sample(nc[1,], 100, type = "random") #

Spatial line start and end point in R

拈花ヽ惹草 提交于 2020-06-01 06:41:10
问题 I am attempting to use the sp package to access the start and end points of a linestring, similar to what ST_StartPoint and ST_EndPoint would produce using psql . No matter how I try to access the line, I get errors or NULL value: > onetrip@lines[[1]][1] Error in onetrip@lines[[1]][1] : object of type 'S4' is not subsettable > onetrip@lines@Lines@coords Error: trying to get slot "Lines" from an object of a basic class ("list") with no slots > onetrip@lines$Lines NULL The only solution that

Spatial line start and end point in R

╄→尐↘猪︶ㄣ 提交于 2020-06-01 06:41:10
问题 I am attempting to use the sp package to access the start and end points of a linestring, similar to what ST_StartPoint and ST_EndPoint would produce using psql . No matter how I try to access the line, I get errors or NULL value: > onetrip@lines[[1]][1] Error in onetrip@lines[[1]][1] : object of type 'S4' is not subsettable > onetrip@lines@Lines@coords Error: trying to get slot "Lines" from an object of a basic class ("list") with no slots > onetrip@lines$Lines NULL The only solution that

Creating sf polygons from a dataframe

你。 提交于 2020-05-17 03:01:22
问题 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", "SE", "SW2", "SW", "NW", "NE", "SE", "SW2"), Easting = c(511830, 512230, 512230, 511830, 511830, 511730, 512130, 512130, 511730, 511730), Northing = c(7550903, 7550903, 7550503, 7550503, 7550903, 7550803, 7550803, 7550403, 7550403, 7550803)) utm18 <- CRS

Creating sf polygons from a dataframe

随声附和 提交于 2020-05-17 02:59:25
问题 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", "SE", "SW2", "SW", "NW", "NE", "SE", "SW2"), Easting = c(511830, 512230, 512230, 511830, 511830, 511730, 512130, 512130, 511730, 511730), Northing = c(7550903, 7550903, 7550503, 7550503, 7550903, 7550803, 7550803, 7550403, 7550403, 7550803)) utm18 <- CRS

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

爱⌒轻易说出口 提交于 2020-05-11 06:55:47
问题 I would like to update the selectModUI from the mapedit package for different leaflet maps when using Shiny . Below is a working example. library(tidyverse) library(shiny) library(sf) library(leaflet) library(mapview) library(mapedit) library(DT) library(viridis) # Load the sf object nc <- st_read(system.file("shape/nc.shp", package = "sf")) # Project transformation nc <- st_transform(nc, crs = 4326) # Create a color function for the leaflet map sid74_pal <- colorBin(palette = viridis(10),

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

[亡魂溺海] 提交于 2020-05-11 06:55:06
问题 I would like to update the selectModUI from the mapedit package for different leaflet maps when using Shiny . Below is a working example. library(tidyverse) library(shiny) library(sf) library(leaflet) library(mapview) library(mapedit) library(DT) library(viridis) # Load the sf object nc <- st_read(system.file("shape/nc.shp", package = "sf")) # Project transformation nc <- st_transform(nc, crs = 4326) # Create a color function for the leaflet map sid74_pal <- colorBin(palette = viridis(10),