sf

Create regional lat, long dataframe from group of states

和自甴很熟 提交于 2021-01-05 08:59:40
问题 I have been using urbnmapr for all of my mapmaking and it contains nice borders for mapping US states. I now need the outer border of a few states to make a regional map and am looking for a way to filter the dataframe to include only the outer borders. I will use this outer border to mask a raster image. The region I am working with is filter(urbnmapr::states, state_name %in% c("South Dakota", "Nebraska", "Iowa", "Minnesota", "Missouri", "Michigan", "Indiana", "Illinois", "Wisconsin",

Plotting lines between two sf POINT features in r

非 Y 不嫁゛ 提交于 2021-01-02 07:21:44
问题 I have two spatial features: library(sf) points1 <- data.frame(foo = seq(15, 75, 15), long = c(-85, -80, -78, -75, -82), lat = c(34, 36, 37, 38, 35)) %>% st_as_sf(coords = c('long', 'lat'), crs = 4326) points2 <- data.frame(bar = seq(15, 75, 15), long = c(85, 80, 78, 75, 82), lat = c(30, 32, 34, 36, 38)) %>% st_as_sf(coords = c('long', 'lat'), crs = 4326) cbind(points1, points2) -> df This gives: foo bar geometry geometry.1 1 15 15 POINT (-85 34) POINT (85 30) 2 30 30 POINT (-80 36) POINT (80

Plotting lines between two sf POINT features in r

血红的双手。 提交于 2021-01-02 07:21:12
问题 I have two spatial features: library(sf) points1 <- data.frame(foo = seq(15, 75, 15), long = c(-85, -80, -78, -75, -82), lat = c(34, 36, 37, 38, 35)) %>% st_as_sf(coords = c('long', 'lat'), crs = 4326) points2 <- data.frame(bar = seq(15, 75, 15), long = c(85, 80, 78, 75, 82), lat = c(30, 32, 34, 36, 38)) %>% st_as_sf(coords = c('long', 'lat'), crs = 4326) cbind(points1, points2) -> df This gives: foo bar geometry geometry.1 1 15 15 POINT (-85 34) POINT (85 30) 2 30 30 POINT (-80 36) POINT (80

Calculate minimum distance between multiple polygons with R

自古美人都是妖i 提交于 2020-12-31 04:34:49
问题 I'm still somewhat new to R and the sf package... I have two sets of multipolygon data that I am trying to analyze. My first set of polygons (fires) contains hundreds of wildfire perimeters. The second set (towns) contains hundreds of urban areas boundaries. For each fire, I would like to calculate the distance to the closest town (fire polygon edge to closest town polygon edge), and add that as a field to each fire. So far I have mostly been using the sf package for spatial data. In my

Calculate minimum distance between multiple polygons with R

て烟熏妆下的殇ゞ 提交于 2020-12-31 04:31:45
问题 I'm still somewhat new to R and the sf package... I have two sets of multipolygon data that I am trying to analyze. My first set of polygons (fires) contains hundreds of wildfire perimeters. The second set (towns) contains hundreds of urban areas boundaries. For each fire, I would like to calculate the distance to the closest town (fire polygon edge to closest town polygon edge), and add that as a field to each fire. So far I have mostly been using the sf package for spatial data. In my

copy libpq.5.dylib to /usr/lib/libpq.5.dylib

倖福魔咒の 提交于 2020-12-13 17:50:09
问题 I can't load packages in R because the file libpq.5.dylib is not in /usr/lib/libpq.5.dylib . It is in /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib I tried this line: sudo ln -s /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib /usr/lib/libpq.5.dylib but I get this response: ln: /usr/lib/libpq.5.dylib: Operation not permitted What can I do to get the file in /usr/lib/libpq.5.dylib without causing issues? This solution suggests that I may face problems down the line so I don't understand what to

copy libpq.5.dylib to /usr/lib/libpq.5.dylib

别来无恙 提交于 2020-12-13 17:49:08
问题 I can't load packages in R because the file libpq.5.dylib is not in /usr/lib/libpq.5.dylib . It is in /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib I tried this line: sudo ln -s /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib /usr/lib/libpq.5.dylib but I get this response: ln: /usr/lib/libpq.5.dylib: Operation not permitted What can I do to get the file in /usr/lib/libpq.5.dylib without causing issues? This solution suggests that I may face problems down the line so I don't understand what to

Removing holes from polygons in R sf

廉价感情. 提交于 2020-12-05 07:06:41
问题 Is there a way to remove holes from a polygon in R with the package sf ? I would be interested in solutions that include other packages, too. Here's an example of a polygon with two holes. library(sf) outer = matrix(c(0,0,10,0,10,10,0,10,0,0),ncol=2, byrow=TRUE) hole1 = matrix(c(1,1,1,2,2,2,2,1,1,1),ncol=2, byrow=TRUE) hole2 = matrix(c(5,5,5,6,6,6,6,5,5,5),ncol=2, byrow=TRUE) pts = list(outer, hole1, hole2) (pl1 = st_polygon(pts)) # POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 2, 2 2, 2 1,

sf: Write Lat/Long from geometry into separate column and keep ID column

蓝咒 提交于 2020-12-02 10:42:24
问题 I have a df with polygon ID's from a shapefile and their centre-points in a geometry column: # A tibble: 3 x 2 ID geometry <dbl> <POINT [°]> 1 1 (117.2 31.8) 2 2 (116.4 40.1) 3 4 (117.9 26) I want to put the latitude/longitude values into separate columns, so I do: library(sf) centres<- as.data.frame(st_coordinates(df)) This new 'centres' dataframe has the lat&long values, but misses the ID column. How can I preserve it, or is there another way to get the lat&long values into separate

sf: Write Lat/Long from geometry into separate column and keep ID column

最后都变了- 提交于 2020-12-02 10:36:09
问题 I have a df with polygon ID's from a shapefile and their centre-points in a geometry column: # A tibble: 3 x 2 ID geometry <dbl> <POINT [°]> 1 1 (117.2 31.8) 2 2 (116.4 40.1) 3 4 (117.9 26) I want to put the latitude/longitude values into separate columns, so I do: library(sf) centres<- as.data.frame(st_coordinates(df)) This new 'centres' dataframe has the lat&long values, but misses the ID column. How can I preserve it, or is there another way to get the lat&long values into separate