Questions tagged [r]

Statistical computing language and software environment.

821 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
3
votes
0answers
38 views

smearing in Linux, but not in Windows

I must have a Linux library out of wack since the following image has "smears" on the colors. Is there a better term? On my Windows 7 RStudio it works fine. this image is from a Ubuntu 16.04 LTS ...
3
votes
0answers
601 views

Leaflet map in R Markdown - not rendering when placed after other plots

I have an R markdown document using shiny with 6 or 7 plots. They all display until the 7th plot, which is a leaflet map, which doesn't display - when I 'run document' there is a big empty space at ...
3
votes
0answers
524 views

Using Random Forest for big data?

I used Random Forest regression for my work, but now I have another problem because I have really big data. I am using a VHR and this is much raster information. My script in R is this: rand.zero <...
3
votes
0answers
955 views

Group and aggregate SpatialPolygonsDataFrame by column in R

I'm working with rgdal, sp, maptools, etc. I have a SpatialPolygonsDataFrame that has each row/Polygons list with only one Polygon. It also has an identifier column which I want to use to group by, ...
3
votes
0answers
926 views

Create a new NetCDF file combining information from two other NetCDF files in R

I wish to combine the "t" variable from the second .nc file, and use the lat, lon variables from the first .nc file as the lat and lon of the t variable, and store them to a new .nc file, that will ...
3
votes
0answers
496 views

ogr2ogr{gdalUtils} correct syntax to set Ground Control Points for vector georeferencing

I would like to know correct syntax of R {gdalUtils} package (version 2.0.1.7) to georeference Shapefiles using corner points as GCPs. (These Shapefiles have y=height and x=width information, without ...
3
votes
0answers
89 views

Data structure for analysis of relationship between rainfall and vegetation indices?

I have several hundred raster files (NDVI) of the same area dating back to the 1980’s, as well as daily rainfall observations from a nearby weather-station over the same period. The raster files are ...
3
votes
0answers
109 views

Error when running v.krige

I've been trying to get v.krige to run in the Grass7 command line, however, when I do so I get the following error: Error : .onAttach failed in attachNamespace() for 'rgrass7', details: call: if (...
3
votes
0answers
304 views

Keys for merging US state/county ANSI's with GADM Unique identifiers?

I've got county-level data from USDA NASS, and I want to merge it with gridded climate data. A preliminary step is the associate the counties with the coordinates of their centroids. If I merge by ...
3
votes
0answers
476 views

Doing spatial regression using big data when Spatial weight matrix is too large for R?

I am currently doing an analysis on a quite huge data set - 250,000 polygons. I have figured out the general Moran's I for a linear model, but when I was trying to do a spatial lag or spatial error ...
3
votes
0answers
439 views

R raster stack 4 dimensions

I am trying to create a raster stack / brick from a list of ncdf files with the dimensions 160x160x24x1). r = stack(files) This gives me a raster stack but without the 4th dimensions which is ...
3
votes
0answers
499 views

Interpreting Global Moran's I and should I krig?

I am trying to weigh up if kriging (or cokriging) the residual error from my model is a valid approach. My first step was to compute whether the error is spatially autocorrelated. I have done this ...
3
votes
0answers
366 views

How to run GAM with raster package?

