Questions tagged [sp]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
24 views

Preserving IDs when using gCentroid to find centroids of multiple polygons in R

This seems like it should be simple. I have multiple polygons contained in one shapefile, and I am using the gCentroid() function from rgeos to create a bunch of centroid points. The function has an ...
0
votes
0answers
23 views

Getting a rasterized object from irregular lat and long data

I have a dataframe (I've named it ozone2raster) with latitude and longitude points, and values for ozone concentration that I want to use for making a rasterized map. The dimensions of this dataframe ...
1
vote
1answer
29 views

Error in writeOGR when trying to export spatial polygons as shapefile in R

I am trying to export polygons that i have created for home range data but when i go to export them get this error message: Error in writeOGR(colkud95[1, ], ".", "colonyhomerange", ...
1
vote
1answer
25 views

Converting a SpatialPointsDataFrame into km units from m, in R

I read in a UTM shapefile to R using readOGR. I want to use the resulting SpatialPointsDataFrame to build a mesh in the INLA package, but I've been told that to help with numerical stability, I should ...
0
votes
1answer
35 views

Determining off to add scale bar and north arrow in spplot

I have a spplot in which I want to add north arrow and scale bar. bbox(dis) # dis is my shapefile, an sp object min max x -285706.6 1492871 y 2620690.6 4120742 I want to attach the ...
1
vote
2answers
33 views

Change projection of list of rasters in R

I am handed down some RData that contain a list of of raster stacks. The file structure is pretty challenging to manipulate. After doing load(), the data looks like this: [[1]] class : ...
0
votes
2answers
24 views

Trying to apply inlabru:::bru_fill_missing to a SpatialPointsDataFrame to fill in NAs

I'm struggling with a function from the inlabru R package, which could help me fill in the NAs in my data. According to the helpfile, I need: bru_fill_missing( data, where, values) data is a ...
4
votes
1answer
66 views

Fixing polygon with incorrectly defined hole in R

I've been given this polygon as a SpatialPolygons object from the sp package. It looks like there is a problem with how this was created, there is an unwanted line connecting the hole to the outer ...
5
votes
1answer
63 views

Unexpected buffer output

Using both R and QGIS I got unexpected output from the buffer function. I'm wondering if it has something to do with my coordinate reference system, USA Contiguous Albers Equal Area Conic, because the ...
0
votes
1answer
43 views

R packge sp to sf QGIS 3.14

I have several scripts written in R language with package "sp" for Qgis. However I am stuck in the old versions (2.18) because whenever I use this same package in current versions 3.14 the ...
0
votes
0answers
81 views

Interpolation of point data in R

I want to interpolate some daily point data. The ultimate goal is to receive something like a heat map/IDW map with some interpolation statistics like kriging/IDW. My data: Nr. : coordinates : ...
0
votes
0answers
12 views

Trying to Rotate Raster Map to Route Up and add Route

Firstly apologies as this is likely a simple answer but I'm new to GIS in R and the associated packages. This is a hobby project and I'm treating it as a learning experience. Anyway what I am trying ...
1
vote
1answer
28 views

Stats for forest cover change over 10 years in R

I am rather new to GIS and I don't know how to perform the following operation: [ R programming language] I am developing a project evaluating forest cover change over 10 years (2010-2020) for a ...
0
votes
2answers
50 views

Raster extent based on SpatialPolygonsDataFrame generating incorrect extent

I'm trying to rasterize data from Berlin's average price per parcel data. I've downloaded the shapefile from their data portal using an API with a function that generates an sf object, and then ...
0
votes
1answer
18 views

Plot points in spastat ppp object

I am new to spatstat package and I am trying to make a point patten map with a shape file and some case points. I was able to plot the shape file plot but I just don't know how to make the points on ...
2
votes
3answers
133 views

Creating smallest-circle covering polygon using R with sf

How can I create the smallest-possible circle which covers a polygon geometry using the sf (preferred) or sp packages in R? One reprex using GADM data: # Load packages library(sf) # Load Nigeria ...
2
votes
1answer
233 views

r sp::CRS() returns NA

I just updated R (from 4.0.2 to 4.0.3) and all my R packages (previously updated about a month ago), and got an error in a previously working workflow on raster objects. It seems that it comes from ...
0
votes
1answer
29 views

Applying function to each element of SpatialLinesDataFrame

How do I apply functions to each element of a SpatialLinesDataFrame, in particular using other data also stored as an attribute (e.g. coordinates or elevation per line vertex)? I've a number of ...
0
votes
1answer
41 views

Navigating an Object of class 'SpatialPolygonsDataFrame' to filter on Polygon Area

I have an Object of class 'SpatialPolygonsDataFrame' with the structure shown below. What's the secret to getting to the @area slot? Ultimately, I'm trying to filter this file so that I'm only left ...
0
votes
0answers
26 views

Some polygons failing to fill with color

I have several Spatial Polygon Data Frames I am adding successively to a plot in R 4.0.2. The polygons represent US States, National Forests, National Parks, and wildfire perimeters. While it probably ...
0
votes
0answers
31 views

How to tile and mosaic spatial vector data in R?

Processing large vector data requires a way to tile the input data and mosaic the output. The following example only targets the tile creation and final mosaic step. Tiling the data has the reason ...
0
votes
1answer
92 views

Finding overlapping polygons of two Spatial Polygon Data Frames using R

I am new to GIS and GIS in R. I have two Spatial Polygon Data Frames (spdf), one contains the marine ecoregions of the world (MEOW), the other one contains Exclusive Economic Zones (EEZ) of the world. ...
0
votes
0answers
14 views

ggplot gridded SpatialPolygonsDataFrame producing odd triangles and subsetting data based on point data

I have cross posted this on SO. Using the code below I can plot the following: This code is adapted from here As you can see there are few issues with the plot. I am struggling to Remove weird ...
1
vote
1answer
26 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
82 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
22 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
397 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
40 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
8 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
77 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
178 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
154 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
2answers
136 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
209 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
17 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
46 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
33 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
53 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 ...
8
votes
4answers
624 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
23 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 ...
7
votes
1answer
2k 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
55 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
68 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 ...
1
vote
1answer
251 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 ...
4
votes
1answer
744 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::...
2
votes
1answer
66 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
31 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
114 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
33 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
44 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 ...

1
2 3 4 5 6