We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
1
vote
1answer
21 views

How to homogenize NA values within a .gpkg from R

I have created an SpatialPointsDataFrame in R with some data. Here is the outputs from R: > class(Fotos) [1] "SpatialPointsDataFrame" attr(,"package") [1] "sp" > class(Fotos$Azimuth) [1] "...
1
vote
0answers
17 views

Computing averages of land areas only from a Raster in R

I am interested in calculating precipitation averages globally. My data is a contained in a RasterStack object in R and is globally distributed precipitation data. However, I only want to isolate land ...
1
vote
1answer
15 views

Write layer style .qml as predefined within a gpkg using R

I have this code to export a layer (Pbm) to a gpkg called "Atlas": writeOGR(Pbm, paste0(normalizePath(OutputFolder),'\\', "Atlas.gpkg"),"Atlas", driver="GPKG", encoding = "UTF-8", ...
2
votes
1answer
20 views

How do I read a layer from a .gpkg file whilst selecting on an attribute?

I have a GeoPackage (.gpkg) database with only one layer: ogrListLayers("data/LM_data/zipped/ay_riks.gpkg") [1] "ay_riks" attr(,"driver") [1] "GPKG" attr(,"nlayers") [1] 1 There are too many objects ...
0
votes
0answers
12 views

Get mean of every 3 raster files from 575 total files for16 years NDVI data sets in R? [on hold]

I have NDVI data sets of 16 years with 10-days temporal resolution (36 images per year). I need monthly NDVI data. So, how can get mean of every 3 raster files for one month and so on in R? I have a ...
2
votes
1answer
35 views

Ignoring buffer files in processing

I'm wondering if it is possible to include some las files in a LAScatalog only for the purpose of providing a buffer to other las files. For example, I may only want to normalize 2 las files and use ...
2
votes
0answers
16 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 ...
1
vote
1answer
16 views

Landsat 8 QA band conversion error?

I downloaded Landsat 8 NDVI bands from the USGS (instead of calculating them myself). The QA band that came with has values different than I see in the Landsat 8 user guide. Using R I did a quick ...
1
vote
1answer
14 views

Convert polygons into spatial points to use R “redlistr” package

I want to use the the makeEOO function from the redlistr package to calculate the Extent of Occurrence of 2 species ("binomial" A and B), starting from a shapefile with the corresponding distribution ...
0
votes
0answers
16 views

Difficulty concerting coordinates system of data frame to raster coordinate system (trasformation) in R

Can someone help me understand why I have issue getting my dataframe (point coordinates into the same coordinate with my Raster data? My dataframe with point files (lets call it trainData_crs) ...
0
votes
0answers
11 views

Why does the function raster::terrain() for R assign aspect=90degrees for slope=0

Does anyone know if there is good reason why the terrain() function in raster package assigns an aspect of 0,5*pi or 90 degrees when slope is 0? Does this not suggest that all slopes are facing to ...
0
votes
0answers
12 views

Aggregate Willmott and Matsuura Temperature Climate Data on Country Level

I'm looking for monthly, mean temperature data on the country-level since 1900 (or at least 1950) for which the temperature is weighted according to population density. The common database for the ...
1
vote
1answer
19 views

rgrass7: “no stars import yet”

I would like to read a raster layer from GRASS 7.8 into R 3.6.1 (on Ubuntu 18.04). Whenever I use the reasRAST method I get a cryptic message that simply says "no stars import yet" [sic]. The console ...
-1
votes
0answers
20 views

Using R to call real-time weather data with issued API key

I would like to use the following API website: Weatherstack (https://weatherstack.com/) to retrieve real-time weather-related information. I am using a free subscription which allows the user to make ...
1
vote
0answers
24 views

Worldclim past data retrieval using R

Here is how I can retrieve current and future data using the raster package: Current environment from worldclim current=getData("worldclim", var="bio", res=2.5) Future env future=getData('CMIP5', ...
2
votes
0answers
25 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 ...
1
vote
0answers
28 views

Transposing coordinates from PDF map onto satellite image

I have a map in a PDF file with boundaries that I want to plot onto a satellite image. I have made a screenshot, saved it as tiff and imported it as a Rraster object. Using click I have outlined the ...
1
vote
1answer
23 views

Unexpected error while RSAGA raster calculations

I want to use RSAGA package in R to calculate the topographical wetness index. However, while applying the rsaga.wetness.index() function, R gives me an error message (see below). My question is, ...
2
votes
1answer
27 views

Point to every other point as dataframe in R

I understand there are several tools out there that can help me accomplish my goal, but I think I'm running into more of a conceptual roadblock. I've tried to implement a fully reproducible example in ...
3
votes
1answer
32 views

Cannot plot OSM data retrieved from R package 'osmdata' with leaflet directly

I am using the R package osm_data to retrieve some polygons. If I want to plot them using leaflet, it does only work if I export the polygons to a shapefile and re-import it, but plotting it directly ...
1
vote
0answers
9 views

DSpat::create.lines and spatstat::rlinegrid: Adding too many lines?

Does anybody know of an issue with either DSpat's create.lines or spatstat's rlinegrid? Whenever I use these functions on my Windows (owins), the output has far too many lines. For example, if I run ...
0
votes
0answers
24 views

Variogram in R (gstat) with predefinded range [closed]

I am trying to build a sample variogram and model (theoretical variogram) with R and the gstat package. I have to use a certain lag distance (width) and I want to use a certain range. How can I achive ...
2
votes
1answer
33 views

Using R to extract point data for LAS file and maintain all the point data

I am trying to extract several point values for a set of lidar data. I am starting with the DEM before I jump into the other more complicated values in my raster stack. Here is my code: library (...
0
votes
0answers
10 views

Leaflet NA values at boundaries R

I am using leaflet to visualize rasters. The output shows NA values around the border areas for discrete classifications. I read another post that said this might be due to the differences in ...
0
votes
0answers
17 views

Error message when joining two dataframes with sf -Error: y should be a data.frame; for spatial joins, use st_join

In R, I'm trying to count the number of points which fall within a buffer around polygons and add the count result to the original shapefile from which the polygon file was created. I've followed the ...
2
votes
3answers
33 views

Extracting pixel values in different bands for different points giving NAs and not pixel values

I am working with R statistics. And I am trying to extract pixel values for each point in each Landsat bands, however, I am just getting NAs instead of getting pixel values Does anyone have any ...
0
votes
1answer
20 views

Use mapview r package to display vector data with outline only

I'm creating a map in r using the mapview package. I have a raster layer with a vector layer displayed over it. I want to view the raster data completely. How do you set vector data to be completely ...
1
vote
0answers
16 views

How to choose scale endpoints for` tm_fill( )`?

I'm trying to map a continuous scale with tm_fill in tmap: tm_shape(shape)+tm_fill(col="value",pallete="seq",contrast=c(0,1)+tm_facets(by=group) I want to make several such maps for different years ...
1
vote
1answer
23 views

Connecting spatiallines or SpatialPoints based on minimum distance using R

Does anybody know of a way to create a single polygon (that will eventually be converted to an Owin) from either a spatialpoints object or a spatiallines object? Here is an example of each: Here's ...
1
vote
1answer
25 views

R leaflet creates geometric striations in some maps but not others

I have been creating leaflet maps from raster files with discrete values. Leaflet creates smooth maps form some of the rasters, but in other there is a strange pattern of geometric striations across ...
1
vote
0answers
9 views

Create grid with a prespecified number of cells inside a shapefile with R

I need to create a grid inside a shapefile with a fixed the number of cells n (inside the shapefile). I tried a few stuff see bellow but nothing worked so far. Any ideas? The data shapefile can be ...
3
votes
1answer
52 views

Subset point vector based on attribute classification in underlying raster

I have two datasets: A raster file containing per-pixel vegetation classifications across Australia. The file is described to have projection of EPSG:3577 https://epsg.io/3577. All additional meta ...
1
vote
0answers
17 views

Switch between ArcGIS and R changes my shapefile projection?

Not the best practice, but somethimes I need to change between ArcGIS 10.6 and R (version 3.6.1) to process my shapefiles. For example, I want to read my shapefile in R -> process it -> export it back ...
2
votes
1answer
23 views

Aligning Multiple Polygons (Based on centroid possibly) [Spatstat, sf, sp]

I'm trying to create a composite/average of multiple similarly shaped polygons. I think the first step is most likely to align them via the centroid of each polygon. Does anybody know of a tool to ...
-3
votes
0answers
24 views

With R, how to get the value of a pixel and its 8 surrounding pixels from points? [closed]

I need to get the value of a pixel (I have coordinates for this pixels) and its 8 surrounding pixel from the pixel/point. I am working with NetCDF files. I am working with R. I found the same ...
0
votes
0answers
29 views

How to use the R function: raster::extract with polygon which partly covers raster?

I have a raster file which is only partly covered by a shapefile with polygons. Now I want to apply raster::extract in order to get the mean value for each polygon based on the rasterfile - But some ...
1
vote
1answer
27 views

Connecting river segments with R riverdist package

I have imported river courses from OpenStreetMap into QGIS in order to recreate the Rhine river system for analysis in R with the riverdist package. In order to calculate distances between sampling ...
2
votes
0answers
35 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)...
1
vote
1answer
31 views

R conditional logic embedded within calc function for raster

I am trying to create a new raster from one existing raster using conditional logic, ifelse statements. The existing raster has numeric values and NA values. Here is what I tried so far, based on ...
2
votes
1answer
53 views

How to highlight/shade areas of raster based on specific values, in R

I have a raster with values ranging from 1 to 5 like the following: library(raster) library(rasterVis) library(viridis) my_class <- raster(x=matrix(sample(x = 1:5, size = 12, replace=TRUE),4,3), ...
1
vote
0answers
25 views

Buffer in meters instead of degrees in south america

I need to create some buffer in meters, but it not possible how I'm doing. I really don't know what is happening. My code: library(rgdal) minas_ti<- readOGR("minas_TI.shp") minas_ti<-...
3
votes
0answers
25 views

Circular focal means with raster and NAs

I am trying to understand circular focal means using rasters having NA values. I made a couple of scenarios to better understand how to combine weight matrices and functions to summarize values. I am ...
3
votes
1answer
32 views

Combine iterations a loop as a single raster in R

I am looking to combine all iterations of a loop into a single raster using R. I am performing shadow analysis where I perform the calculation for specific hours of a day and would like each ...
0
votes
1answer
16 views

Query multiple OSM node keys in R

I have a big table that contains a set of osm_nodes_keys, like the following working example: a <- c(5993651, 27886377, 104537102) b <- c(a, b, c) df <- data.frame(osm_nodes_keys = a, ...
1
vote
1answer
25 views

Iterate through raster in R and apply conditional statements

I have a raster data set in R with numeric values ranging from 0 to 61.5, including some random NAs throughout. I would provide a reproducible data set, but I don't know how to create a raster with ...
1
vote
1answer
29 views

Selecting polygons within another polygons [duplicate]

I have the same city map (BH city) for two different shapefiles with different locations. The first one is the "shared management", this one have bigger polygons, as we can see shared_management <-...
3
votes
0answers
49 views

R raster / rasterize creating GeoTIFF with Null Value “grid lines”

I am attempting the seemingly simple task of converting a .csv with lat, lon and population values into a .tif (raster). Here's my R code: geoName <- read.csv("/pathToData/geoName.csv") ...
3
votes
1answer
19 views

Reading in different raster files with different bands using a loop

I've downloaded 6 multi-band raster files (each file has 4 bands) from the National Weather Service containing precipitation data for different time periods (30, 60, 90, 120, and 365 day periods). ...
2
votes
0answers
24 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
26 views

Reading Multiple KML Files into list in R

I am trying to read in multiple KML files into a list in R, just like you would do with multiple CSV. I did a lot of research on the web but did not find anything. My code so far: library(maptools) ...