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
1answer
53 views

Using sf to combine polygons that share border with a polygon, but dropping the central polygon? [closed]

I have rows of respondents within census polygons and am trying to generate first-order aggregated polygons, excluding the census unit a respondent resides in. Put another way, I want to combine ...
1
vote
1answer
59 views

R Error in sp::CRS(SRS_string = from$wkt): unused argument (SRS_string = from$wkt)

A previous script that I had is no longer working after the sf package major change. I am using sf 0.9.6 and raster 3.0.2. I have tried to modify my code but cannot run raster::extract(). My previous ...
2
votes
1answer
21 views

Pivot sf geometry column such that each row contains a single polygon

I am trying to calculate the average distance to all habitat patches within a landscape from a site point (sf object). To do this, I have polygonized my habitat raster (dissolving to get patches) and ...
0
votes
1answer
18 views

st_rasterize (template smaller than sf object)

I need to rasterize an sf object that at the end must have the same cell size and be on the same grid of a defined raster object "template", because, eventually, I want to merge them. The ...
1
vote
0answers
21 views

Finding which census tracts lie within a given shape?

I'm new to GIS in R, and I am trying to create a crosswalk that maps the communities drawn in these shapefiles to census tract shapefiles for Los Angeles County that I've gathered from the Tigris ...
1
vote
1answer
20 views

Working with .geo of GEE in R

I am doing something similar to a previous post on stack exchange regarding exporting data from GEE to csv. Once I have the .geo column, how do I work with it in R? I would like to create a shapefile ...
1
vote
1answer
20 views

Use mapview in function to open viewer, but also do other things afterwards

The question may sound a little strange, but what I want to do is the following: library(sp) library(sf) data(meuse) meuse = st_as_sf(meuse, coords = c("x", "y")) plotit = ...
1
vote
1answer
43 views

Making a for loop with st_intersections for multiple time-units in R

I have two sf & dataframe objects and I want to test intersections between their geometries based for different cycles of years. Basically I have a flood dataset that contains flood events and ...
0
votes
0answers
24 views

Making stars::st_rasterize equivalent to raster::raster using meuse.grid

I'm trying to learn my way around stars. Given the meuse.grid data, how can I make a stars object that has the same dimensions, extent, etc. as I can get from going from SpatialPointsDataFrame to ...
1
vote
0answers
33 views

Getting an sf boundary of a raster or stars object

