Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
5
votes
2answers
10k views

Inserting zoomed-in plot with full scale plot in sp package in R

I am using the sp package in R to plot sampled points along a river. However, I would like to zoom in to a sampled area of the entire river, and plot this zoomed area on the full length of the river. ...
5
votes
1answer
5k views

Creating scatterplot with icons (svg or png) instead of points?

I'm just starting with R and I wanted to know if it's possible to create a scatterplot with custom icons (svg or png) instead of points. I started to import a shapefile, and then I have a set of ...
5
votes
1answer
581 views

Why does ManageR and rpy2 not work in QGIS (1.8.0-Lisboa)?

I have been trying to get R scripts to function and ManageR to work within QGIS (1.8.0-Lisboa). (Windows 7). Python2.7.5. Two problems indicated that R was not working in QGis. First - when I run an ...
5
votes
2answers
3k views

Correlation between rasters using R

In R, anyone know a method for measuring correlation between raster and spatialpixels, or between two rasters?. I read something about Kulldorff but do not understand how to use it, and maybe it's not ...
5
votes
1answer
2k views

Iterate features on SpatialPolygonsDataFrame in R

I have a SpatialPolygonsDataFrame object. Is there way to use apply on this object rather than using a for loop to iterate features in this object?
5
votes
3answers
935 views

Create Zonal Grid in R

Suppose I have a n*n raster, and I want to create k square blocks (k can be divided exactly by n*n ) for zonal analysis: for example, when n = 4 and k = 4 a 4*4 raster is create with value 1 1 2 2 ...
5
votes
2answers
2k views

Seeking QGIS affine equation?

I am at the mercy of a govt authority who have provided utility information in a cad format with a 0,0 origin and a nonsense grid. About a dozen files, the grid and origin are entirely arbitrary. To ...
5
votes
3answers
5k views

Stack rasters with different origin, dimensions and resolution in R

I have three raster files with the same extent and CRS, but with different origin, dimensions and resolution. r1 class : RasterLayer dimensions : 3020, 3043, 9189860 (nrow, ncol, ncell) ...
5
votes
1answer
880 views

Project raster to new extent

I have some data in a raster stack (CCSM4 climate projections from 2010 - 2300) that I've done some processing on, but now I would like to change the extent. I'm not 100% sure how to do this in R. So ...
5
votes
1answer
1k views

Creating an sf object from the maps package

I am trying to use data from the maps package in an sf workflow. I'm not sure if I have the operation correct (see below). It seems to work until state 20 (massachusetts). What am I doing wrong? Maybe ...
5
votes
3answers
2k views

Sample points randomly within raster cells in R

I would like to generate one random point for each cell in a raster, while excluding NAs. I can use sampleRandom however this just gives me the centroid of each cell: library(raster) ras <-...
5
votes
2answers
2k views

Read multiple layers of KML file using R

I have a KML that 3970 layers. I am trying to read it into R using the following script: library(rgdal) lyr <- ogrListLayers("file.KML") mykml <- readOGR("file.KML","Layer1") This works but ...
5
votes
2answers
4k views

Flow Accumulation in R

My apologies for such a general question. Is there an ArcGIS like implementation of Flow Accumulation for R? What I am trying to avoid: Using ArcGIS; Using Grass; Using RpyGEO (but will if need be) ...
5
votes
1answer
570 views

Is there any reason NOT to use MODIS sinusoidal projection?

I have a large number of MODIS snow rasters which I am cropping with the extent of a shapefile. Currently, I am using spTransform so that my shapefile has the same CRS as the rasters. This code works ...
5
votes
1answer
926 views

Importing raster with R from File Geodatabase?

How can I importing raster file from gdb into R Name rater file: Cont_maturite in gdb : CAROPER_04151.gdb In wd: c:\test\caroper
5
votes
2answers
1k views

Adding a linestring by st_read in Shiny/Leaflet

I have a large shapefile. For a better perfomance I try to load data with st_read() from sf package. The official documentation states that it should be very easy to integrate the shapefile into ...
5
votes
1answer
1k views

R - multicore approach to extract raster values using spatial points

It might look like this question is duplicated, but I'm asking about data extraction by points, rather than by polygons, and I couldn't find hints about point extraction. Therefore, please bare with ...
5
votes
1answer
2k views

