Questions tagged [sp]

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

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

Locating SpatialPoints on SpatialPixels using R

I have met this frustrating problem while using R doing some GIS operation. The problem is, I want to locate some spatial points (SpatialPointsDataFrame) on geographical grids (SpatialPixelsDataFrame)....
3
votes
1answer
26 views

Save Spatial Pixel Data Frame

I have met a small yet puzzling problem about saving and reading Spatial Pixel Data Frame. I created a raster with over 10 million grids (resolution = 25000). adm0 <- readOGR(dsn = path.expand(&...
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 = ...
0
votes
1answer
39 views

Problems with specifiying TM_fill when creating a map in R with TM_maps

For my research I am visualizing plastic contents in segments of water. After creating my segment (online, polygons in KML-file) I jointed it with my table with fieldworkdata with plastics per segment....
0
votes
0answers
19 views

Issues fitting Variogram Model in R

I have taken a shapefile from Open NYC Data and performed the following method. My end goal is to predict Taxi trip_duration at various points across the city of NYC in March at given time segments. I ...
0
votes
0answers
7 views

How to choose cell size for grid points to fill polygons in R?

I have a shapefile consisting of hundreds of polygons depicting building footprints in a city. I want to fill these polygons with grid points. I am doing this by making a grid of points and then ...
0
votes
0answers
34 views

Projection issue causing clipping issue in R, different proj4 strings

I am trying to clip a grid of points to a vector polygon layer in R, but am encountering an odd error I can't figure out. The goal is to get a new layer that has the grid points, but only as clusters ...
3
votes
1answer
72 views

Combining two shapefiles using common attribute

I have two shapefiles "sf1" and "sf2" for same area. "sf1" is population data for year 2015 and has 6 variables. "sf2" is population data for year 2010 and ...
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 ...
1
vote
1answer
97 views

Non finite transformation detected - lidR spTransform

I would like to re project the following laz file using lidR and spTransform from sp. The EPSG code is not defined but it seems to me that the CRS string is complete: tmp_laz <- readLAS("./...
0
votes
0answers
16 views

Are these sp files equal in terms of proj4string? Can I do some transformation of the proj4string?

summary(SCat_sp_E6) Object of class SpatialPolygonsDataFrame Coordinates: min max x -74.095072 -74.018988 y 4.647323 4.832934 Is projected: FALSE proj4string : [+proj=longlat +...
0
votes
1answer
31 views

R raster::shapefile() seems to overwrite ID when writing SpatialLinesDataFrame

I am creating a "nested" SpatialLinesDataFrame like so: lines.list <- list() id.vect <- c("A", "B", "C") for (lines.index in 1:3) { line.list <- ...
0
votes
1answer
23 views

Include ID in an spatial weight matrix R

I have a data frame like this one: dataSp <- read.table( text = ' ID LATITUDE LONGITUDE A -85 134 B 34 2 C 42 3 D 45 ...
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 ...
7
votes
3answers
269 views

sp::proj4string equivalent in the PROJ6 framework?

I am confused about the shift from PROJ4 to PROJ6 in the (relatively) recent versions of the spatial packages of R (and gdal for that matter). I used to use sp::proj4string() to get the projection ...
1
vote
0answers
20 views

R statspat package (or similar pkg) and convert back to spatial objects

I've been testing the waters and doing some basic overview on the statspat package. This is a complex package and would likely require some serious effort to jump in and then get familiar with the ...
6
votes
1answer
767 views

How should I handle CRS properly after the major change in PROJ library?

As explained here, the PROJ library has changed a lot and one should stop using proj.4 strings. To me it is not clear, what I should do instead. This answer explains, how I could deal with the problem ...
2
votes
1answer
54 views

Extract() increases sum of values?

I am using the Landscan grid to calculate the number people within Vietnamese communes. First I masked the data with the GADM boundary. Then I used extract() to calculate the population by commune and ...
1
vote
1answer
35 views

Understanding error in changing projection of SpatialPolygon (R)

I am encountering an error I don't understand. I want to change the projection of a SpatialPolygonsDataFrame from +longlat to Mollweide or Robinson. For this I am trying to use spTransform(), but it ...
0
votes
1answer
146 views

Issue with osrmIsochrone function in R

I have been using osrm package for a while and didn't ever come across this kind of issue before. It looks so weird and I have been trying to update package and reinstall R as well. But nothing is ...
3
votes
1answer
408 views

Why does updating `rgdal` package in R change output of `sp::CRS` (+towgs84=0,0,0)?

I am not a GIS expert, and this change caused quite some errors in our analysis. So my question is, why this was changed: From rgdal 1.4.8 to 1.5.16, the +towgs84=0,0,0 disappeard in the output of sp::...
1
vote
1answer
39 views

Spatial neighbors in ggplot2

I'm trying to make a space plot with ggplot() as indicated here, but I'm having trouble using the nb2lines() function. .shp files are here Error in if (!is.na(projargs) && !nzchar(projargs)) ...
1
vote
1answer
23 views

Unable to process multiple polygons using SpatialPolygons object

I have a list with 4 objects, each object is a data frame. The data frame is the coordinate matrix of each polygon. I would like calculate the total area of the 4 polygons and then draw the voronoi ...
1
vote
1answer
58 views

How to perform point to raster operation and plot it with raster of different spatial resolution in R?

I posted a question (please find the link below) regarding raster plots at stackoverflow but could not get the solution. Does anyone here has the solution? https://stackoverflow.com/questions/63209707/...
0
votes
0answers
26 views

Modify spatial lines according to the minimum distance between line coordinates in R

I have an output of getContourLines() from contoureR package. The data frame output was modified and some points in the contour path were removed according to some masks, due to that: the distance ...
0
votes
0answers
24 views

spplot of a vector of values

I merged the shape file of the Los Angeles county ("LA_shp") with a cross-section cvs containing a certain number of variables and their respective values for the different areas of the ...
0
votes
0answers
37 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 ...
0
votes
1answer
39 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
19 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
20 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
86 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
54 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 ...
1
vote
1answer
257 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
68 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
45 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
307 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
63 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 ...
8
votes
1answer
339 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
68 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
46 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
78 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
91 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
32 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
147 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
467 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
1answer
52 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
33 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
395 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
2 3 4 5 6