An R package for spatial data. Questions on spatial data might be better asked on https://gis.stackexchange.com
Questions tagged [r-sp]
691 questions
4
votes
1 answer
spTransform() in R warnings with PROJ
I'm in R v 4.0.4 - sp v 1.4-5, and rgdal 1.5-23. I'm loading a shapefile using the rgdal package and then trying to simply apply spTransform() but I'm getting a ridiculous set of warnings that I can't get rid of. Anyone have any insight on…

GrantRWHumphries
- 612
- 7
- 22
4
votes
1 answer
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 to plot this data using hexagonal grids onto a…

Leo Ohyama
- 887
- 1
- 9
- 26
4
votes
2 answers
Since update of sp package i get a warning by calling a sp::CRS definition
Since update of sp package i get a warning i did not get before:
1: In showSRID(uprojargs, format = "PROJ", multiline = "NO") :
Discarded ellps unknown in CRS definition: +proj=stere +lat_0=90 +lon_0=10 +k=0.93301270189 +x_0=0 +y_0=0 +R=6370040…

Andreas
- 397
- 4
- 18
- 37
4
votes
2 answers
How to preserve scale_fill_color from first plot using shapefiles in ggplot2
I need help with scale_fill_manual using a shapefile in ggplot2.
I have tried many thing and I am finally posting so hopefully someone
will be able to give me a hint.
I am basically ploting a shapefile and use scale_fill_manual to vizualise it
with…

Salvador
- 1,229
- 1
- 11
- 19
4
votes
2 answers
Converting data.frame to SpatialPolygonsDataFrame
Here is the data for reproducible purposes:
structure(list(countyfp10 = c(1, 1, 1, 1, 3, 3, 3, 3, 5, 5, 5,
5, 7, 7, 7, 7), id = c(7417, 7418, 7419, 7420, 7421, 7422, 7423,
7424, 7425, 7426, 7427, 7428, 7429, 7430, 7431, 7432), lat =…
user9302275
4
votes
1 answer
Fastest way to determine COUNTRY from millions of GPS coordinates [R]
I have millions of GPS coordinates and want to quickly add a column of the country of the coordinates.
My current method works but is extremely slow:
library(data.table)
#REPRODUCE DATA
data <- data.table(latitude=sample(seq(47,52,by=0.001),…

Neal Barsch
- 2,810
- 2
- 13
- 39
4
votes
1 answer
line connecting label text and point in tmap plot
i'm doing a tmap plot with a shape file, and i want to be plotting several points for which i have long-lat coordinates onto the shape file. i've got the plot working just fine, however there are too many points on the map, meaning that the label…

nikUoM
- 639
- 1
- 8
- 18
4
votes
2 answers
How to compute the greatest distance between a centroid and the edge of the polygon using the SF package?
I have a bunch of variously shaped and sized polygons with centroids. I want to calculate distance from each centroid to the furthest point of its respective polygon.
This question has been resolved here using the package::sp and…

John J.
- 1,450
- 1
- 13
- 28
4
votes
1 answer
How to get the coordinates of an intesected line with an outline - R
I have a shape that I upload form the internet. Based on its calculated centroid I would like to plot from it a 50-degree line and find the coordinates that he intersect with the outline. Any idea how can I do…

elyraz
- 473
- 5
- 18
4
votes
2 answers
Memory (RAM) issues using intersect from raster package
I have trouble getting the intersection between two large SpatialPolygonsDataFrame on R. My polygons data represent buildings and administrative boundaries, and I am trying to get the intersection polygons between them.
I understand that the…

A.Rogeau
- 41
- 3
4
votes
2 answers
R - SpatialPolygonsDataFrame from a list of SpatialPolygons
I´m looking for a way to create a SpatialPolygonsDataFrame from a list of SpatialPolygons?
In the following there´s an example of a list of Polygons from which a SpatialPolygonsDataFrame, containing all Polygons of the list, should be created.…

N'ya
- 347
- 3
- 13
4
votes
1 answer
Extract data without geometries from `sf` objects like in `sp@data`
Probably a very basic question but I found nothing in the documentation of Simple Features R package.
I'm looking for the native sf function to extract on the fly all the columns of an sf object without the geometries. Just like SP@data with sp…

Gilles San Martin
- 4,224
- 1
- 18
- 31
4
votes
1 answer
Simplifying polygons in rgeos and maintaining data in SpatialPolygonsDataFrame
Background
I'm interested in simplifying polygons with use of the gSimplify function available through the rgeos package.
Reproducible example
A reproducible example can be generated with use of the code below:
# Data sourcing…

Konrad
- 17,740
- 16
- 106
- 167
4
votes
1 answer
How to assign the data of a centroid (marker) to the voronoi/thiessen polygon it belongs to? (R)
In his article Kyle Walker showed a method to make Voronoi Polygons in Leaflet. He drew Voronoi polygons around each starbucks coffeehouse in Fort Worth by means of the following code:
library(leaflet); library(rgeos)
library(rgdal); …

Zigaar
- 45
- 6
4
votes
1 answer
Create hexagonal grid over city and associate with lon / lat points (in R)
I've been researching this for a while now but haven't come across any solution that fit my needs or that I can transform sufficiently to work in my case:
I have a large car sharing data set for multiple cities in which I have the charging demand…

Jonathan
- 148
- 1
- 10