Questions tagged [sf]

us this tag when asking questions about sf R package (sf: Simple Features for R)

Filter by
Sorted by
Tagged with
2
votes
1answer
35 views

CRS validity and PROJ versions

I'm not sure where the right place to raise this is, so: The PROJ strings for EPSG codes 4151 and 4283 are identical: +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs which is a hassle ...
1
vote
1answer
24 views

Randomly sample existing points from within polygons in SF | R

I have a set of existing sf points and want to randomly sample 1 point from each of a 1km2 grid cell over a landscape. I can create a grid of 1km2 polygons, but I can't work out in sf how to then ...
1
vote
1answer
31 views

st_write fails for object created with st_difference using R?

Using publicly available sea area shapefiles bahamas: http://www.marineregions.org/gazetteer.php?p=details&id=8404 ("eez.zip") watl: http://www.marineregions.org/gazetteer.php?p=details&id=...
0
votes
0answers
26 views

Split lines in R creating 2 group ids [duplicate]

I would like to split a linestring into two features separated by a point. Here's what I mean: This is what I've tried so far in R using the sf package: Sample data library(sf) library(dplyr) # ...
0
votes
1answer
21 views

Finding datasets embedded in R GISTools package?

How can I find the embedded datasets in R package GISTools? I can find examples of datasets (Georgia, Newhaven etc.), but I cannot see exactly which datasets are available.
-1
votes
0answers
23 views

Finding centrelines from polygons in R sf

Has anyone found a solution for turning polygons into centrelines using R? It has to be in R as I'm deploying it in parallel on a UNIX cluster. I've got as far as: library(sf) centreline <- ...
2
votes
1answer
52 views

Banding appears when reprojecting shapefiles using R?

I have downloaded a shape file (Marine Ecoregions (last one on the page)) from the nature conservancy http://maps.tnc.org/gis_data.html I am then using R and the sf package to project this shapefile. ...
1
vote
0answers
78 views

How to divide LINESTRING spatial network into equal length segments using R/sf?

I'm working on a project to model car crashes within the municipality of Milan using different statistical methods. I have a big dataset of all geocoded car accidents that happenend within the ...
1
vote
0answers
17 views

How to recognize original group from unified set of polygons in R

I have simple question. How can I know the original group after apply z = sf::st_union(x, y)? I have 2 sets: length(x[[1]]) = 4253, length(y[[1]]) = 91. Finally, I have z of lenght 411 but don't know ...
1
vote
1answer
26 views

How to build polygons from buffered points and merge overlapping ones using R?

I have a sample of 3 groups of points which are similarly spread within their groups. > pts x y [1,] 453067.5 364073.5 [2,] 453066.5 364072.5 [3,] 453068.5 364072.5 [4,] ...
0
votes
0answers
25 views

Extract time series from NetCDF stars proxy object

I'm trying to extract a time series from a netCDF file opened as a stars_proxy object in R. Looking at the raster to stars mapping table, I should use the aggregate function. But I'm getting a CRS ...
1
vote
1answer
38 views

Using tmap for points in R?

I'm having a problem using tmaps to map out points in R. The data is taken from the Chicago data portal, and I was able to turn it into a sf object using the code below. However, when I try to use ...
0
votes
0answers
26 views

Using R for analysing relations between administrative borders (neighborhood of polygons) and voting results (or void votes)

What would be the relatively simple way to verify if there is a relationship between administrative borders (polygons) and voting results (like: void votes). This would be used to verify if voting ...
1
vote
1answer
42 views

sp::over vs sf::st_intersection in r

I was wondering why sf::st_intersection() takes too much time, in comparison with sp::over(); I use sf for pretty much all of my geospatial workflows (I was used to sp as well), and more and more ...
1
vote
1answer
55 views

Union, merge, intersection, join layers - logical difference and clear explanation for QGIS

I note that there are answers available on the difference between join and merge (e.g., Difference between 'join' and 'merge'?) that link to ArcGIS resources as a reference. However, I ...
0
votes
1answer
38 views

Use sf (R) to return the overlapping area between two polygons by rows?

I have two sfc data frames with the same number of rows (individual IDs), but each data frame contains a polygon assigned to the individual. For example, dataframe1 may have a circle assigned neared ...
1
vote
0answers
51 views

st_buffer() not preserving the shape of the original polygons [closed]