Plot many rasters on the same graph, one on top of the other, using a certain angle in R

I wish to create a plot with multiple raster layers in R, but plot them in a certain angle so that all layers can be properly seen. What I have in mind is a plot like the following, taken from here: ...
5
votes
1answer
1k views

How to load a Spatialite layer into R?

I have a polygon layer (>600000 features) in a Spatialite database and I want to overcome to run out of RAM by selecting only the features I need for subsequent workflow. I can connect to my ...
5
votes
1answer
549 views

Is there an analog to ArcGIS Area Solar Radiation in R?

Is there a function in R to compute direct, diffuse, and global insolation based of DEM in R similar to Area Solar Radiation tool in ArcGIS?
5
votes
1answer
448 views

Getting a raster into GRASS and back out again: `rgrass7` readRAST not preserving dimensions

I am trying to get a raster into GRASS from R and back out again using the rgrass7 package. Getting the raster in seems to be no problem. However, when I try to get it out with the readRAST function ...
5
votes
1answer
673 views

Problem projecting lat/long into the CRS of my raster in R

I am working with a raster in the .e00 format, located here: ftp://ftp.epa.gov/castnet/tdep/grids/n_dw/n_dw-2000.zip I unzip, and then load this raster in R: require(raster) require(rgdal) require(...
5
votes
3answers
852 views

Generating Grid Maps from shapefiles

I've become a big fan of a visualisation technique called grid maps. Here are some examples: http://flowingdata.com/2015/05/12/the-great-grid-map-debate-of-2015/ http://i.telegraph.co.uk/multimedia/...
5
votes
1answer
2k views

How do I get rid of edge effects while using focal in R to smooth a raster?

I am trying to use R with the focal function from the raster package to smooth raster images. I am working with Radar images that have already been preprocessed. As part of that, some calculations ...
5
votes
2answers
6k views

Generate HTML file with R using Leaflet

I try to display the France map on HTML with RStudio; I followed the tutorial to the World card in Creating an interactive map with Leaflet; Example works. I wanted to do the same just by displaying ...
5
votes
1answer
2k views

Geographic Heatmaps with Concentric Circles by Distance?

I'm looking to generate a geographic heatmap (using 'ggmap') that overlays some dimension (to start, housing prices) over the lat/lon near a city center. Then I want to create circles of equi-distant ...
5
votes
1answer
955 views

Cross-validation of TPS and kriging outputs from the fields package in R

I am looking for existing package or functions that will allow me to cross-validate multiple outputs of Thin plate spline (TPS) and Kriging from the fields package. Does anyone know of any available ...
5
votes
1answer
3k views

How to cluster Raster data

I have thousands of Raster data concerning the ice coverage at the pole at different times (days) over several years. Now I would like to perform a cluster analysis. I want to split the data into ...
5
votes
2answers
3k views

How to draw a point at an exact location with spplot?

I imported a Shapefile holding a quite detailed world map from: http://www.diva-gis.org library(sp) library(rgdal) world = readOGR('./countries_shp/', 'countries') Using R with the sp-Packages, ...
5
votes
1answer
667 views

r - sf::st_cast(“LINESTRING”) - keeping first linestring only warning

