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
3
votes
1 answer

spplot issue with legend range and colors distribution

I have problem with correct color range on my plot and legend. This is code which I use: data.ch4 <- read.csv2("v42_CH4_1970_TOT.txt",skip = 3,stringsAsFactors = FALSE, header = F) num_data <-…
Karmel
  • 115
  • 3
  • 10
3
votes
1 answer

How to add a scalebar to a single panel in spplot

I have a panel of eight maps from a RasterStack, and wish to add a 100km scale bar to the plot. I have used sp.layout within the spplot function to add SpatialLines objects on top of the rasters, and assumed that the same would be possible with…
Andrew
  • 516
  • 1
  • 6
  • 17
3
votes
0 answers

Inconsistent behavior of gOverlaps and gTouches when polygons intersect at a point

I have two examples of SpatialPolygons (from package sp) that intersect at a single point. According to the help pages for gOverlaps and gTouches (from package rgeos), in this situation gOverlaps should return FALSE and gTouches should return TRUE.…
Cameron Bieganek
  • 7,208
  • 1
  • 23
  • 40
3
votes
1 answer

spsample: Error in .local(x, n, type, ...) : iteration did not converge; try enlarging argument iter

I am running into this error when running random point generation over a loop. spsample works fine if I generate points just once, but if I try this repeatedly I end up (sooner or later) with this error. Any ideas how to solve it properly (I mean…
Juta
  • 55
  • 5
3
votes
1 answer

sp R package SpatialPolygons-Class plot transparent

I want to plot objects of class SpatialPolygons with a transparent filling color. Slightly changed example from the help pages of SpatialPolygons-Class: # simple example, from vignette("sp"): Sr1 = Polygon(cbind(c(2,4,4,1,2),c(2,3,5,4,2))) Sr2 =…
Chris
  • 139
  • 9
3
votes
1 answer

How do I fix a color scale bar in several spplots?

I am doing a idw interpolation between several air quality stations. For the final visualization I want to collapse all the images I made into a GIF. Everything works, the only problem is that the scales of values change in every image, and the…
ArnJac
  • 352
  • 2
  • 5
  • 15
3
votes
1 answer

How to set the default theme for spplot?

Let's say, I have some spatial data and I want to plot it using spplot function from sp package: library('sp') library('lattice') demo(meuse, ask = FALSE, echo = FALSE) spplot(meuse.grid[,'dist']) It's easy to change the theme, for example…
Jot eN
  • 6,120
  • 4
  • 40
  • 59
3
votes
2 answers

Merge spatial points and use interpolation to fill the gaps

I have set of data frames and would like to use them to create one raster grid. Here are 2 example files: dat1 dat2 I use sp package to plot the spatial points: library(raster) library(sp) coordinates(dat1) <- c("x", "y") proj4string(dat1) <-…
Geo-sp
  • 1,704
  • 3
  • 19
  • 42
3
votes
1 answer

ggplot fortify ignores order of spatial data

I am having some trouble with ggplot's fortify. When using Open Streetmap shapefile, fortify is loosing the order of some lines. The order must be correct in the file as qgis and the sp package have no problem with the plots. Here is an example with…
ahs85
  • 1,927
  • 2
  • 13
  • 11
3
votes
1 answer

Raster image seems to be shifted using leaflet for R

I want to plot some spatial data using the leaflet package in R, however the generated raster image seems to be shifted compared to a reference grid. I suspect map projection issue, but I am not expert on the topic, so any help would be…
rozsasarpi
  • 1,621
  • 20
  • 34
3
votes
3 answers

Creating SpatialLinesDataFrame from SpatialLines object and basic df

Using leaflet, I'm trying to plot some lines and set their color based on a 'speed' variable. My data start at an encoded polyline level (i.e. a series of lat/long points, encoded as an alphanumeric string) with a single speed value for each…
Andrew Cheesman
  • 140
  • 1
  • 10
3
votes
1 answer

overlay points over polygons in R

I need to overlay 40,000 points over 100,000 polygons. The polygons were created using: polygon <- gBuffer(pc, width=500, byid=TRUE) The overlay was created using: test <- over(pts, polygon) So as a result, I have a data frame with the attributes…
MLavoie
  • 9,671
  • 41
  • 36
  • 56
3
votes
1 answer

Remove PNG plot margins

I am trying to get rid of the top and bottom margins of a SpatialPolygons plot. I have tried setting the margins to c(0,0,0,0) but this only changes the left and right margins. When plotting in RStudio, the top and bottom margins are 0 but the left…
jhhwilliams
  • 2,297
  • 1
  • 22
  • 26
3
votes
1 answer

How to limit the number of levels created by a density plot and?

I have some spatial data and I use the code below to create a heatmap and to extract the created levels as polygons. My question is now how to limit the number of levels which are created? My goal is to have e.g. 5 different density levels? In a…
user2988757
  • 105
  • 1
  • 1
  • 8
3
votes
1 answer

Aggregate data frame to coarser spatial resolution

I have a dataset that is 0.25 * 0.25 degree grid resolution. I've another that is 1 * 1 degree resolution and want to make them comparable (both changed to 1 * 1 resolution). The area is 28.5 to 36.5 longitude and -4.5 to 4.5 latitude with monthly…
Darren J
  • 503
  • 2
  • 5
  • 16