Skip to main content

Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
2 votes
1 answer
432 views

Mac terminal and R show different GDAL versions

I am trying to read a .hdf file into R using: gdalUtils::get_subdatasets() but I am left with this error: ERROR 4: `/var/folders/24/9_h4zhq564g3zpvqp6jmbm0c0000gn/T//RtmpibWWKQ/MODIStsp/HDFs/MCD12Q1....
0 votes
1 answer
571 views

How can I keep the time information while converting NetCDF file to dataframe?

My final objective is to perform a regression (latitude predicted by precipitation). To achieve that, I have download this dataset from Copernicus: https://surfobs.climate.copernicus.eu/dataaccess/...
0 votes
2 answers
206 views

Getting polygon coordinates for areas outside known polygons using R

I have downloaded shapefile containing polygons for urban areas. However, I am interested in polygons representing rural areas. Therefore I would like to convert the shapefile containing urban areas ...
0 votes
1 answer
2k views

Converting points to latitude and longitude values in R

I have a .tiff file with some coordinate data associated with temperatures that I need to convert into latitude and longitude, using R. I used the following code to read the original file: testlat<-...
1 vote
1 answer
246 views

Faulty spatial ref when writing geopackage from sf

I am using sf version 0.9-5 in R 3.6.1 in Windows, and am transforming an sf feature to the USA_Contiguous_Albers_Equal_Area_Conic projection that has ESRI authority 102003 and no EPSG code - I can ...
-2 votes
0 answers
17 views

Help rendering task update messages as they are completed in Shiny App [closed]

Within an observer button event, I'm trying to render an update message to the Shiny UI upon completion. In the code below, each task is timestamped correctly however they aren't rendered to the UI ...
0 votes
1 answer
21 views

Algorithm for catchment delineation with equal size basins

I am looking to delineate catchment areas of roughly equal size at specified outlet points along a channel. I need something that adds preference to capturing the floodplain on either side of the ...
0 votes
1 answer
434 views

0........0.kriging error messages, grid file problem ? (automap, gstat)

I am trying to conduct kriging of variable called percent in South Africa. head(LL12) Location Longitude Latitude percent 1 L1 16.48476 -28.60737 1.0000000 2 L3 16....
1 vote
1 answer
202 views

lidR plot large LAS crashes RStudio

I'm trying to plot a large LAS (9GB, 269,671,586 points) using plot in the lidR library. (RStudio version 2022.07.2 Build 576, R version 4.2.2, lidR version 4.0.1) I have plotted smaller LAS ...
0 votes
1 answer
30 views

CDO combined commands not working

I am working in R and have netCDF files that I need to pre-process beforehand. One file can be downloaded here: https://drive.google.com/file/d/14tbMvFaYSvHpDWTOdbSSdverkowEhNyV/view?usp=share_link ...
0 votes
1 answer
496 views

slmtest in R - Error non-conformable arguments

I'm running panel regression models in R with the specified model: tot_crime <- log_rt_crime ~ ndvi + log_disad_inde + log_density I've successfully run: non-spatial OLS pooled model using plm ...
0 votes
2 answers
31 views

R: 'area' function for las-file

I want to work on this project: https://gitlab.gwdg.de/tanja.kempen/skidtrail-detection/-/blob/main/README.md?ref_type=heads where I'm using the SkidTrail_Preprocessing.R R-Script. Software: RStudio ...
0 votes
1 answer
228 views

Error in .bboxCoords(coords) : nrow(coords) > 0 is not TRUE using raster::sampleRandom()

I am trying to sample a raster (pixel values= 1 or NA, where 1 means opportunity as defined for my research). The specs of my raster are class : RasterLayer dimensions : 15838, 3808, 60311104 (...
4 votes
2 answers
593 views

Extract pixel values in raster stack using shp

I am using the following code to extract mean pixel values over an area represented by a polygon: mean<-lapply(S2_stack, FUN=function (S2_stack) {data.frame(mean=extract(S2_stack, polygons2, fun=...
0 votes
1 answer
320 views

R sf package: Error in subsetting geometries - "invalid subscript type 'list'"

I'm working with the sf package in R to process a set of point geometries. My objective is to find neighbors for each point within a certain distance. However, I'm encountering an error when ...
0 votes
0 answers
54 views

Overlapping emmissions with Euclidean decay

I have a number of emission sources (roads) with varying emission values (noise). For the sake of simplicity, let's say the sources were 3 points. The emitting noise decreases by the inverse distance ...
0 votes
0 answers
39 views

MODIStsp R package: unable to download land cover data

I am trying to download land cover data using the MODIStsp R package without using the GUI, using the following code: library(remotes) remotes::install_github( "ropensci/MODIStsp" ) ...
0 votes
1 answer
943 views

Creating multi-ring buffers around points in a single layer and for each point selecting neighbors within a specified radius in R

I have a CSV file of data on a set of 3000 points (locations) with respective coordinates and a number of attributes. I want to perform a regression analysis that takes cognizance of any spatial ...
1 vote
1 answer
212 views

Orphaned holes in LoCoH K

I am trying to estimate the home range of wolves and would like to use LoCoH to do that. However I am running into a orphaned hole problem that I really do not know how to solve. var <- read.csv(&...
1 vote
2 answers
2k views

dismo - Plotting individual predictor responses

I have a MaxEnt model implemented in dismo package. The package has the convenient function response to plot predictors' responses as the ones provided by the model html output, in R plotting style. ...
1 vote
2 answers
406 views

Convenient way to download MCD19A2 product using R

I want to download MODIS MCDA219 product. I have been downloading manually from https://ladsweb.modaps.eosdis.nasa.gov/ and https://earthdata.nasa.gov . As a new to R user, recently I have learn ...
0 votes
1 answer
168 views

Remove ("erase") polygons by shared attribute

I need to do a pair-wise removal of a set of polygons within a larger set of polygons. pt<-data.frame("x"= c(0,0),"y"= c(0,5),pair= c("a","b")) pt<- ...
0 votes
1 answer
175 views

Error message with Krige function: Error in as.character.default(X[[i]], ...) : no method for coercing this S4 class to a vector

I am trying to run the Krige function but I keep receiving NA values for var1.pred and var1.var. After using the warning() command, it says: Error in as.character.default(X[[i]], ...) : no method for ...
1 vote
1 answer
160 views

Expand the horizontal range of ggmap

I'm trying to map an area by using ggmap. The problem is that ggmap only plots a square map. What I'd like to do is to expand just a little bit the map, so the map would fit perfectly. Here is my code....
0 votes
0 answers
23 views

Adding borders to 2D plot in ggplot2

the displayed code produces the following plot with ggplot2: plot_DK <- ggplot(coordinate_grid, aes(coordinate_east, coordinate_north, fill = model1_predictions)) + geom_tile() + ...
0 votes
1 answer
243 views

I am using BFAST to do a time series analysis of LST and I am getting NaN errors

This is the blog post I refer to, https://philippgaertner.github.io/2018/04/bfast-preparation/, and the author's code is as follows: # NDVI data data(tura) selected_pixel <- 90 represents a ...
5 votes
1 answer
547 views

Working out travel time from gdistance's conductance values in R?

Introduction This question is indirectly related to a previous post of mine (Calculating accumulated walking pace from starting location outwards using R?), but asks guidance about a different aspect, ...
0 votes
1 answer
375 views

Opening .NC file in R online rather than downloading it

I am trying to access the .nc file in R which can be found(downloaded) here: https://www.ncei.noaa.gov/data/nclimgrid-daily/access/grids/1951/ncdd-195101-grd-scaled.nc I tried using this function ...
0 votes
1 answer
584 views

How to create a ppp spatstat object from a sf object

I am trying to create a ppp object from a sf object in R. I am using the population-weighted centroids in Minnesota from 2020 census data. You can find the data here: https://www2.census.gov/geo/docs/...
2 votes
1 answer
399 views

Biweekly time series for raster stack in r

I have a netcdf file with daily data and I calculate for each week some statistics, using the "apply.weekly" command in the "xts" library. However, I would like to calculate bi-weekly statistics, ...
0 votes
1 answer
2k views

Error opening shapefile with read_sf()

I'm trying to load a shapefile to R using the following code: state_shape<- read_sf(file.path("C:/Users/ssaha/Documents"), layer="IND_adm1.shp") But I keep getting the ...
1 vote
1 answer
28 views

Adding WKT to VRT using R / LidR

I am trying to work through this error after adding a VLR to a LAS. I'm using a custom local projection that does not have an EPSG code, hence trying to add the WKT string as a VRT. > header(las) ...
41 votes
2 answers
40k views

Reading feature class in file geodatabase using R?

I have a feature contained in a geodatabase that is larger than 2GB as an exported shapefile. I need to run an extract function in R to attribute the polygons with data from a raster file. Exporting ...
0 votes
1 answer
216 views

Error computing quantiles on large RasterStack

I want to get quantiles of each cell across layers on a stacked set of RasterLayers on R. My RasterStack looks like this dimensions : 721, 1440, 1038240, 18628 (nrow, ncol, ncell, nlayers) I run the ...
2 votes
1 answer
2k views

Using spatial points to extract values from large raster in R

I am working with location data for 22 different individuals (id). The data contains an id column, and coordinates (UTM_x and UTM_y). For all individuals combined, there is a total of 991,099 ...
1 vote
2 answers
112 views

Cloud masking ECOSTRESS LST data

I have downloaded a land surface temperature (LST) raster from ECOSTRESS as well as it's associate cloud mask (you can sign-up for free here and download your own data). NASA's tutorial (minute 31:15) ...
0 votes
1 answer
59 views

Unable to open .grd file on R using raster

I have downloaded a .grd file from IMD website https://www.imdpune.gov.in/cmpg/Griddata/Rainfall_25_Bin.html It is described as 0.25 x 0.25 Binary file. Below is MWE # Package names packages <- c(&...
1 vote
1 answer
495 views

Issue with osrmIsochrone function in R

I have been using osrm package for a while and didn't ever come across this kind of issue before. It looks so weird and I have been trying to update package and reinstall R as well. But nothing is ...
0 votes
1 answer
580 views

Identifying spatially contiguous clusters in raster data using R

I am doing a classification of z over a single raster of dimension x,y,z. r <- raster(nrows = 200, ncols = 400, xmn=-1, xmx=1, ymn=-1, ymx=1) r[] <- sample(1:100, size = 80000, replace = TRUE) ...
1 vote
1 answer
25 views

Raster extract function on R return values incompletely

I am using R to extract the raster values based on the grid (polygon). The result extracts the values but with some missing data (NA) in the output. These missing values are located on the ...
4 votes
1 answer
13k views

Error in compareRaster(c(x, rasters)) : different extent

I have a RasterStack that I want to add two rasters to. I am using this code library(rgdal) library(raster) #original rasterstack rasterfiles <- list.files("C:\\path_to_rasters", "*.tif$", ...
0 votes
1 answer
250 views

Faster way to compute Moran’s Index from a very large distance matrix between geographic points

I am computing Moran’s Index from a very large distance matrix between geographic points. The time to execute the code is too high. I used the dism function in the geosphere package. Here a ...
0 votes
1 answer
43 views

Spatial join on R with counting point in grids for different months and years

I am running using the spatial join function on R, to calculate the fire occurrences in each grid for different months (1-12)and years (2001-2022). However, the fire count values from the result table ...
0 votes
1 answer
37 views

Correlation analysis between large number of environmental rasters

I am trying to run a correlation test in R for 761 environmental rasters, but that seems to be too many to run at one time. For context, I have average monthly SST and CHL rasters over roughly 50 ...
0 votes
1 answer
34 views

Error when using tmap: Error in if (hover != "" && !hover %in% smeta$vars) rlang::arg_match0(hover, : missing value where TRUE/FALSE needed

I am trying to make a map using the tmap package in R, because I have a continous raster for which I think using Jenks Nature Breaks would be usful for visualisation. Thus far this is what I have: ...
0 votes
1 answer
1k views

Plotting and/or exporting VIIRS SDR DNB data as GeoTIFF in R?

I already asked this question @stackoverflow however, perhaps it fits better here, due to the spatial nature of VIIRS data and the hdf5-eos file format. Im looking into how to handle .h5 (hdf-eos) ...
0 votes
1 answer
34 views

Merging shapefile with data file with coordinates

I have a shapefile 'shp' with boundaries, and I have a data .csv file with coordinates and some values. I want to join the df to shp, so that each coordinate/observation would be in the correct zone/...
2 votes
1 answer
260 views

Using spTransform CRS in Leaflet

I am producing Kernel density estimates for animals from tracking data. Location is input at x y data, I produce a spatial polygons dataframe from these coordinates. xy<-id[c("X", "Y&...
2 votes
1 answer
720 views

Find all census tracts N miles from a lat, lon point

Using R, I'd like to find all census tracts within a given distance of a point (lon,lat). i.e. All census tracts within 20 miles of 34.0522, 118.2428 I have used the sp library and over command to ...
0 votes
1 answer
380 views

Creating coordinate points based on polygon

I am trying to create coordinate points based on a polygon that I've created in Google Maps and imported into R as an sf object. Specifically I have sample points of physical samples I've taken, but ...

1
2 3 4 5
119