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 |
a graphical technique for representing a data set. Usually showing the relationship between two or more variables.
2
votes
Plotting LISA map using R
The source function runs code from another R script file (see help(source) for details).
Normally you'd see it more like:
source("LISA.R")
with the filename in quotation marks. Without the quotation …
1
vote
Color a layer of the map based on the location of dots on another layer
Quick: use the over(pts,poly) function to return which polygon each point is in. [You might have to construct pts as a SpatialPoints object from your data frame]. Then the return value tells you which …
1
vote
Accepted
How can I plot WorldPopProject data (GeoTIFF) in R with an appropriate scale?
Don't use readTIFF for reading GeoTIFF files. It will not read the spatial information and may mess up in other ways too:
ghanaPop = readTIFF(ghanaPopLocation) #Get initial GEOTIFF loaded
use raster …
1
vote
Plot a series of subsetted pixels from a raster stack in R
This is what the raster::extract function does, and it can extract values from a stack by cell number, or x-y coordinate.
See help(extract) for more.
1
vote
Accepted
`tmap` basemap in `plot` mode
The rosm package can download tiles from OpenStreetMap and construct an RGB raster that you can use as the first layer in a tmap plot. …
1
vote
Creating BoxPlot in R
Taking a vector and subsetting it by a condition will return those values that match the condition. You seem to want to make a boxplot of:
RupandehiForest2010$Forest.Percent[RupandehiForest2010$Forest …
4
votes
How to add labels to shapefile point layer in R?
853703, 825353, 805353)
Add another point close to point 4:
library(sp)
x = c(x,x[4]+1000)
y = c(y,y[4])
SP <- SpatialPoints(coords = cbind(x,y))
SP$ID <- paste("point", 1:length(SP), sep = "")
Plot … points, add labels:
library(maptools)
plot(SP)
pointLabel(coordinates(SP),labels=SP$ID)
Note point4 and point8 labels don't overlap. …
10
votes
Remove internal boundaries in spatial object/polygon for plotting
/topo_E06000023.json")
plot(m$geom)
plot(st_union(m$geom)) …
1
vote
Accepted
R: plotting lines (SpatialLinesDataFrame) with a different line type according to a nominal ...
as.data.frame(mydata)
length funct functN
1 500.8422 t 1
2 293.6068 t 1
11 612.0664 wcs 2
21 629.7057 wcs 2
those numbers are valid line types, so you can then do:
plot … (mydata, lty=mydata$functN)
If you want the solid and dashed lines the other way round then subtract it from 3:
plot(mydata, lty=3-mydata$functN)
which will transform 2 to 1 and 1 to 2. …
2
votes
Accepted
Plot two rasters with different extents
and plot the extent, then add the rasters:
em = merge(extent(rr1),extent(rr2))
plot(em, type="n")
plot(rr1,add=TRUE, legend=FALSE)
plot(rr2, add=TRUE, legend=FALSE)
Use type="n" so a box isn't drawn … From experiments it seems to me that plot(r, ext=e) only has an effect if e is within r, in other words for focusing on a part of a raster, not zooming out. …
9
votes
Accepted
How to use st_buffer?
This is unnecessary because the object is already in that coordinate system:
proj4string(countries_sp) <- CRS("+init=epsg:4326")
This doesn't do a coordinate transformation - the crs argument is i …
1
vote
Extract a list areas and indices of multi-part polygons (SpatialPolygonsDataframe) R
of each row:
> multi = function(spdf){
sapply(spdf@polygons, function(p){length(p@Polygons)}) >1 }
So it returns true or false:
> multi(nc)
[1] FALSE FALSE FALSE TRUE FALSE FALSE ... etc
Plot … the multu polys with some colours so you can see the parts:
> plot(nc[multi(nc),], col=1:10)
And if you want row indexes you can have them:
> which(multi(nc))
[1] 4 56 57 87 91 95
and if you …
1
vote
Trouble overlaying plots in R
California is not at latitude -120, unless there's been an earthquake and its drifted off into the Pacific (although +30 longitude probably puts it in the South Atlantic...). It seems that latitude an …
2
votes
Keeping X and Y bounds fixed when plotting geographical coordinates using mapview
You might be able to do this by converting your points to sf objects and then mapview lets you use hide=TRUE when you add map layers. Then you can use all your points as a hidden map layer, and that s …
1
vote
Accepted
How to add coastline over a plot of a RasterLayer in R?
Now plot the raster and overlay the coastline:
plot(fdiff_north)
plot(sldf_prj, add=TRUE)
Note its better to use sf packages and classes, you can do that with:
library(sf)
coast = rnaturalearth::ne_coastline … (returnclass="sf")
coast_t = st_transform(coast, crs(fdiff_north))
plot(fdiff_north)
plot(st_geometry(coast_t), add=TRUE)
And you get the same map but probably bit quicker and with less memory. …