I am trying to figure out the best approach to convert an raster or stars object into its boundary returned as an sf object. I think I have a pretty decent handle on how to do it with raster (shown ...
3
votes
2answers
84 views

Choosing projection for running polygon intersections at global scale (i.e, geodesic intersections)?

How do I choose a projection for intersecting two global polygon datasets in WGS-84 (4326), and get accurate estimates of their overlap area? I searched the internet for answers to this question, and ...
2
votes
1answer
23 views

Parallel process for spatial weights matrix production in R

I have an sf object pData that is rather large (300,000 polygons) and I am trying to produce spatial weights for each polygon: tilesNb=knn2nb(knearneigh(st_centroid(pData), k = 2)) tilesWeights=...
1
vote
0answers
45 views

Measuring distance from centroid to polygon's boundaries in R

I'm still new to raster and sf and I'm having some trouble getting a distance between a point and a polygon for every time period. I have a sf object with MULTIPOLYGONS that refers to flood episodes ...
0
votes
1answer
40 views

Reshape a shapefile wide to long in R

I have a shapefile (sf) object made up of polygons with polygon characteristics stored in a dataframe. This object is called tiles. Within the dataframe there are 12 variables indicating number of ...
1
vote
2answers
34 views

Importing GEE feature collection output as sf object in R

When you export a feature collection (as a CSV) from Google Earth Engine, the geometry information is stored in WKT format under the variable .geo. The general format for each cell in the vector .geo ...
0
votes
1answer
51 views

Test intersections with time indicators in R

I have a sf object with MULTIPOLYGONS that refers to flood episodes from 1800's onwards(https://data.gov.uk/dataset/16e32c53-35a6-4d54-a111-ca09031eaaaf/recorded-flood-outlines). Then I have another ...
1
vote
2answers
54 views

Converting a shapefile from decimal degrees to UTM (km) in R

The code that I have below seems like it works in converting my vector roads which is in decimal degrees into a UTM CRS so that I can more easily work on the data in kilometers rather than decimal ...
0
votes
0answers
24 views

Can't join coordinates to polygons represented by black icons in RStudio viewer

I'm using {sf} to import a GeoJSON file. What does the black icon represent? I'm trying to join coordinates to this object via st_join(ken_con_sf, join = st_within) and it seems to fail where ...
1
vote
0answers
43 views

Faulty spatial ref when writing geopackage from sf

I am using sf version 0.9-5 in R 3.6.1 in Windows, and am transforming an sf feature to the USA_Contiguous_Albers_Equal_Area_Conic projection that has ESRI authority 102003 and no EPSG code - I can ...
4
votes
2answers
84 views

Map two sf objects on one map with mapview

I have two sf objects, precincts and elemZones. I want to make a mapview object showing the boundaries of both sf objects, and I want to style each sf object differently. My code so far. library(sf) ...
1
vote
1answer
17 views

Match centroids from one dataset with polygons of another

I want to make a data frame showing which voting precincts are in each school zone. To do this, I want to see which precincts' center points are in which school zones. library(sf) precincts <- ...
2
votes
2answers
65 views

How to split network in equal piece line segments in R

I create a SpatialLines from x and y coordinates. I was wondering is there a way to pick 5, 10 or m number points on the network which are equal distance to each other at least (2:m-1) ones have equal ...
1
vote
0answers
89 views

Why use st_union after st_combine with sf?

The documentation of the st_union function of sf is not clear (for me!) on one point: what are the action and result of the function when applied to an sfc with a single feature, with the parameter ...
1
vote
0answers
24 views

Polygon st_union in sf drops some polygons from output

I have written the following code that downloads state boundaries and population data from the US Census and then recursively merges the least populated states with their least populated neighbors. ...
0
votes
0answers
27 views

How to make `st_join` stricter?

I used st_join() to combine t1 and t2. library(sf) j <- st_join( x = t1, y = t2 ) t1 represents voting precincts boundaries and t2, school zone boundaries. In some cases, the boundaries of t1 ...
1
vote
1answer
36 views

How to get rid of the transformation grid in st_transform?

I use the last versions of R -4.0.3- and sf -0.9.6- (thus relying on PROJ version 6.3.1). I want to transform a layer from one system of coordinates (EPSG:27572) to another (EPSG:2154). This can be ...
2
votes
1answer
31 views

ggplot sf not rounding x-axis coordinate ticks properly

I have an issue plotting an sf object in ETRS89 / UTM zone 32N. It is not displaying the x-axis coordinate ticks well. Instead of 8.649° it is displaying 8.6490000000000000001°. Also see the image ...
0
votes
0answers
24 views

Empty reply from server when downloading NLCD 2016 in R

I am trying to download the NLCD 2016 Land Cover Dataset in RStudio. The area I am trying to get data for is roughly that of New York State. The code I am using at this point is: library(FedData) ...
2
votes
1answer
68 views

Combining a feature collection of MULTILINESTRINGs into one closed polygon in R

I have a shapefile consisting of 262 rows of MULTILINESTRINGs. Combined this shapefile (the political boundary of the arctic region) wraps the world and I would like to check for a large set of ...
0
votes
1answer
55 views

Clip function in the sf package in R

I try to clip shape "a" with shape "b". The result should be a polygon with the attributes and borders of "a" but cliped on the extent of "b". Basically a ...
1
vote
1answer
34 views

Avoid a for loop in raster::extract(rst,shp)

I am working on R to extract the mean and maximum value of a raster within a 3 meter buffer of some buildings. For this, I have created a for loop that iterates iterates through each building to ...
0
votes
0answers
33 views

R terra and `Error in x@ptr$geometry(nlyrs) : could not find valid method`

i am using terra::raster 0.9-1 and, specifically terra::values and the xyz function in terra::rast, but i keep encountering the following Error in x@ptr$geometry(nlyrs) : could not find valid method &...
2
votes
1answer
87 views

Removing overlapping sf lines in R

I have sfc LINESTRING and I would like to remove overlapping lines. Object data was created from an algorithm that joins lines with minimum distance. Using unique will not remove the initial lines. ...
0
votes
0answers
20 views

Is there a way to plot Triangulated Irregular Networks (TIN) in R Jupyter notebooks?

I was wondering if it is possible to plot TINs (Triangulated Irregular Networks) in Jupyter plots (with R kernel)? I use R's sf package (in conjunction with PostGIS) and ggplot2 in Jupyter to plot ...
1
vote
1answer
68 views

Convert large stars object to sf object

My ultimate goal is to convert landcover raster (.tif) objects to an sf object representing the raster's grid and the original values of each cell within each geometry. I have been able to do this for ...
1
vote
2answers
82 views

Non-noded intersection issues from overlapping buffer objects

I am working with valid lat/lon point data, creating buffers, and trying to calculate overlapping areas from buffers and running into the not-so-rare error with non-noded intersections when using ...
4
votes
1answer
54 views

st_crop() follow latitudinal circle on polar projection

I am generating a polar projection with the rnaturalearth::ne_countries() dataset. Because I'm only interested in high-latitude regions, I want to crop the shape above a particular latitude. However, ...
1
vote
0answers
27 views

R: Find parallel line strings and keep only one

For a project I use OpenStreetMap road data. However, if multiple roads are parallel to each other (say within 30 meters), I only want to keep one line, not both. See this example where a part of the ...
0
votes
0answers
17 views

R: extract z-value from 3D Multipolygon

I have a dataset with multipolygons that have a z-value, meaning they are three-dimensional. I read the dataset with sf::st_read(), so my dataset is in simple features format. This is my polygon: ...
2
votes
1answer
91 views

Reproject using WKT for just the horizontal CRS

I'm trying to reproject LiDAR point clouds from California zone 2 (ftUS) using spTransform from sp R package to a metric CRS like EPSG 3857 (initial post here) and got non finite transformation ...
1
vote
1answer
76 views

“non finite transformation detected” using sp R

This is a part of a broader question already posted (Non finite transformation detected - lidR spTransform) but I am creating a new question for the sp related part of that. I'm trying to reproject ...
0
votes
1answer
27 views

R: ggplotting st_cast(“MULTILINESTRING”) lines: ends points connected to starts, undesirably, why?

I have the lat-lon positions of various individuals. When I plot multiple individuals at the same time, I see odd lines over land, and have been investigating why. It transpires that plotting ...
1
vote
0answers
55 views

Spatial Join a point layer to polygon layer using st_join in order to create a choropleth map using R

I have three spatial layers, 1 USA boundaries and 2 point layers for Arby's and Hardee's locations across USA. Goal of the assignment is to create 2 choropleth maps for density of these fast food ...
2
votes
1answer
116 views

Iterate st_intersection (sf) over factor levels

I wrote a code using sf objects in order to count the number of points per category within cells. The code works well, but I would like to iterate over factor levels. Here is a reproducible example : ...
1
vote
0answers
69 views

Faster st_is_within_distance for points to lines

I am looking for a fast way to run a st_is_within_distance (or equivalent) in R, to find all the lines (y) within a given distance of each point (x). (This would be an equivalent of ArcGIS's "...
2
votes
0answers
34 views

How to create a hexbin polygon over a world map with a geom_sf object in R?

I have global data with over 180,000 data points. For every pair of coordinates I have a value, and many times I have multiple values at the same coordinates (see example of the dataframe df). I want ...
2
votes
0answers
18 views

How to use sf:gdal_utils with extent option (-te)?

I want to build a Gdal VRT dataset with several bands and cropped to a specific region. For that, I'm using sf::gdal_utils but somehow I can't get the option -te to work. It either complains about an ...
1
vote
2answers
73 views

Save layers from a gdb as sf objects in a loop

I'm taking an R class and I have an assignment that I'm trying to figure out. Instructor wants us to save all layers in a gdb file as sf objects. He told us that we should use loops. I'm able to ...
2
votes
1answer
56 views

Using specific transformation in R sf::st_transform() to reproduce ESRI’s Project tool

I am reading in a CSV with latitude/longitude points (WGS 84, EPSG 4326), transforming into the NAD_1983_HARN_StatePlane_Maryland_FIPS_1900_Feet projection (WKID 2893) and saving as a feature class. I ...
1
vote
1answer
86 views

Buffer coastlines

I'm trying to generate a coastline buffer by using st_buffer() with data from the rnaturalearth library. However, when I create the buffer, it extends outside the realm of the projection, rather than ...

1
2 3 4 5
8