I have a dataset with geometry column in which there are linestrings and multilinestrings. While keeping the linestrings I want to convert the multilinestrings to linestrings (which should potentially ...
5
votes
1answer
2k views

Access to attribute in rasterlayer in R

I read an ADF file in R: kommuner <- raster( "../../../10-Data/Kommunne_i_Norge_2000/Kommuner2000_100m_100m/100x100_2k/w001001.adf" ) It contains three attributes: > kommuner class :...
5
votes
1answer
2k views

Assigning CRS to Lat/Lon in R giving error: “Geographical CRS given to non-conformant data”

I have a list of suburbs in Queensland, Australia along with their lat/longs. However, when I try to read in the file in R and assign a CRS, R is giving the following error message: Error in ...
5
votes
2answers
263 views

substitue raster values duplicate error

I have a raster (seg) whose values I want to substitute, and am getting an error from function subs from the raster package that I don't understand at all. I get the following error Error in .local(...
5
votes
1answer
911 views

Interpolate temperature data (shapefile) using R

The answer below solved my fist question, so I edit my question as follows: I have a shapefile given with the attributes lat, lon, elevation and temperature. So far I have a script that interpolates ...
5
votes
2answers
801 views

R code to find the smallest bounding box for a specified orientation

How can I devise an R-code that can derive a rectangular bounding box (with 90-degree angle on each corner) for a set of points with arbitrary orientation? e.g. if the 2 longer edges have a 45-degree ...
5
votes
1answer
756 views

Spatio-temporal kriging - useful if not interpolating to new time points?

I have data measuring a variable Z say at several locations on a fixed network (each location at a fixed longitude and latitude). values of Z are measured daily at the same time. At the moment I am ...
5
votes
1answer
620 views

How to add a topographic map to a shapefile?

I wonder how it's possible to add this topographic information (elevation) to the map of Santa Cruz Island and all of the Galápagos Island that I have here. library(rgdal) library(rgeos) library(...
5
votes
1answer
472 views

Use “facet_wrap” in ggplot2 with QGIS?

I'm using QGIS 2.6.1 and R version 3.2.2. I'm struggling to get the syntax on a R Script for creating plots via QGIS processing to work. My understanding is that R syntax in QGIS Processing is ...
5
votes
2answers
1k views

Is it possible to clip a shapefile to an image() in R?

I am working on mapping some netcdf data in R and have been having a tough time trying to perform a clip with an imported country shapefile that I'm using. Here is my question from yesterday. If you ...
5
votes
3answers
5k views

Dissolve Polygons using R / join specific polygons

I have data in shapefile format :: UK_boundaries I am new to R and Spatial data as well, I am trying to join some areas to be as one area no line(s) between them. Based on my search I understand ...
5
votes
3answers
1k views

How can I snap one set of points to another in R

I would like to snap one set of points (SpatialPoints* objects) to another in R using Euclidean distance. I'm hoping for a function like maptools::snapPointsToLines. The attributes of the points don'...
5
votes
1answer
4k views

Count overlapping polygons in single shapefile with R

I have a shapefile of species ranges for ~ 346 species. Some species have multiple polygon ranges so there are 1,078 polygons and many polygons are multi-part. It looks something like this: I would ...
5
votes
2answers
3k views

Three-dimensional interpolation of temperature profiles using gstat in R?

I'm working on a problem in which I'd like to interpolate a set of oceanographic temperature profiles over a three-dimensional matrix of unsampled x, y, & z locations. The data to interpolate is ...
5
votes
1answer
4k views

how to extract a variable at specific time and depth from netcdf in r

I have the following netcdf file containing 7 variables and 4 dimensions. [1] "file data.nc has 4 dimensions:" [1] "depth Size: 12" [1] "time Size: 37" [1] "x Size: 305" [1] "y Size: 432" [1]...
5
votes
1answer
290 views

Spatial graphing, distribution of polygon area over latitudes

Given a polygon in a PostGIS database, what is the best way to create a graph of its distribution over a range of latitudes? I'm picturing a graph of a curve, where the proportion of the total area ...
5
votes
1answer
154 views

How to assign (or project) CRS to LiDAR file in lidR?

Can someone enlighten me if there is a difference between initializing a CRS object using the EPSG code versus just the +proj string read from a shapefile? Consider the following objects: A ...
5
votes
1answer
1k views

Slow plotting of spatial data in macOS RStudio's plotting device

In my macOS system RStudio, plotting spatial data (statialpolygons, points and lines) is extremely slow, making it impossible to work with. When I try to plot the shapefile in this link (@https://...
5
votes
1answer
2k views

Creating empty Polygons or SpatialPolygons in R?

I'm working on a project where I'm looking at overlap in users circling an area in an image. Esentially, I make a SpatialPolygonsDataFrame where each user gets one row. Some users don't select ...
5
votes
1answer
689 views

Which statistical methods to compare the spatial distribution of two different variables in two raster maps?

I am working with two global raster maps using the R Software (original file: netCDF for map 1 and GeoTIFF for map 2), with a resolution of 5 min of arc. Map 1 contains data on the share of the land ...
5
votes
1answer
2k views

A faster polygon intersection tool than rgeos gIntersection in R?

I'm looking for a R function able to retrieve the polygon intersecting between two SpatialPolygonsDataFrame. I need to use R and the rgeos::gIntersection() is too slow in comparison with ArcGis...