I am currently trying to create buffers of 5km around polygons of the region of interest. However, every time I increase the radius from 500 metres to 5000 metres, the shape of the buffer is not ...
1
vote
0answers
70 views

After installation of gdal (to enable PostGIS tools) on Windows, sf gives warnings about dependencies?

To get a PostgreSQL/PostGIS setup working on my Windows 10 machine I had to manually install GDAL using these instructions: https://sandbox.idre.ucla.edu/sandbox/tutorials/installing-gdal-for-windows ...
3
votes
1answer
67 views

Counting points in polygons with sf package of R? [closed]

I'm quite new to R and especially GIS with R. So recently I had to proceed to a quite simple analysis: counting health centers (points) per administrative unit (polygons). Quite common process in ...
0
votes
2answers
101 views

Dissolve only overlapping polygons in R using sf

I extracted information from open street map that contains many polygons, some of them overlapping. I want to union all polygons that overlap with other polygons. This question has been asked before ...
2
votes
2answers
35 views

st_transform producing spurious ribbons across region

I am trying to use st_transform on PERZONES shapefile available here . In its native projection, it looks like this: However, when I run the command: tansformedPF<-st_transform(PF,"+proj=sinu +...
1
vote
2answers
48 views

Create a circle in R, and plot it in a shapefile

I want to plot a circle with a radius of 5 miles around a hospital in Massachusetts. I was using some previous answers found here, but it is not working. st_buffer shows an error. library(sp) ...
3
votes
1answer
58 views

Same equal area projection results in different areas when shifting the center of projection

I found that using an equal area projection results in different areas for the same polygons if you shift the center of projection (ie to minimize the distortion of your area of interest when you ...
0
votes
1answer
38 views

Using st_read to create an owin in R

I have updated a program because readShapePoly has been replaced by st_read. Changing from: unzip(paste(mdir, "AU_Vic_POA_2011.zip", sep = "")) boundary.shp <- readShapePoly("...
1
vote
3answers
39 views

Errors fitting a Markvov Random Field GAM with multiple samples per Polygon

all, after reviewing this excellent tutorial, I'm trying to expand out my use of GAMs for space and time. I'm trying to use the Pennsylvania smoking and cancer data, but am running into a problem when ...
0
votes
1answer
54 views

Creating coordinate points based on polygon

I am trying to create coordinate points based on a polygon that I've created in Google Maps and imported into R as an sf object. Specifically I have sample points of physical samples I've taken, but ...
0
votes
2answers
31 views

How to save a plot to disc with tmap in R

I have made a plot with these lines mainland print(Bornhold, vp = viewport(x = 0.7, y = 0.5, width = 0.3, height = 0.2)) One is mainland and the other an island. How can I save it to one one png ...
0
votes
1answer
54 views

Using sf to combine polygons that share borders?

I have rows of respondents with their residential census tract polygon and am trying to generate first-order aggregated areas. Meaning I want a given respondent’s census tract polygon to be merged ...
1
vote
1answer
21 views

Avoiding/cleaning buffer artifacts in R

I'm trying to create a buffer around a multi-linestring object with st_buffer. Here's my initial attempt: library(rnaturalearth) library(dplyr) library(sf) library(rmapshaper) proj_sahel <- "+...
3
votes
1answer
79 views

Convert XYZ to stars curvilinear grid and plot

I have data in XYZ format (long, lat, elevation) that does not fit on a rectangular grid, but I would like to plot it as grid cells of different sizes. To illustrate what I mean, the last two plots ...
1
vote
2answers
130 views

Combining st_join with st_nn to include all points within, as well as within a given distance of a polygon

This is a follow up to my earlier question (Spatial join in R - Adding points to polygons with multiple corresponding points). I have successfully joined a spatial points file to a polygon file in R ...
0
votes
0answers
26 views

Aligning grid to polygon R sf

I am attempting to create a dataframe of point locations based on a polygon. Specifically, I am trying to estimate the locations of trees in an orchard. So I need regularly spaced points within this ...
1
vote
0answers
31 views

Problem of reversed coordinates (XY) when importing WFS data with st_read

This question was originally posted in StackOverflow. I am trying to use French spatial data distributed using WFS. I want to use these data in a Shiny app that allows the user to update the data, ...
0
votes
1answer
31 views

ArcGIS GeoPackage ArcMap Drawing Error [closed]

I am trying to understand the meaning of this error. I created spatial data using the sf package in R and wrote out the data as a GeoPackage (i.e. a .gpkg). However, whenever I add the data into ...
2
votes
1answer
54 views

Why does fasterize gives different output for multipolygons with and without internally resolved boundaries?

I was thrilled to be clued into the package fasterize, which speeds up the rasterization process in R tremendously. However, I cannot figure out why the fasterize() function outputs two different ...
0
votes
0answers
24 views

Convert DWG to Shapefile Using FME and R

I converted a DWG file to an ESRI Shapefile using FME Workbench. Now I wish to create an elevation raster. I'm not sure how to extract the elevation info. library(sp) library(raster) # https://www....
2
votes
1answer
37 views

Transform CRS of Shapefile in R

I started with an AutoCAD DWG file and used FME Workbench to extract elevation data into a shapefile. read_sf yields: > shapename Simple feature collection with 41620 features and 1 field (with ...
1
vote
1answer
34 views

Appending polygons in R using sf

I'm trying to create a multipolygon dataset where each row is identifiable. Example below library(sf) library(raster) # example raster data r <- brick(nl = 2, nrows = 5, ncols = 10) set.seed(54);...
1
vote
0answers
21 views

Set attribute length when exporting features with st_write

I have sf features that I have created/manipulated in R that I need to export to shapefile (my client only accepts shapefile format so I cannot use .gpkg or other formats). I have used st_write to ...
1
vote
0answers
70 views

Why shapefiles created with sf package (in R) do not display same CRS in ArcMap?

I have created a polygon shapefile in ArcMap using 7 points(lat,lon) then read this shapefile into R to obtain the CRS. I then created a shape file in R using the sf package (and the 7 points) and ...
2
votes
2answers
156 views

Is there a way to clip a layer with a shape from another layer in `sf`?

I would like to get the greens polygons that intersects (or overlapsed) the red outlined polygon (see image below). I tried sf::st_intersection() but the polygon in yellow (yes that just one polygon) ...
0
votes
1answer
24 views

Plotting Geographical Grid from Long/Lat Coordinates in R

I have a file of coordinates (Long/Lat) that should enable me to plot a series of 10km grid squares covering the UK. However, for each grid square I have five sets of coordinates by way of plotting ...
3
votes
1answer
57 views

gIntersection error: linearRing not created

I am trying to do something relatively simple but with large shapefiles. I have a shapefile of protected areas in the USA: and watershed boundaries: I want to calculate the percentage and ...
1
vote
1answer
147 views

R sf count number of Polygons in Multipolygon

How can I count the number of polygons that are present in a multipolygon with the R package sf? Example: In the following image that represents a multipolygon I count 3 polygons. I want to be able to ...
0
votes
1answer
17 views

Set same dimensions multipolygon and point data

I'm trying to plot point data (coördinates) on a multipolygoon map. But I can't get them on top of each other and in the right shape. Underlying projection data of the Netherlands multipolygon data: ...
2
votes
2answers
56 views

How do I combine geometries in a shapefile based on a grouping variable?

Here is a simple example. I have a shapefile of three US states: This is the code that creates the shapefile. library(USAboundaries) library(sf) library(dplyr) states <- us_states(map_date = "...
0
votes
1answer
77 views

Create polygons (representing boundaries) from lines

I received a file of municipality boundaries, where the boundaries are represented as lines. I would like to convert this to a set of polygons, each representing a municipality. In other words, from ...
1
vote
1answer
32 views

Why does this R code that maps points into polygons cause a segmentation fault?

As in this question/answer, I have a data frame of points (which also includes some necessary, non-coordinate data columns) and a shapefile. In this case the shapes are US states. The last line of the ...
0
votes
0answers
95 views

R sf package - link to GDAL

Is it possible to ask R {sf} package to use a GDAL installation I prefer? So far I found how to check external software it uses: library(sf) sf_extSoftVersion() # GEOS GDAL ...
3
votes
1answer
114 views

Writing a table (no geometry) to GeoPackage using R

I'm trying to do something so incredibly simple: write a table (with no geometry) to a GeoPackage. I can store tables in a GeoPackage using QGIS, so it stands to reason I'd be able to write one from R....