Questions tagged [sf]

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

Filter by
Sorted by
Tagged with
1 vote
1 answer
15 views

Which point lies on which linestring?

Using the {sf} package, I have two sf objects: one containing linestrings (edges), which form a linear network; one containing points, which are restricted to lie on the network. My goal ist to ...
user avatar
  • 113
0 votes
0 answers
10 views

Raster intersect is duplicating polygons

I am using a raster intersect to intersect two spatialpolygonsdataframes. One is a moose home range and the other is a SPDF containing wetlands. However, when I intersect them, the total number of ...
user avatar
  • 1
0 votes
0 answers
21 views

Segmenting transect lines using st_segmentize on R

I'm currently working on R for spatial analysis and trying to segment transect lines (shapefile) by 4km using sf::st_segmentize. I managed to do this following the instructions from here and here for ...
user avatar
  • 11
0 votes
1 answer
20 views

Error message with Krige function: Error in as.character.default(X[[i]], ...) : no method for coercing this S4 class to a vector

I am trying to run the Krige function but I keep receiving NA values for var1.pred and var1.var. After using the warning() command, it says: Error in as.character.default(X[[i]], ...) : no method for ...
user avatar
  • 1
0 votes
0 answers
27 views

using as.polygons() with patches() from terra instead of rasterToPolygons() with clump() from raster

