Questions tagged [r-sp]

An R package for spatial data. Questions on spatial data might be better asked on https://gis.stackexchange.com

691 questions
12
votes
4 answers

R measuring distance from a coastline

I have a set of coordinates: d1 <- data_frame( title = c("base1", "base2", "base3", "base4"), lat = c(57.3, 58.8, 47.2, 57.8, 65.4, 56.7, 53.3), long = c(0.4, 3.4, 3.5, 1.2, 1.5, 2.6, 2.7)) I would like to know whether the coordinates fall on land,…
Mrmoleje
  • 453
  • 1
  • 12
  • 35
12
votes
1 answer

Changing CRS of a SF object

I have some 'roads' as a sp object: class : SpatialLinesDataFrame features : 17360 extent : 490176.4, 567680.9, 148639.1, 212821 (xmin, xmax, ymin, ymax) coord. ref. : +init=epsg:27700 +proj=tmerc +lat_0=49 +lon_0=-2 …
TheRealJimShady
  • 777
  • 3
  • 9
  • 24
9
votes
1 answer

Improve speed/use of gDistance function by using parallel processing and/or plyr/dplyr?

I have a bunch of locations for each of about 1000 individuals. The total dataset used to be around 2.5 million and my processing script took about 20 hours to run. Now however, I have 24 million observations and figure I need to clean up my code…
Jordan
  • 614
  • 1
  • 7
  • 20
8
votes
3 answers

Improving positioning of map / polygon labels

This is an extension to Improve centering county names ggplot & maps and ggplot centered names on a map. It is not only a theoretical problem, I came across that particular case on answering How merge specific states together by group with one label…
tjebo
  • 21,977
  • 7
  • 58
  • 94
8
votes
3 answers

How to create animation of vehicle moving form A to B along a route?

below is an example of finding route, travel time and travel distance from 'One World Trade Center, NYC' to 'Madison Square Park, NYC' using osrm package in R. (I learnt it from Road Routing in R). The travel time here is 10.37 minutes. I wanted to…
SiH
  • 1,378
  • 4
  • 18
8
votes
2 answers

R: SpatialPointsDataFrame code no longer working. Error in !res[[1]] : invalid argument type

I have been following this workflow to convert coordinates from Eastings / Northings to Latitude / Longitude in R. Up until today it has been working fine. Here is a reproducible example: require(rgdal) # create test coordinates x <- 259269 y <-…
RWard
  • 93
  • 1
  • 5
8
votes
1 answer

"Globe"-shaped map of Russia

I draw a map of regions of Russia using GADM data: setwd("~/Desktop/Master thesis/") library(sp) library(RColorBrewer) library(raster) data <- getData('GADM', country='RUS', level=1) #exclude columns I don't need data <-…
MariaBee
  • 83
  • 3
8
votes
2 answers

R: How can I count how many points are in each cell of my grid?

I have made a reference grid, cells 50x50m, based on GPS locations of a collared animal. I want to do the equivalent to a spatial join in ArcGIS, and count the number of points in each cell. I have made a reference grid, using a…
Danica
  • 87
  • 1
  • 1
  • 6
8
votes
2 answers

Custom placement of spplot legend in the map

Is it possible to place the spplot (spplot polygons) legend within the map, in lower left corner, like this? The closest I've been able to get is this (I am not posting my data, I just use the example data instead, so in this case, try to place the…
Tomas
  • 57,621
  • 49
  • 238
  • 373
7
votes
1 answer

Comparing simple features {sf} and Spatial objects {sp}: speed and memory

I'm using some spatial data in R, and wondering whether use the packages/functions that rely on the old Spatial format (package sp) or the new package sf. I made this test, based on code found here. The idea is to "identify all points falling within…
Hugo
  • 357
  • 3
  • 10
7
votes
2 answers

Make a SpatialPointsDataFrame with sf the fast way

The task I'm trying to do is very simple with the sp package in R but I'm trying to learn sf hence my question. I'm trying to create a shape of points in R. I have lots of points so it has to be efficient. I've succeeded doing it in both sp and…
Bastien
  • 3,007
  • 20
  • 38
7
votes
1 answer

Equivalent of `poly.counts` to count lat/long pairs falling inside of polygons with the sf package

The sf package provides a great approach to working with geographic features, but I can't figure out a simple equivalent to the poly.counts function from GISTools package which desires sp objects. poly.counts computes the number of points from a…
7
votes
2 answers

OSM, rgeos, osmar, area calculation, does not add up

I am trying to get the size of a polygon from OSM, using osmar to download the data. However, sanity check tells me the are is not right. Below is an example of what I mean. (1) Geographical area around Hyde Park in London. Extracting all ways and…
Sylvia
  • 315
  • 2
  • 17
6
votes
2 answers

R - How do I draw a radius around a point and use that result to filter other points?

I am looking to draw a radius around a lat long point, then use that buffer to filter other points that fit within it. For example: #stores datasets stores = data.frame(store_id = 1:3, lat = c("40.7505","40.7502","40.6045"), …
LoF10
  • 1,907
  • 1
  • 23
  • 64
6
votes
3 answers

R - Fitting a grid over a City Map and inputting data into grid squares

I'm trying to place a grid over San Jose like this: Grid of San Jose You can make the grid visually using the following code: ca_cities = tigris::places(state = "CA") #using tigris package to get shape file of all CA cities sj =…
Albert Gehami
  • 63
  • 1
  • 4
1
2
3
45 46