All Questions
80
questions
0
votes
1
answer
20
views
How to group aggregate data based of latitude and longitude
I have 2 dataframes in R that both have this type of structure:
Lon
Lat
Measurement
5
7
15
5
8
20
The numbers in the actual dataframes are different from this example but I don't think that should ...
2
votes
1
answer
34
views
Coalescing two `POINT` columns gives a list-column instead of another `POINT` column
I have two tibbles, each with a geometry column. I want to merge those and make a sort of coalesce() but if I combine ifelse() with st_is_empty() I end up with a list column instead of a POINT column:
...
1
vote
1
answer
37
views
I would like to identify the primary administrative unit from the latitude and longitude coded in the dataset
I want to identify the primary administrative unit from the latitude and longitude coded in the dataset, and fill that administrative unit with red
What I tried:
library(rnaturalearth)
library(sf)
...
3
votes
1
answer
73
views
Trying to create continent map for South America but geom_polygon produces zigzag fill
I try to do this ggplot:
library (sf)
library(dplyr)
library(ggplot2)
continents.f.xy <- st_zm(continents.f)
continents_map_SA <- continents.f.xy%>%
dplyr::bind_rows() %>% #bind the ...
0
votes
1
answer
78
views
How to match the coordinates of 2 shapefiles in R
I have 2 shapefiles, one of them has the coordinates of administrative units as a multipolygon, and the other has the coordinates of various sections of a border wall as a multilinestring. I am trying ...
2
votes
1
answer
77
views
How to show both colors at a border using geom_sf?
I'm creating a map with two layers- a heatmap (geom_tile) with biome data and layering a map of the different regions on top. I've got a list countries in each region and I got R to display a map with ...
2
votes
1
answer
179
views
Same code (using R's dplyr, stringr, and sf) produces different results when using different package versions
I am trying to run the same R code using computers that different versions of packages, but in one of them the code works and in the other it produces an error.
Specifically, I downloaded files from ...
3
votes
1
answer
605
views
dplyr::filter on sf object: Error in `vec_size()`: ! `x` must be a vector, not a <sfc_POLYGON/sfc> object
I loaded and filtered a geojson file (https://downtownrecovery.com/downtowns-original.geojson) using the code
library(dplyr); library(geojsonsf)
orig <- geojson_sf("downtowns-original.geojson&...
1
vote
0
answers
65
views
Limit or conditionally modify longitude values in st_buffer
I have a series of lines with endpoints at 180 degrees longitude. When buffering using st_buffer the buffers extend beyond the 180 degree threshold creating non-sensical polygons. I'd like to use the ...
2
votes
1
answer
135
views
How to sample from a spatial grid based on weights?
I am running some simulations, and want to generate spatially-autocorrelated data. May be going about this completely the wrong way...
First, I have generated a dataset of observations, with the ...
2
votes
0
answers
105
views
Using long legend name in scale_fill_gradientn cause legend box to be off-centered, and more when use with cowplot functions ggdraw and draw_plot
I wonder how could I fix the position of my legend box in the bottom-middle of my map, specifically when I using inset plot with cowplot functions. I tried various ways but it didn’t work. Would ...
0
votes
1
answer
365
views
How to use fill aesthetic in geom_sf only for filtered values while ‘excluded’ and ‘NA’ values both presented on map with other colours
I want to use Spectral palette from RColorBrewer only for AREA greater than 0.1, but I also wanted to show AREA less than 0.1 with let’s say dark grey or even better with hatched. In addition to this, ...
0
votes
1
answer
60
views
How to use shiny reactive functions for plotting an sf object that mapped a numeric column based on its quantiles
I am trying to use select input that filters the data based on a categorical column, income_grp in my example, and then use geom_sf to draw a map of a numerical column like pop_est with color ...
0
votes
1
answer
59
views
Shiny for choropleth map with two selection lists
I have df, and I wanted to create a shiny application that gets updated based on the value of two selection lists, one for picking an indicator, and the other for choosing the subgroup. I also create ...
2
votes
0
answers
270
views
Find shortest walking route that gets me within 100m of all points within polygon
I regularly need to devise the shortest walking route that gets me within 100m of all points in a polygon. I normally draw the walking route on a map. But I'm wondering if I can get R to devise the ...