I am trying to figure out the equivalent of contour_poly <- rasterToPolygons(clump(my_raster > 1), dissolve = TRUE) from raster to terra. I tried contour_poly <- as.polygons(patches(...
user avatar
1 vote
1 answer
55 views

Create sf polygon from sf linestring and bounding box

I want to create a polygon using a linestring within the sf universe. I am generating a map of a coastline and I want the area that is water to be blue and the area that is land to be tan. Because ...
user avatar
  • 2,008
0 votes
0 answers
28 views

R arc.write error

I am getting the following error while writing an sf object dataframe to a GDB. The dataframe imported is a feature class from a GDB brought in via the sf package. After some data manipulation I am ...
user avatar
0 votes
1 answer
29 views

R Distance from Point to Line: Negative if within shape

I'm working with Brazilian deforestation data - specifically two sf objects: A point shapefile on environmental fines (centroid of land plots that have been fined for deforestation). A polygon of (...
user avatar
  • 19
0 votes
1 answer
26 views

sf: Session aborts when reading large geopackage into R

I want to read a geopackage into R that is roughly ~ 600 mb in size. Every time I want to read it my R-Studio session aborts when doing the data = read_sf(path_geo) Is there any "trick" ...
user avatar
  • 657
1 vote
1 answer
20 views

Tessellation will not display quadrat totals when plotted (spatstat, R)

I have tessellated an image, and am trying to plot the number of quadrats that appear in each tessellated region. I have two problems here: My tessellated image will not plot with my gw_ppp points, ...
user avatar
2 votes
2 answers
33 views

exact_extract Coverage area wrong fcoverage fraction

I'm using R to extract the values from a raster into a polygon. It works fine for most of them, but I found this small polygon (which is smaller than the cells) where it is giving me some misleading ...
user avatar
1 vote
1 answer
23 views

Is there a way to select nearest feature to a point by selected column?

I'm using crs= 2263. I have two datasets, buildings and 311. I would like to see what is the closest building to each 311 complaint. st_nearest_feature(311, Buildings) I believe this works but it ...
user avatar
  • 193
1 vote
1 answer
41 views

Warnings() in functions sf package

I'm running the code below and I get several "warnings". I used the sf_use_s2(FALSE) function to work with plane coordinates following the old way of the 'sf' package but even so I keep ...
user avatar
1 vote
1 answer
64 views

Rasterizing and resampling a vector object using stars::st_rasterize() and terra::rast() loses values/data

I am currently struggling with rasterizing and later, resampling a vector object using functions from stars and terra. Let's start with the example dataset here: https://drive.google.com/drive/u/2/...
user avatar
  • 1,282
1 vote
1 answer
34 views

Comparing polygon areas across simple feature collections

I currently have three simple feature objects created from different shapefiles in R using the sf package. These three objects have all been projected to the same coordinate system using st_transform()...
user avatar
  • 1,282
1 vote
0 answers
29 views

Reprojecting raster or vector CRS and extracting raster values based on vector boundaries

I am working with a EUR-11 CORDEX dataset of daily temperature values (nc file) from ESGF database and EUROSTAT NUTS data (from here: https://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/...
user avatar
  • 11
0 votes
1 answer
42 views

Rasterise sf Polygon and Assign Cell Value based on Total Area Deforested

I'm a relatively new to working with spatial data in R. I'm working with Deforestation data (EPSG: 5880) for the Brazilian Amazon - consisting of 70,000 polygons of deforested land that covers all of ...
user avatar
  • 19
0 votes
2 answers
76 views

sf::st_read() and terra::vect() reading in different extents from the same shapefile

I am currently working with multiple shapefiles in R and working towards rasterizing them using a combination of functions from sf,terra and stars. However, I noticed while reading in a shapefile that ...
user avatar
  • 1,282
0 votes
1 answer
36 views

Extract a network from spatstat to graph object in igraph using R

I am looking for an efficient way to transfer a linear network (class linnet) from spatstat, e. g. library(spatstat); data('chicago'); net <- spatstat.linnet::domain.lpp(chicago) to a 'graph' ...
user avatar
  • 113
1 vote
2 answers
34 views

Calculate sum/average of variable within each group of neighboring counties using R

I am trying to calculate the sum and/or average value of a variable for each group of neighboring counties in the US. I realized this needs at least two steps: For every county, find the set of ...
user avatar
0 votes
0 answers
40 views

Error when trying to mask raster to shapefile after interpolation using R - "sp supports Z dimension only for POINT and MULTIPOINT"

I am trying to mask an interpolated raster to a shapefile with the same coordinate reference system using R, but I keep getting an error. The error is shown below. How can I overcome this error and ...
user avatar
0 votes
0 answers
26 views

Creating a raster that displays the distance from developed areas using R

I am working with raster categorical data, and I am tasked with computing the distances from developed areas in R. The raster I am working with can be downloaded here. This raster has land use ...
user avatar
1 vote
2 answers
45 views

Using R, how can I find the average slope of a raster with land use area information?

I am new to GIS in R. I have two input rasters (an elevation DEM and a land use classified raster), and I am tasked with reprojecting, aggregating into courser resolution, and finally calculating the ...
user avatar
1 vote
1 answer
53 views

How to subset columns based on row values in R?

I have extracted ERA5 temperature data for specific points that contain the day of the year when the temperature exceeds 10 degrees celsius. And now I want to see how the temperature develops ...
user avatar
  • 772
0 votes
0 answers
59 views

Sample points from outside sf polygon object r

I am looking for a method, that allows me to select points that lie outside all features in an sf multipolygon object. In total I need 10,000 sample points. I am looking for suggestions that adhere to ...
user avatar
  • 395
1 vote
1 answer
43 views

Kriging with gstat package in R produces empty interpolation points

I have kriged a dataset with the gstat package in R, but it has produced an empty variable as a result. I have 1,167 measurement points within a field, and I am trying to interpolate them across 3,464 ...
user avatar
  • 453
1 vote
0 answers
51 views

sf multipolygon to elevation raster [closed]

I am trying to create some shadowmaps of the NYC skyline using the shapefiles found here: shapefiles of NYC buildings. I can import them after unbundling the gdb folders. What I have trouble with is ...
user avatar
  • 129
4 votes
1 answer
62 views

Clipping polygon based on a line to get a polygon in R

I would like to clip a polygon on the right-hand side of a line i.e. the portion of the polygon to the east of the line such that the result is a polygon. I have tried functions such as sf::...
user avatar
1 vote
1 answer
18 views

load gdb directory into R using simple features package

I am trying to work in R with the NYC 3D building models, specifically http://maps.nyc.gov/download/3dmodel/DA_WISE_Multipatch.zip. This is the package I use: > library(sf) Linking to GEOS 3.9.1, ...
user avatar
  • 129
0 votes
1 answer
19 views

R sf polygon only showing 3 corners

I'm trying to make a polygon over a chunk of North America. I try to make this 4 cornered polygon NAbounds<-st_multipoint(c(st_point(c(-103.58,28.9)), #SW st_point(c(-67....
user avatar
1 vote
0 answers
47 views

Seeking sf equivalent of QGIS Extract Vertices

If there is an equivalent function in the sf library for QGIS Vector Geometry tool Extract Vertices, what is it? Essentially st_cast(), but would incorporate node/vertex index, part, part index, ...
user avatar
  • 46
1 vote
1 answer
58 views

Non overlapping buffers/morphological tessellation for polygons in sf

I am trying to replicate the tessellation functionality from the momepy package (see source code here, lines 61 to 550) in R, using sf. This is basically a kind of mixture between a buffer and a ...
user avatar
  • 115
2 votes
1 answer
66 views

Why is sf() struggling to run plots quickly on UK datasets?

Problem: When I load in any of the shapefile datasets from Census data explorer plots are brutally slow. I suspect this is an issue specific to running R / RStudio on MacOS. For replication: require(...
user avatar
1 vote
1 answer
40 views

Making a cosmetic mask for an Arctic projection in R using sf

I'm making a fairly detailed map of the northern high latitudes that I want to show with an Arctic projection. I'd like to have a map that has a transparent circle from 50N to 90N as a mask for the ...
user avatar
3 votes
1 answer
52 views

How to loop st_transform

I have several sf files that have different CRS. Normally I would use the following code and "copy paste" it several times for each file. st_geometry(Zonas) = st_transform(st_geometry(Zonas),...
user avatar
0 votes
1 answer
51 views

GIS geometric operations in R

I have a question question regarding geometric operations in R. In the code below, I download spatial files on municipalities (lau_2011) and borderlines of nuts0 regions (nuts_bn). I later change the ...
user avatar
2 votes
1 answer
61 views

R sf: when should one run computations on the plane (R2) or on the sphere (S2?)

When should I use S2 computations on the sphere versus project my data and use R2 computations on the plane? Starting with version 1.0, package sf uses now the s2 package to handle unprojected/...
user avatar
  • 1,693
0 votes
1 answer
26 views

My R package doesn't use `raster` or `sp` but these seem to be loaded when I roxygenize it

I have refactored my package to remove any trace of raster to replace it with the newer, faster terra package. Here is the list of functions and packages I now import as listed in my package's ...
user avatar
0 votes
1 answer
50 views

Read shapefile for st_within in sf

I'm trying to use st_within to find points within a polygon, but I can't get a shapefile into the right format. I'm using the standard shp file JPN_adm1.shp from https://purl.stanford.edu/np872wp5062 ...
user avatar
  • 115
1 vote
2 answers
47 views

Is there an equivalent of "isLonLat" function in terra package in R?

I am refactoring my code which extensively relied on raster package to now use the newer and better terra package. I was making use of the isLonLat() function that returns TRUE if the crs of a raster ...
user avatar
0 votes
0 answers
36 views

How to do st_intersection in PostGIS using R

I have a large polygon file in the form of .gdb (mygdb, ~10gb) and I need to crop it using another polygon shapefile (myshp, ~10mb). I want to do this PostGIS database using R so that it will be ...
user avatar
  • 393
1 vote
0 answers
36 views

Topolgy vs simple features

I'm starting using PostGIS, and then I found the main extensions of it, Simple Features (postgis), Topology (postgis_topology), Rasters(postgis_raster). The Topology extension is great, in some ...
user avatar
  • 21
0 votes
1 answer
122 views

st_read fails to read from database

I need to read multi-polygon data stored in PostGIS database into R. Having successfully established the connection (let's say con), I tried to read using sf::st_read and dbi::dbGetQuery using dbi::...
user avatar
  • 393
0 votes
1 answer
35 views

Merging two multipolygon shapefiles and removing one of overlapping polygons using R

I have two shapefiles of digitized wildfires. Each shapefile has many polygons representing different fires. Each shapefile has an attribute field to denote the year of the fire. One shapefile covers ...
user avatar
  • 165
0 votes
0 answers
44 views

Plot labels for spatial lines in parallel to them in R

So I have this shapefile filled with spatial lines, https://www.dropbox.com/s/6o9gtfjesvqz696/vias%20pecuarias%20andalucia.zip?dl=0 and this with polygons https://www.dropbox.com/s/olbje6ljh26pvwx/...
user avatar
0 votes
0 answers
24 views

Discrepancies in size of area for Brownian bridge model

I want to get the size of some animal tracks using a Brownian bridge movement model. However, I've noticed that when I combine my data into a single object the size of the area differs compared to ...
user avatar
  • 41
2 votes
0 answers
69 views

Aggregate interpolated data at county level with R

The raw data is at the state level and I would like to go down to the county level. To do this, I first adjusted the data to county level and then interpolated it. The raw data on state level looks ...
user avatar
1 vote
1 answer
44 views

Buffers clipped to features used to create them

I'm trying to create an sf object of polygons which are buffer regions clipped to the polygons used to create the buffers. Using st_difference returns an sf object with all combinations of both sf ...
user avatar
0 votes
0 answers
56 views

Converting complex depth contours to polygons in sf and R

I have a large dataset of depth contours downloaded from an open database. At the time of writing, these contours appear to contain the best available continuous depth model for my region of interest. ...
user avatar
  • 325
2 votes
1 answer
83 views

Counting points in polygon by time / attribute condition

I have two tables in different databases I cannot connect directly. Table A contains polygons of regions. Table B contains points with timestamps. I want to count the points in each polygon for a ...
user avatar
  • 24.6k

1
2 3 4 5
11