Questions tagged [sp]

R package with classes and methods to create and manipulate spatial data

Filter by
Sorted by
Tagged with
-3
votes
0answers
18 views

Minimum distance from each polygon (964 polgons) to a set of points (100 points) in R

I have a number of polygons and points. I want to calculate the distance from each polygon to any of the points and determine the minimum. How can I do this in R for each polygon and point?
0
votes
0answers
22 views

R-ArcGIS Bridge - Interpolation with gstat library

I have a problem with the idw or krige function from the gstat library in R. I'm trying to use the gstat library and the R-ArcGIS bridge to load a shapefile from ArcGIS into R, interpolate the data ...
-1
votes
0answers
33 views

R: How to get coordinates information at un-sampling and unknown locations in an area?

I have an atmospheric sampling dataset from a certain area like this: Rows: 100 Columns: 4 $ Pressure <dbl> 976.4521, 976.1801, 976.3160, 975.6355, 975.7716, 975.... $ Temp <dbl&...
0
votes
1answer
33 views

Calculating area between two SpatialLines

I'm trying to calculate the area between two lines. The two lines have the same start and end location, but the number of vertices for each line can vary. I've tried to create a polygon from the ...
0
votes
0answers
13 views

How do you create a column computing area in SF with a SpatialPolygonDataFrame?

I am attempting to add a column that provides the area of my HUC_12 watershed polygons to a watershed data set, but the only code online that demonstrates how to do this is using the raster library, ...
0
votes
1answer
11 views

R when I reproject coastscoarse to Robinson using spTransform I get an unwanted horizontal extra line

When I run this code library(rworldmap) data("coastsCoarse") plot(coastsCoarse) RobinsonProj <- "+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs" ...
1
vote
1answer
25 views

How to save polygons generated from raster extents to shapefile in R

I'm looping through a list of rasters, getting the bounding box for each from raster@extent, and storing the matrices representing each polygon in a list. I'd ultimately like to save to shapefile ...
0
votes
0answers
37 views

One-to-many spatial join in R

I want to perform a spatial join (one-to-many relation) between two Spatial Dataframe layers in R. More specifically, I have a set of lines (SpatialLinesDataframe) that need to be joined to the ID of ...
0
votes
1answer
51 views

Converting a CSV to a shapefile in R : “Creating Name field failed”

