All Questions
204
questions
-1
votes
1
answer
72
views
Misaligned sf object in ggplot
I have two sf objects, which when plotting are slightly misaligned.
While initially the two objects have different CRS:
the first has: WGS 84
the second has: MGI / Austria GK East
I proceed, as ...
3
votes
1
answer
110
views
Is there a way to completely snap a linestring to polygon in R?
I have 2 SHP files, one with many linestrings (railroads) and one with many polygons (counties in the U.S.). There is no intersections between those two files at all. My goal is to snap the lines to ...
0
votes
1
answer
99
views
sf error: OGR error: cannot export to WKT
I'm having issues running sf on my computer (R version 4.3.3, linux ubuntu 22.04.4). When trying to import a shapefile using st_read(), I am faced with the following error and warning messages:
> ...
0
votes
3
answers
146
views
Import shapefile and join to coordinates to create spatial dataframe in R
Before maptools and rgdal were deprecated, I used this code to import a shapefile, centroids csv and commuting count data, to create a flow map using the code below (I removed the ggplot code for ...
0
votes
1
answer
63
views
How to preserve holes when combining contours into polygons via R?
Part of the workflow for my project requires creating contours from a raster. I am able to generate the contours using raster::rasterToContour and can convert to a polygon using the sf package in R, ...
1
vote
0
answers
119
views
How do I generate the correct volume contour from a raster using sf, spatialEco, and terra?
I am interested in using R packages spatialEco and terra to generate some kernel density estimates with data of varying weights so that I can export contour shapefiles for mapping. I'm currently ...
0
votes
1
answer
136
views
R filling in a matrix with values from spatial data
I have a matrix in R called “habitat” with latitude as the rownames and longitude as the column names. The cells are filled with NA right now. My end goal is to have the whole matrix filled with ...
0
votes
1
answer
108
views
How to transform a sf table to a stars cube with stars::st_as_stars function?
I want to transform a sf data.frame into a stars cube, and choose the dimensions.
But I don't succeed in using the function stars::st_as_stars properly and get what I want.
Why do I want to transform ...
1
vote
1
answer
595
views
Convert a vector grid created with sf::st_make_grid into a raster stack
I have a vector grid created with sf::st_make_grid() with several columns of
values. I would like to convert it to a raster stack, with each column of values becoming
a layer of the raster stack.
I ...
0
votes
1
answer
166
views
How to calculate near neighbours in sf object with polygon geometry in R?
I have polygon shape data for German postcodes. For those postcode polygon I like to calculate various nearest neighbour measures. I have seen that procedures working with the sp package (using ...
0
votes
1
answer
114
views
R Make choropleth map with Robinson projection
I'm trying to make a choropleth map with a Robinson projection, mapping means onto each country. But something in the projection goes very wrong.
Here's a reproducible example and excerpts of full ...
0
votes
1
answer
267
views
Converting list of dataframes into a sf object in R
I am trying to convert a list of sfc dataframes into a single sf object with geometry per row.
Somehow I managed to convert it to a sf dataframe but I have a weird sf object.
In the environment panel,...
3
votes
1
answer
105
views
Connect multiple polygons from the same shapefile
I want to connect ALL the states drew from a sample of states of USA with a thin line exactly how it is done in this post.
I did manage to draw some lines between some polygons but I did not manage to ...
0
votes
2
answers
175
views
how to automate combining multiple shapefiles and retain filename as column?
I have multiple point shapefiles, each containing two columns: "id" and "Measurement." The "id" column represents the unique identifier for each point, and these ...
2
votes
1
answer
1k
views
Add column into sf() dataframe in r?
I have an sf object as obtained from here.
extraWD <- "."
if (!file.exists(file.path(extraWD, "departement.zip"))) {
githubURL <- "https://github.com/statnmap/...