Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
Statistical computing language and software environment.
5
votes
Accepted
Calculating Moran's I on large point dataframe in R
I created an R package that calculates the distance matrix on the fly, so it takes much less memory to calculate Moran's I. Its also quite fast. You can find it at github.com/mcooper/moranfast. …
1
vote
Reorder legend in ggplot object
bind_rows, list(Gcross_normal, Gcross_tumor, Gcross_invasive))
Then, you can make a ggplot with only one call to geom_line, with the feature as an aesthetic:
ggplot() +
geom_line(data=Gcross, aes(x=r* …
2
votes
Reclassifying raster stack based on condition and other layers using R?
The bracket extract operators work on rasters in R. So you dont need to use setValues or overlay. I would do this:
r1[r1 > r2] <- 1
r1[r1 < r3] <- 0
r1[!(r1 > r2 | r1 < r3)] <- r4[! …
1
vote
Improves performance on R working with raster files
To assign raster values to 0, you can do something like this:
r <- raster('yourraster.tif')
r[is.na(r)] <- 0 #Convert all NAs within extent of r to 0
r[r < 0] <- 0 #Convert all negative numbers …
3
votes
Accepted
Find which latitude and longitude values are falling in which raster cells
So:
metersCoordinates <- totalMeterDatabase[,c("longitude","latitude")]
coordinates(metersCoordinates) <- ~longitude+latitude
r <- raster(matrix(seq(1,6000*2000), ncol=6000, nrow=2000),
xmx … metersCoordinates$longitude),
xmn=min(metersCoordinates$longitude),
ymx=max(metersCoordinates$latitude),
ymn=min(metersCoordinates$latitude))
totalMeterDatabase$cellnumber <- extract(r, …
1
vote
0
answers
646
views
Subset moving window when using focal on raster in R
The code I am using:
r <- raster('myraster.tif')
FocalSelect <- function(cells){
if (cells[c(25)]==4){
return(4)}
if (cells[c(25)]==9){
return(9)}
if (cells[c(17,18,19,24,25,26,31,32,33 … 37,41))]==rep(7,25)){
return(7)}
if (cells==rep(3,49)){
return(3)}
if (cells==rep(10,49)){
return(10)}
if (cells==rep(11,49)){
return(11)}
else{
return(0)
}
}
out <- focal(r, …
6
votes
3
answers
26k
views
Unable to read raster into R: 'TIFFReadDirectory:Failed to read directory at offset'
I'm getting a weird error when trying to read a raster into R. … I've tried restarting R and my computer without success.
So the rasters that are doing this are ones that I recently downloaded using the function download.file(). …
8
votes
1
answer
8k
views
Distance to nearest point for every point same SpatialPointsDataFrame in R
I have a SpatialPointsDataFrame that I'm working with in R. …
3
votes
2
answers
3k
views
Display two-dimensional color gradient for two different quantities
I can use ArcGIS, QGIS and R. …
8
votes
5
answers
9k
views
In R, set NA cells in one raster where another raster has values
I have two rasters in R. I want to set values to NA in the first raster where the second raster has values. … I'm doing:
newraster <- raster1[is.na(raster2)]
But this seems to take an unnecessary amount of memory, and keeps crashing R. My computer has 8GB of memory. …