I was trying to convert a CSV to a shapefile (process that I've already managed to do several times with R without particular problem) but today I'm facing a troublesome issue I haven't been able to ...
0
votes
1answer
38 views

sf: SpatialGridDataFrame vs SpatialPixelsDataFrame: Processing, Visualization and Storage

I'm trying to understand what are the differences between an SpatialGridDataFrame and SpatialPixelsDataFrame. My final goal is to process some raster (readed with raster package and tif format) and ...
1
vote
0answers
20 views

Extracting data from a SpatialPointsDataFrame into a SpatialPolygonsDataFrame in case some polygons have no overlapping spatial points

Data used in this post: Climate data (10') from the Climatic Research Unit, which I have changed into a SpatialPointsDataFrame https://crudata.uea.ac.uk/cru/data/hrg/tmc/ Shapefile from European NUTS ...
1
vote
0answers
27 views

Help spTransform CRS for use in leaflet

I am producing Kernal density estimates for animals from tracking data. Location is input at x y data, I produce a spatial polygons dataframe from these coordinates. xy<-id[c("X", "Y")] id<-id[...
2
votes
1answer
68 views

R spatial: st_overlaps to subset also fully covered polygons?

I want to subset all polygons in fc1 completely or partially overlapping with fc2. But, the st_overlaps subsets only polygons that overlaps with the border of fc2, but skips the fully covered polygons....
1
vote
1answer
38 views

Adding new polygon attribute column based on location withing another polygon in R

I have here an example with two layers - one containing two large polygons Pol_large, and second containing 4 small polygons Pol_small. For Pol_small I want now to find the location of each of the ...
7
votes
1answer
133 views

R spatial: Erase one polygon from another: correct use of `st_difference`?

I am trying to erase one shapefile from the other, similar to ArcGIS Erase tool: This worked pretty well with rgeos::gDifference(spdf1, spdf2), which needs as input geometry of ...
1
vote
1answer
28 views

Use geometry binary predicate list to subset simple feature object?

I am trying to create a new simple feature from two overlapping features. I want to subset all polygons that are fully or partially located within my buffer (red border). However, the st_overlaps ...
1
vote
1answer
26 views

Keep getting NAs when I run sp's over function on LatLon points on shapefile polygons

I am not sure why i am keep getting NA whenever I run the Over function with Latitude and Longitude point on the polygon from shapefile. Please note that this is first time for me doing the spatial ...
2
votes
1answer
32 views

Check if points overlap with polygon

I have data that maps lat lon of a storm for every day as follows (I have removed the day ID so it has only year and month) lat_lonDat <- structure(list(Latitude = c(9.1, 9.15755, 9.2, 9.21496, ...
2
votes
1answer
51 views

How do I reverse spplot colour key so the values are decreasing?

How do I reverse the colour key in a spplot so the that values are decreasing from the top to the bottom? Demo from https://edzer.github.io/sp/ below. require(sp) demo(meuse, ask = FALSE, echo = ...
1
vote
2answers
59 views

Maintaining coordinates when converting SpatialPolygonsDataFrame to simple feature in R

I am ultimately trying to determine the area of a home range, but I need to remove areas that overlap land. To accomplish this, I have calculated and plotted my home range, and want to use one polygon ...
1
vote
0answers
24 views

Extracting SpatialPolygonsDataFrame attributes into a dataframe in R. Assigning new vars based on other polygon in R

Here you can see a group of small and large polygons. Small polygons are cropped as I am only interested in their properties, such as size inside the large polygons. I have two furhter objectives ...
2
votes
0answers
62 views

Not all points overlain on raster map are showing up with R

Using R, I loaded a raster file (.tif) and overlaid points on the map. I have 46 points but only about half of them appear on the map. I can't figure out why other points are not showing up. Here are ...
3
votes
1answer
161 views

How to add labels to points in elevation plot in R?

I am a complete noob at using GIS in R and have been trying many packages and functions but get stuck each time. What I want is to generate an elevation map for a location in the Himalayas with ...
1
vote
0answers
22 views

Can poly2nb() or nb2listw() be made time-sensitive?

I was wondering if there is a way to make the poly2nb() or nb2listw() temporally sensitive. For example, let's say we have a spatialobject that tracks a set of polygons for 2019 and 2020. Some of the ...
1
vote
1answer
45 views

Calculating density within a shapefile (in R)

I'm trying to calculate density within a shapefile, but I'm fairly confident I'm doing it wrong. The idea is to figure out which geographical regions there have been the most sales by density. Here ...
1
vote
0answers
32 views

Replicated Point Pattern: Get Density Variance Between Replicated Patterns and Subtract from Composite

I have written a lengthy code that dissects differently shaped/sized windows into recognizable components (individual cells in the image), gets the point density within each cell, then builds a whole ...
1
vote
1answer
249 views

Weighted kernel density estimate mapping in R

I am trying to reproduce ArcGIS' kernel density in R. Specifically, I'd like to make a weighted kernel density map, like you see in Census OnTheMap (example). I am running into a lot of dead ends, ...
1
vote
1answer
37 views

spTransform cutting off part of ROI in stereographic projection

I'd like to have a map of land above 50N in the stereographic projection. I use the following code but as you can see, some land is cut out. proj<- "+proj=stere +lat_0=90 +lat_ts=71 +lon_0=0 ...
2
votes
1answer
264 views

calculate distance of points from centroid

I have a spatialpoints object, and a spatialpolygonsdataframe, composed of rectangular cells, and which the spatialpoints fall into. What I would like is to determine which polygon in the ...
1
vote
1answer
40 views

ggplot2lend for sf-objects

I wanted to make a simple plot of four sf-objects which don't contain much more than the sfc-column and some postal-code information. The sf-objects have the names level 1-4 and plz. What I would ...
0
votes
0answers
41 views

Creating a pattern with certain parameters [R, spatstat, spatial, sf]

Let's say I want to create a pattern, that is based on numerous other patterns with similar shaped areas. Other than an average of the point densities in the rectangles, is there other patterning ...
1
vote
0answers
92 views

Unknown proj4: how to create custom proj4 from wkt?

I have a shapefile with a .prj file I've never seen before. In fact, it seems that GDAL doesn't even know what it is (see below). Therefore, when I read it into R with raster::shapefile() the CRS isn'...
1
vote
1answer
13 views

DSpat::create.lines and spatstat::rlinegrid: Adding too many lines?

Does anybody know of an issue with either DSpat's create.lines or spatstat's rlinegrid? Whenever I use these functions on my Windows (owins), the output has far too many lines. For example, if I run ...
1
vote
1answer
55 views

Connecting spatiallines or SpatialPoints based on minimum distance using R

Does anybody know of a way to create a single polygon (that will eventually be converted to an Owin) from either a spatialpoints object or a spatiallines object? Here is an example of each: Here's ...
2
votes
1answer
33 views

Aligning Multiple Polygons (Based on centroid possibly) [Spatstat, sf, sp]

I'm trying to create a composite/average of multiple similarly shaped polygons. I think the first step is most likely to align them via the centroid of each polygon. Does anybody know of a tool to ...
1
vote
1answer
126 views

spplot doesn´t work - sppanel error

I have this code (below) for plotting some information in a map, but it doesn't work, in the map appear only the error "sppanel", why I solve that? library(GWmodel) library(RColorBrewer) data(...
1
vote
1answer
99 views

String column in QGIS shapefile that is read as a factor column in R

I have a shapefile that has 3 columns (ID_1, NAME_1 and Rainfall). The 2nd column contains the names of governorates (type of variable is string). I have used the sf package in R to read this ...
2
votes
1answer
77 views

Spliting a polyline object by line ID based on @data values

I am trying split a SpatialLinesDataFrame by attributes I merged into @data I extracted a list of line ID's associated with a points data frame and aggregated them by category and line ID in dplyr # ...
1
vote
1answer
46 views

Exracting data fromSpatialPolygonDataFrame conditionally in R?

For some research I am working on, I have a dataframe called charters of charter schools in New Jersey. Simplified it looks like this: school.name school.id district.id lat ...
1
vote
0answers
36 views

Speeding up spatial subsetting in R?

I need to subset a global fishing dataset to just have the fishing in the Pacific. Right now I have a shapefile of the Pacific and I am using the sp method of subsetting (see below) oceans <- ...
1
vote
1answer
68 views

Generating pattern in each of set of polygons using sp (r)?

I have an object of class SpatialPolygonsDataFrame, and for each polygon in the dataframe I have a number of points I would like to generate in that polygon (e.g. I have 130 polygons, and I have a ...
2
votes
1answer
304 views

R (spatstat, sp, sf): Grid a single polygon, divide, alphanumeric labels based on column/row

I am trying to take a polygon and add grid lines over top, then divide the polygon into many polygons based on the grids. I've accomplished this through st_make_grid() and raster::intersect(). The ...
1
vote
0answers
100 views

ggplot with island (“Alaska problem”)

The data for this example can be found here: https://github.com/davidbaniadam/maps The problem is essentially the same with Alaska and mainland USA, i.e. I want the size of Alaska to be correct in ...
2
votes
1answer
274 views

Spatial 1 to 1 join by proximity in sf and R?

I'm trying to join a Simple Feature of POINT geometry type to another Simple Feature of POLYGON geometry type using st_join and nngeo::st_nn as the person asking this other question also did. The ...
2
votes
0answers
101 views

Union anti-meridian “multipolygons” after re-centering world map

My goal is to create a world map (using ggplot2) with a Pacific perspective. I have managed to re-center the map, by following this solution. Code below: # world country layer sppolys <-...
2
votes
1answer
50 views

Get shortest/fastest path between two points from SpatialLines(DataFrame)

I have a large rivernetwork as a SpatialLines(DataFrame) and want to subset it so I get a SpatialLine with only the shortest/fastest path between two SpatialPoints(DataFrame) which propably need to be ...
1
vote
2answers
90 views

Adequate proj4string for ETRS89

I am currently working with spatial data in R using sp When I used WGS84-referenced coordinates, I used to specify it by setting the proj4string to: +proj=utm +zone=18 +datum=WGS84 +units=m +no_defs +...
1
vote
1answer
269 views

Keep spatial lines intersecting spatial polygons using R?

I am trying to keep spatial Lines objects intersecting a spatial polygon in R. The intersect function from raster package is doing actually a crop. But what I need is to keep the lines intersecting a ...
1
vote
1answer
121 views

Remove polygons having less than 4 coordinates in R

I have a multiPolygon shapefile of buildings in a particular city. I read it in with readOGR and and transform it to my desired planar projection with the following code: buildings_data<-readOGR("...
0
votes
0answers
37 views

How to correct border between 2 polygons in R? [duplicate]

What algorithm to use to correct (average) the borderline between 2 polygons? All I know is that they have their own borderlines very close to each other. Sometimes they may overlap, otherwise not. ...

1
2 3 4 5