Questions tagged [r]
Statistical computing language and software environment.
5,708
questions
0
votes
0
answers
6
views
leafsync strange behaviour - duplicate maps when syncing two different maps
I have a bizarre thing going on with leafsync::sync. I have two maps generated using mapview function in r. The underlying data is in sf format
map1
map2
As you can see they are two different maps ...
0
votes
0
answers
21
views
Way to turn a RasterStack into a SpatVector in R
I have a RasterStack with 2 layers. I am using an R package that requires only SpatVector objects. Using the layers separately is not really an option since I want their combined effects. Would there ...
0
votes
0
answers
10
views
Matching coordinates to the closest raster in a stack by date in R
I have downloaded NDVI rasters from luna::getModis, and assigned each raster layer the appropriate date. This was then converted to a rasterstack. I also have a dataframe with coordinates and date.
I ...
1
vote
1
answer
15
views
Iterating through las directory using lidR in R results in not finding file or not recognising file as .las
I am trying to produce a script which has functions that can produce a list of statistics and writes them to data.frame, which can in turn be written to a csv file if needed. This would be to check ...
-2
votes
1
answer
20
views
How to prepare the spatio temporal data sets for Spatio-temporal variogram? [closed]
How are you creating these spatiotemporal data sets. I am facing troubles to make one. My satellite data is for 10 days (say 01-01-2018 to 11-01-2018) at lat long and data values. Could you tell me ...
0
votes
0
answers
10
views
Mean and standard error based on class type using R
I have two raster images (.tif), A and B. A has a range of values, and B is a land cover class (in my case, nine classes). I want to calculate the mean and standard deviation of raster A based on the ...
0
votes
0
answers
15
views
Output of catalog_map in R
i am quite new to R and RStudio, i am currently working with a large set of point cloud data (~450 files), when I try to get the crowns attributes with catalog_map(), I find that the output of the ...
0
votes
0
answers
22
views
How to use sf::st_join and avoid filling in values if polygon mostly covers empty space?
I am using sf::st_join in R to join two polygon layers. One of the two layers (sample) was created from a rasterised subset of the other (patches).
I would like to extract the values from the subset ...
1
vote
0
answers
44
views
Extract touching polygons using st_touches
I am trying to extract touching polygons using R. The polygons are some wall facades and gaps. When I use st_touches(), it gave all (empty) value. However, they do touch each other.
The issue is quite ...
1
vote
0
answers
12
views
GDAL error with renv virtual environment in R
I recently started using renv (on a Mac) to manage project environments and I’ve noticed a troublesome problem. When I activate an environment (with sf and terra installed) I cannot set the CRS for or ...
0
votes
1
answer
46
views
Create multiple rasters in PostGIS from a (xyz) table
I'm having a hard time understanding how PostGIS works in terms of raster creation. Let's say I have a table with 14 columns: the first two are x and y coordinates followed by the air temperature for ...
0
votes
0
answers
33
views
Calculating polygon area in R using sf - inconsistency with ArcGIS Pro
I am working with a few shapefiles in R and trying to calculate area of the individual polygons within each shapefile. One of them seems to be working appropriately - when I calculate area using "...
0
votes
1
answer
26
views
Colouring wrld_simpl countries with a variable
This seemed at first rather easy but turned out to be impossible to solve.
I want to plot the wrld_simpl map but coloring the countries with a color gradient that depends on a variable. The countries ...
0
votes
1
answer
56
views
Tracing a Route on a Map
I am working with the R programming language.
Using OSM (Open Street Maps), I am trying to make a detailed map for the city of Toronto (Canada) with the road distance between the CN Tower and the ...
0
votes
0
answers
26
views
R - Spatial sample from a points layer
I read all day several articles regarding various methodologies and tools to create a significant sample from my initial data but I get lost at some point.
It is a shapefile of points.
I would like to ...
1
vote
1
answer
44
views
Mathematical formula to convert lat-lon to Lambert Conformal Conic
I want to manually convert coordinates (latitude-longitude in degree decimals) data into Lambert Conformal Conic (more precisely, EPSG:3347). I already know how to use GIS software functions for ...
0
votes
1
answer
18
views
Mean and standard error of raster data
I have a 30-meter raster data of an area of carbon stock. I want to calculate mean and standard error using R. It can be calculated easily but the SE is very very low, I am sure it is underestimation.
...
0
votes
1
answer
33
views
Pixel level landcover change analysis [closed]
I have two land cover maps in Geotiff format and need guidance on conducting a pixel-level change analysis.
library(raster)
set.seed(123)
raster1 <- raster(nrows = 100, ncols = 100)
raster1[] <-...
-1
votes
0
answers
17
views
Spatial Join between Isochrone and shapefile in R [closed]
library(r5r)
library(sf)
library(data.table)
library(readr)
library(dplyr)
library(ggplot2)
library(tidytransit)
library(tidyverse)
options(java.parameters = "-Xmx2G")
###Fixing the path ...
0
votes
0
answers
19
views
Split population number by area in R
This is continuation of my previous question. This works in ArcMap as it should. I am now trying to do it in R.
I have a polygon that contains the population number. Another polygon is a zone polygon. ...
0
votes
1
answer
22
views
MODIS MCD641 quality bits from TIFF file in R
I have a TIFF file from MODIS MCD64A1 (burned area) which has a quality flag band with documentation like so:
I want to just select where bit 0 and bit 1 = 1 or where the flags are a land grid cell ...
0
votes
1
answer
52
views
Decide consensus after finding location of unknown point with distances to two known points
Based on feedback from this question: https://stackoverflow.com/questions/77063827/find-location-of-unknown-point-with-distances-to-two-known-points, I created R code.
I am using a dataset that ...
0
votes
0
answers
25
views
Error in rep.int(sep, ncolumns - 1) : invalid 'times' value in bayesx function [R2BayesX package] in R
I am trying to run a STAR model within the R2BayesX package using the bayesx function. My model works with the cases of leptospirosis in Colombia ('observed' and 'expected') by department in a ...
1
vote
1
answer
58
views
Extent not found on NASA's Black Marble monthly images - How to set it?
I downloaded NASA's Black Marble monthly nighttime light (NTL), VNP46A3. The product is in .h5 format and it contains the radiance NTL raster as well as the scientific data sets (SDS) in order to ...
0
votes
1
answer
42
views
Distance measure that constrains a walk over land and accounts for the shape of the Earth
Are there distance measures that constrain a walk over land (even across multiple continents) and account for the shape of the Earth?
I have been using the Vincenty-Ellipsoid distance in R in package ...
0
votes
1
answer
38
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
1
answer
22
views
Error using "if" in R: "== : missing value where TRUE/FALSE needed" for spTransform
I am trying to make the projection of a set of coordinates identical to a shape from wrld_simpl. But I keep getting the error below. How to solve that?
d=read.csv()
it= wrld_simpl[wrld_simpl$NAME == &...
0
votes
1
answer
27
views
Get values from raster file in R
I have never used satellite data and I'm using NASA's information of PM2.5 "Global Annual PM2.5 Grids from MODIS, MISR and SeaWiFS Aerosol Optical Depth (AOD), 1998-2019, V4.GL.03", I got it ...
0
votes
0
answers
36
views
Spatial Autocorrelation in R
I have a point pattern with which I would like to test for spatial autocorrelation (Moran's I). All of the examples I have seen test for autocorrelation for some variable y, however, since I just have ...
0
votes
1
answer
34
views
read geojson file which is not in CRS 4326
I have a geojson file which i need to read/convert to sf object
I read it with geojsonR package and it shows as lists of lists, but i need it to sf. I tried using st_read but it gives me "Error: ...
0
votes
1
answer
21
views
vis.gam spatial interaction output as a raster grid instead of plot object
I am trying to create an object that can be put into tmap or another GIS platform from my model output. I created a model using the gamm4 package that has a spatial interaction term. See an example ...
0
votes
0
answers
45
views
Resolving gaps between polygons
I have a large global shapefile with thousands of small gaps/sliver polygons between joined polygons (shared borders of countries). I joined the shapefiles using the sf R package, and have attempted ...
1
vote
1
answer
72
views
Function to draw lines based on starting point, angle and length
I have used an R script to calculate the distance from a point within a polygon to the edge of the polygon at 1-degree increments. This has been saved as a CSV file. I am now wanting to create a ...
0
votes
1
answer
55
views
Using st_intersects to classify points in a multi polygon
I have a list of lat/lons and want to determine which county they belong to, by intersecting them with multi polygon dataset using sf::st_intersect. I can successfully perform the intersection and get ...
2
votes
1
answer
83
views
Filter raster by taking the max of a Gaussian filter
I have a raster which I applied a Gaussian filter. By "default", the Gaussian filter, takes the mean within the kernel. How can I take the max, instead of the mean, within the kernel?
Here ...
0
votes
1
answer
49
views
What Does It Mean To "Clip" A Polygon?
I have the following dataset in R - this dataset contains a list of geocoded addresses (Canada) with their Postal Codes, Longitudes and Latitudes: https://www.dropbox.com/scl/fi/9kjoqsppb85ip0tdc5wmr/...
0
votes
2
answers
45
views
Error while trying to train RandomForest in R
I have this data:
diff is the results of image difference from bitemporal imagery, and 2, 4, 6, and 8 is the bands of PlanetScope imagery.
When I trying to train this data using RandomForest, ...
0
votes
1
answer
18
views
Function applied to Raster cell values also executes to NA values in R
I'm trying to fuzzify a Terra SpatRaster object using a Fuzzy membership function created with FuzzyR package using the method Terra::app, but the function is also aplied to NA values. How can I avoid ...
0
votes
0
answers
22
views
Error installing FIELDimageR in R
I am trying to install the FIELDimageR library, I follow the recommendations indicated on
Github, I have tried to install it in the three ways indicated in the install section:
form 1
install.packages(...
1
vote
0
answers
32
views
R raster plot produces small/barely visible grid cells with large gaps in between
I have a dataset with lat/lon coordinates. I've converted the dataset in R to a raster layer using raster::rasterFromXYZ (Raster package). The dimensions of the raster layer are: 1249, 2551, 3186199 (...
2
votes
1
answer
35
views
Create conical gradient around a point using R
I have a point on a map that I am simulating bird movements from. I'd like to create a raster grid around this point with a conical gradient, similar to the picture below.
The idea is that the birds ...
0
votes
1
answer
37
views
Calculating statistic for pixels within specified neighborhood in R
I have a raster with coded values of either 0 or 1. For each pixel, I want to calculate the percentage of 1s within a 500m radius. Using the focal() function in the terra package seems to be my best ...
0
votes
0
answers
60
views
Replacing cell values from a SpatRaster to another binary stacked SpatRaster under certain conditions in R (terra Package)
I have a binary stacked SpatRaster bstacked_fht whose 25 layers correspond to presence/absence data for different forest habitat types. Instead of having only values 0 and 1, I want to replace the ...
1
vote
1
answer
53
views
Problem with creating elevation cross sections using R and terra
The terra::extract function samples raster data from the top to the bottom and from left to right. This creates an issue if you're using a line to sample a raster with plan of plotting the data as a ...
1
vote
1
answer
67
views
Aggregate a simple features collection in R by a factor variable
I'm trying to aggregate a simple features collection using a group variable that is a factor. Below is a simple example.
library(sf)
#> Warning: package 'sf' was built under R version 4.2.3
#> ...
0
votes
0
answers
16
views
How to add attributes to a raster stack
I have a dataframe ("DataGroup"), which holds tracking data from individual birds. Each bird has a unique id ("ID"), and belongs to one of 10 study groups ("DGroup").
In ...
0
votes
1
answer
33
views
Edit the value of polygons depending on the presence of points in it
I have a shapefile (regions of France) and points (.CSV). Both are in WGS84 (EPSG:4326) and both overlap perfectly with the tmap package. I would like to color the regions according to the presence, ...
0
votes
1
answer
67
views
Building a shapefile for Canadian postal codes
Background: I am working with the R Programming language. I am looking for a shapefile of Canadian Postal Codes - but unfortunately, there is nothing available online for free. Therefore, I had the ...
0
votes
1
answer
19
views
spdep::localmoran How to access classified cluster values?
I am trying to get a LISA cluster map similar to this one, eg showing the 'High-high', 'Low-Low'.. cllassified values.
But, I can't figure out how to extract this classifications from the ...
0
votes
0
answers
27
views
Query Oracle for new data based on properties of visible markers?
I'm very new to R/Shiny/Leaflet.
I have a barebones working example where I can display points on map based on their lat/long in a table I pull from Oracle:
siteData <- conn %>% tbl(in_schema(&...