When I am using the raster package to predict a surface probability map of species distribution using the following functions in R, the following error occurrs: CA132122200=raster("F:/CBG maps-UnProj/...
3
votes
0answers
619 views

How to split a polygon into quadrants in R/Qgis?

I am solving the same problem as How to split a polygon into quadrants?, except that I am looking for a solution in R or QGis. So I have a polygon layer shapefile, which is unfortunatelly not exactly ...
3
votes
0answers
581 views

How to calculate 90% confidence interval in a raster stack

I have a stack of grid files (23) in ASC format from a MODIS sensor and I need to calculate a 90% confidence interval, mean, min, etc, for each one in R, how can I do that? specially the interval. #...
3
votes
0answers
386 views

R: Can raster predict function pass to predict.rfsrc (a prediction function in a parallel verion of RandomForest)?

It seems that raster predict function can pass to predict.randomForest by setting the "type='response'". I am using a parallel version of randomForest package called the "randomForestSRC" and I am ...
3
votes
0answers
239 views

R - how to create a pre-determined number of identical square polygons to use for a choropleth map?

I am trying to plot crime data density (again!) over a city map, say of NY. As a well known problem there are plenty of examples on this (http://www.obscureanalytics.com/2012/12/07/visualizing-...
3
votes
0answers
870 views

Decision tree classifying of satellite image in R?

I want to classify satellite image in R using RWeka classifier, J48. I have a CSV file with the classes required, and raster data loaded in R. I am able to make the tree, however, I am not able to use ...
3
votes
0answers
400 views

How do I access layer attributes from within QGIS' manageR plugin?

This is probably a fairly basic question, but searches for manageR come up with a lot of noise, and there's no manageR tag. What I'd like to do is load the attributes from a particular field of a ...
3
votes
2answers
603 views

Writing raster with attribute table in R?

I fitted a species distribution model and predicted the suitable habitat using this model, and then I got a map plotted in R. I tried to save this prediction as a raster, using code: rf<-...
3
votes
1answer
1k views

R: Error when stacking multiple raster files

I have a large number of rasters in grid format ("asc"). I created a list of files: files <- list.files("D:/......../EnvironData", pattern='asc', full.names = TRUE) Then I ...
3
votes
2answers
152 views

Calculate the travel time from locations to the closest N points

I want to calculate the travel time (based on walking time) from locations to the closest N points of another dataset. Then I want to create a hull around those N closest points per location Is this ...
3
votes
1answer
447 views

EPSG code lost when writing shapefile with sf

I've found that the EPSG can be recorded in the .prj file of a shapefile using the "AUTHORITY["EPSG","xxxx"] syntax. However, writing a shapefile with sf::st_write() doesn't seem to add that entry, ...
2
votes
1answer
95 views

Setting CRS of raster to EPSG 3035 using R

I am trying to set the CRS of a raster file with the following code: library(raster) r<-raster(xmn=0,xmx=10,ymn=0,ymx=10) crs(r)<-CRS("+init=epsg:3035") The warning message is: ...
2
votes
1answer
27 views

Axis labels with geom_sf & ggmap

I'm trying to create a map using a basemap pulled in using ggmap (get_stamenmap) with some shapefiles plopped on top (geom_sf). I want to change axis labels! Why's it so difficult! When I only plot ...
2
votes
0answers
26 views

Add raster inset to a raster map in R

I need to plot an inset on my raster map showing a zoomed-in part of the map (according to specificed coordinates). Something like the image below (credit: David Wachsmuth, twitter). I know there ...
2
votes
0answers
48 views

Why does R's osmar::get_osm throw an error?

May be this is obvious, but I was not able to find a solution: I just copied the code from here library('osmar') library('geosphere') rome.box <- center_bbox(center_lon = 12.5450, center_lat = 41....
2
votes
0answers
33 views

Selecting some vector layer attributes as parameter in R script in QGIS 3.10

I am doing a script of R for QGIS and I need to select only some fields of one vectorial layer. I just found these option for choose several layers but not choose several attributes. Is it possible ...
2
votes
0answers
44 views

How to correct sentinel data with sen2cor in R using a json with parameters?

Reading the sen2r documentation I saw the next example: library(sen2r) library(sf) # Download an L1C SAFE product example_s2_list <- s2_list( spatial_extent = st_sfc(st_point(c(12.0, 44.8)), ...
2
votes
0answers
46 views

Extracting GEE time series in one step

I want to extract values across an imageCollection for a specific location. I can do that (using an R and the package rgee, but I think that same could be done in python etc.) looping through the ...
2
votes
0answers
39 views

Shapefile calculation error: 'list' object cannot be coerced to type 'integer'

I'm trying to identify which of two regions within a shapefile specific spatial points lie. To this I used this code. This worked well but I ended with a lot of NAs because my 1/3 of my points are ...
2
votes
0answers
49 views

Optimising use of st_within for parallelisation

I'm trying to use st_within() to calculate points within polygons on a fairly complex shapefile. This operation tends to take 4-5 hours which is a bummer for debugging the code. I have access to a ...
2
votes
0answers
85 views

Changing shapefile longitude from -180-180 to 0-360 in R

I have a world shapefile. I am reading the shapefile using readOGR() function from rgdal package. The shapefile which I have has Greenwich as the prime meridian. I got the world shapefile from this ...
2
votes
0answers
132 views

Apply function on raster

I often need to apply functions on every raster cell. Unfortunately I don't know how to use a efficient method like calc, so I am using very slow for-loops. For example: logistic_function <- ...
2
votes
0answers
62 views

Not all points overlain on raster map are showing up with R

Using R, I loaded a raster file (.tif) and overlaid points on the map. I have 46 points but only about half of them appear on the map. I can't figure out why other points are not showing up. Here are ...
2
votes
0answers
26 views

tmap max categories being weirdly combined

I am trying to plot homeless numbers in the UK using tmap. However, I am coming into some problems with the max.categories for tmap_options. Data EnglandWales <- geojson_read("https://opendata....
2
votes
0answers
32 views

BoundingBox around plot in mapview

I wanted to plot some raster-data with mapview. I always get this greyish bounding box around my data though. Anybody an idea of what this might be? I just call mapview(<raster>)
2
votes
0answers
43 views

The results of xy coordinate transform in R and arcmap are different

Some lon lat sites were converted to xy geographic coordinates in R (target geographic coordinate system EPSG:102012) : lon lat 1 120.11 50.15 2 121.41 50.29 3 117.19 49.35 4 119.42 49.15 5 ...
2
votes
0answers
56 views

Adding polygons to Leaflet inset map in R

I've created a map using the Leaflet package in R and added an inset locator map using addMiniMap(). I would like to add polygons features to said inset map. I've already added the polygons to the ...
2
votes
0answers
230 views

Create a grid in R, change in cell size displaces position of grid

I'm writing R script which will allow users to overlay a grid on their data in a new projection with the option of defining the size of the grid cell. This seems to work fine, however, when I plot two ...
2
votes
0answers
39 views

Can't get two shapefiles to plot together

I have two shapefiles that I am trying to plot in R together with no luck. I believe both shapefiles have the same projection based on the following information: Shapefile 1 - sams proj4string(sams)...
2
votes
0answers
31 views

Not all layers of tmap rendering

I have three 'layers' I would like to render on a map. 1) County-level estimates for various ACS 5-year variables (acquired through the tidycensus package) (in pseudocode below: data) 2) State ...
2
votes
0answers
74 views

Extracting values from rasters with different size in R

I have 10,000 raster files with different sizes. I need to extract values based on a list of points. I have used the following using the raster pckg: library(raster) library(ncdf4) library(data....
2
votes
2answers
64 views

Ignoring ellipsoidal heights recorded from GPS when only interested in location?

I am not interested in converting ellipsoidal height into AHD heights, because I have a good DEM. However, this whole business about geocentric vs geodesic coordinate systems is thoroughly confusing ...
2
votes
0answers
181 views

R: How to get a filename list of raster layers in a geodatabase?

In R, how do we get a file list of rasters in a geodatabase folder? We know the case of vector layers as follow. library(rgdal) fgdb = "C:/path/to/your/filegeodatabase.gdb" subset(ogrDrivers(), ...
2
votes
0answers
90 views

Stratified ordinary kriging using gstat and stars packages

The gstat package supports stratified ordinary kriging using sp objects as shown at https://github.com/r-spatial/gstat/blob/master/demo/examples.R (the code below). This year (https://r-spatial.github....
2
votes
0answers
158 views

Union by new category using R and sf

I'd like to create a new shapefile or a new geometry variable that allows me to plot borders around regions in R. I'm using the sf and mapping with tmap. Basically, I'm adding a character vector to an ...
2
votes
1answer
247 views

Reducing number of polygons in a shapefile to increase the render speed for R Leaflet?

I'm trying to increase the speed of my R Leaflet map by reducing the size of the polygons. I found a great solution on stack exchange here, but for some reason, I get the following error when I try ...
2
votes
0answers
95 views

Extract population density data from a raster by shapefile

I'm trying to extract population density data from a raster by shapefile. I get NaN values, but I think my problem is further upstream at the raster level. I don't do much GIS work, so I'm likely ...
2
votes
0answers
101 views

Union anti-meridian “multipolygons” after re-centering world map

My goal is to create a world map (using ggplot2) with a Pacific perspective. I have managed to re-center the map, by following this solution. Code below: # world country layer sppolys <-...

1
2
3 4 5
17