Questions tagged [r]
Statistical computing language and software environment.
5,856
questions
1
vote
1
answer
859
views
Removing data outside country map boundary in R
This is a location point dataset (lat and long) that I want to map, and I want to remove density lines outside the US map borders.
df1<-structure(list(Latitude = c(44.085655, 45.75582402, 44.465059,...
1
vote
1
answer
170
views
Use *jpg to create *jgw file using R
In my example, I have a single dji image in *JPG:
library(terra)
single.image <-rast("https://github.com/Leprechault/trash/raw/main/DJI_0274.JPG")
plotRGB(single.image, r = 3, g = 2, b = ...
1
vote
2
answers
1k
views
Renaming and exporting a list of rasters using terra
I've a list of hundreds of rasters that I've renamed, but when I export using writeRaster, the filenames have not changed.
For example:
library(terra)
library(tidyverse)
# all the of the packages I ...
1
vote
1
answer
54
views
Delete polygons from layer 1 with polygons from layer 2 based on a common attribute between both layers
I have two layers with a large number of polygons. Layer 1 are the polygons I want to crop (green border) and layer 2 are the clipping polygons (red border). Both layers have a common identifier in ...
1
vote
3
answers
85
views
Intersecting objects and converting it to simple features so I can use 'raster', R
This question is connected to: How to create a regular, square grid, and find centroid by factors using R
I have a data frame which have three columns: (1) the "scientificName" column ...
1
vote
2
answers
675
views
Change raster cells non-NA values based on the longitude using R terra
I would like to change all the non-NA cell values based on the cells longitude. For instance, any cell that had a non-NA value and a longitude greater than x would have the value replaced with y.
I ...
0
votes
0
answers
91
views
Equivalent of gCentroid(x, byid=FALSE) in sf system?
I am attempting to change a number of scripts from the sd world to the sf world and am running across a problem that I feel really should have a simple solution (and probably does; I just can't find ...
2
votes
1
answer
79
views
Exporting an sf dataframe from R changes integer attributes to float attributes
I've noticed when I write an sf data.frame from R and open in QGIS, it seems to convert all of the numeric attribute values from integer to float (even though they should be integer). I'm not sure if ...
0
votes
1
answer
293
views
Rasterize sf object in R (desired cell values 1 and 0)
I have a vector file (multipolygon) in class sf, which I want to turn into a raster of a certain extent. I need all the areas where polygons are located to be value 1 and all areas where no polygons ...
1
vote
1
answer
551
views
How to create a regular, square grid, and find centroid by factors using R
I want to create a regular, square grid of .5x.5 degree around my sampling points and find latlong centroid by factors.
I have a data frame which have three columns: (1) the "scientificName" ...
0
votes
2
answers
779
views
Raster calculations in R
I have two rasters, one with land use data (raster A) classified in discrete values that represent different classes (1,2,3,4,5...18). The other one (raster B) contains data that can represent ...
0
votes
0
answers
33
views
Date is missing in CRU data
I used the following code to extract "Climate research Unit" climate data. However extracted data showing "Date : NaN, NaN (min, max)".
pre <- brick("cru_ts4.06.1901....
0
votes
1
answer
23
views
Date in CRU data is starting from 380 instead of 1, since unit is days since 1900-1-1
I ran the following line of command. Below result show that:
" time Size:1380 *** is unlimited ***
long_name: time
units: days since 1900-1-1
calendar: gregorian
daily_rain <- "...
1
vote
0
answers
150
views
Transformation from Lambert azimuthal equal-area to WGS84 uncovers polar region
I'm having an issue where a transformation from a projected coordinate system (Lambert azimuthal equal-area) to WGS84 changes the shape of my polygon near the polar region. The real data creates a ...
0
votes
1
answer
114
views
Get intersects of indexed grouped polygons between 2 SpatialPolygonDataframes in R
I am testing 2 different methods (m2b & hmm) for classifying the movement behaviour of penguins to ultimately classify feeding behaviour from GPS points and from these create kernel polygons to ...
0
votes
0
answers
101
views
Generate unconditional simulations with same nugget, sill, and range
I am a newbie with gstat and unconditional simulations. As I understand, unconditional simulations should have the same nugget, psill, and range, but they do not (except nugget) when I use gstat in R. ...
0
votes
1
answer
1k
views
What might have caused this error "x cell sizes are not regular"?
I am doing a landuse classification. I tried to convert values to raster using this:
x<-SpatialPointsDataFrame(as.data.frame(grid.data)[, c("x", "y")], data = grid.data)
r <-...
0
votes
1
answer
104
views
R equivalent to the ArcGIS's Shape Metrics Tool
I am trying to calculate the compactness of (vector) polygons in using R.
My main reference to do so is this paper. There used to be an ArcGIS toolbox (Shape Metrics) to calculate these metrics. ...
1
vote
1
answer
262
views
Dissolving large shapefiles of protected areas in R
My overall aim is to measure the number of GPS points that overlap with protected areas. I am using the protected planet database to source my shapefiles for Ireland and the UK.
I don't need any ...
1
vote
1
answer
490
views
Calculate poygon area in km2 from degrees to km2 in R
I found this but I think it is possible.
I am trying to calculate the area in Km2 of a polygon given by the vertices in degrees:
library(pracma)
x= c(-40.03953, -44.24278, -40.90583, -35.55361) #those ...
0
votes
0
answers
40
views
How to stack/merge geom_stars items/plots in one - in R
If I have plotted the Relative Error Maps for the Silt soil attribute for the following 4 different soil types: Cambisols, calcisols, leptosols and fluvisols that form my study case area:
ggplot() +
...
8
votes
5
answers
6k
views
Create a ground overlay kml from georeferenced raster
I have a world georeferenced raster (5m resolution, ~4000 x 4000 pixels) that I would like to display in google earth. I am looking for a simple and effective way to generate this kml file.
Using ...
2
votes
1
answer
142
views
lidR: "Argument is not a LAS object" when using catalog_apply
I am using the lidR package to read lidar data (LAZ format), then using clip_roi() and normalize_height() to process the data for the segment trees function. These functions are being executed within ...
1
vote
1
answer
68
views
Recover historical shoreline extract from Google Earth Tool and .mdb using Ubuntu OS, NOAA T-00267
For a birthday present for my father-in-law, I want to get historical shoreline data viewable in Google Earth into a format I can read into R and use with the sf package, specifically table T-00267, ...
1
vote
0
answers
261
views
Combine a polygon map on top of a raster map in R
I would like to combine a shapefile map of some US states on top of a raster map obtained from using library ggmap.
This is the code I have
library(USAboundaries)
library(ggmap)
library(ggplot2)
...
3
votes
1
answer
178
views
R lidR catalog_laxindex() spatial index options
Is it possible to set the las catalog processing options to create .lax files by default?
Something like lidR::catalog_laxindex(ctg) <- TRUE
5
votes
2
answers
2k
views
R- alphahull - duplicate points error help
I am just starting to use R.
I came across R function -alphahull- and believe it is the best option to turn gps points into a polygon (3 or 4 days worth of gps points across residence/neighborhood for ...
0
votes
1
answer
62
views
Finding the uncertainty for the fractal dimension of spatial data using fractaldim package in R
I am able to use the below code to calculate the fractal dimension of a spatial data using R package 'fractaldim'. I need to find an uncertainty value associated with this. The function accesses the ...
1
vote
1
answer
125
views
Clipping using R and ArcMap do not match
I am carrying out a Raster clipping from a shapefile, using its exact shape.
I have done a clip using the Clip (Data Management) in ArcMap. The "Using Input Features for Clipping Geometry (...
0
votes
0
answers
49
views
Spatial neighbors to voxels for R-INLA
I am working on an fMRI dataset that I want to analyse using a Bayesian spatial model in R-INLA. I extracted the coordinates for all these voxels. (See the image to get an impression one such a ...
2
votes
1
answer
79
views
How can I create a 3-dimensional cube legend (R)?
Has anyone ever plotted a 3-D (cube) legend as shown below? Essentially trivariate mapping.
I would like to recreate the below using the same variables of population, built (% area that is built up) ...
0
votes
1
answer
114
views
Calculate argmax and second argmax of a RasterStack in R
I need to calculate the argmax (index of the maximum) and index of the second maximum of a RasterStack in R. That is, for each pixel of the image, I need to evaluate in which index (layer) is the ...
3
votes
2
answers
486
views
What is the canonical way to perform raster calculations using R stars?
I have a data cube that I am handling in the R stars package. It has 3 dimensions (latitude, longitude and time) and 2 attributes (northwards and eastwards components of wind). A dummy equivalent ...
1
vote
1
answer
260
views
What is the lidR filter_poi() equivalent to readLAS(..., "-keep_last")?
With the excellent lidR package we can filter at C++ level when using readLAS(), e.g. with the following syntax
lidar = readLAS(LASfile, filter="-keep_first")
or when the pointcloud is ...
1
vote
1
answer
155
views
Extracting pixels from a raster list according to a value range and position in R
I'm working on a script on R and I have a doubt.
I have a directory with a raster dataset of NDSI MODIS files.
I want to create a list(or stack) of rasters whose first pixel (x=1, y=1) value is ...
4
votes
1
answer
3k
views
Spatial interpolation from categorical data in R
I have a spatial point data set, where each point represents a person pronouncing a word in a specific fashion. Let's say I have six different pronunciations.
In an earlier iteration, I aggregated ...
0
votes
0
answers
179
views
Spatial Outliers Detection and Remove in R?
I have run my data in R, and created a distribution mapof my data (Clay Soil Property).
I want to detect in a way the spatial outliers that i can see from the map, and remove them in order to execute ...
0
votes
2
answers
405
views
Need TIGER/line national (USA) road files, not per county
I'm trying to get the TIGER/line files for roads to create a raster of major and minor road density for about half of the USA.
The problem is the interactive tool provided
(https://www.census.gov/cgi-...
6
votes
1
answer
3k
views
How can I both resample and aggregate a raster using Terra?
I essentially have the same issue described here, but this question has not been answered Can I resample a raster in R using "max" as function?.
I have a elevation raster with a resolution ...
2
votes
2
answers
2k
views
Splitting overlap between polygons and assign to nearest polygon using R?
My question is how to perform the process described in the answer to this similar question in R, ideally using the sf package. In the linked case this is done using using PostGIS with some sf commands,...
1
vote
0
answers
345
views
Making map with marginal graphics like rasterVis::levelplot(margin=T)
I love rasterVis::levelplot(margin=T) because its marginal graphics show the column (x)
and row (y) summaries of the Raster object. I think it is very helpful to visualize the raster.
Package ...
0
votes
1
answer
112
views
Using ncf package to generate correlograms and calculate Moran's I
I'm trying to use the ncf package in R to generate correlograms and calculate Moran's I for some data on archaeological human remains. This script seems to work:
jomcor <- correlog(x = jomon$NCLat,...
0
votes
3
answers
187
views
Processing raster present as MS Access database
I wanted to know if anyone has experience working with WISE soil database, I am trying to process world soil data which is downloaded from here
https://data.isric.org/geonetwork/srv/eng/catalog....
1
vote
1
answer
1k
views
How can I add size parameters in an uiOutput element for a R "shiny" application?
I'm developing an R "shiny" application where it is necessary to pass size parameters (width and height) different to the corresponding defaults, for a leaflet map, for avoiding issues with ...
4
votes
1
answer
150
views
How to infer a given (EPSG) projection property: is it area-, scale- or distance-preserving?
Imagine you are given a EPSG:abcd crs code, and would like to know the properties of that crs, i.e. you want to know whether it is area-, distance-, scale-preserving etc.
Are there tools (ideally in R)...
1
vote
1
answer
422
views
Representing different borders in tmap legend
my map looks similar to this one:
# import shapefile
shape_data <- system.file("shape/nc.shp", package="sf")
shape_data <- st_read(shape_data)
sample_data <- filter(...
1
vote
1
answer
143
views
rkt Package function on time series analysis is returning error
I am working with an NDVI time series raster composite (1989 to 2019). I am running a time series function on each pixel of the raster stack using the R code provided by Pironkova et al. 2018. The ...
0
votes
1
answer
849
views
Creating hexagons around polygon using sf
I create hexagons within a polygon perimeter using either the sp package or the newer sf package. Page 134 6.4 of Bivand et al.'s (2008) "Applied Spatial Data Analysis with R" gives an ...
1
vote
1
answer
62
views
Assigns geographical locations to the pixels in isolate drone image in R
In my example, I have a single dji image in *JPG:
library(terra)
single.image <-stack("https://github.com/Leprechault/trash/raw/main/DJI_0274.JPG")
plotRGB(single.image, r = 3, g = 2, b =...
2
votes
1
answer
168
views
Euclidean distance from vector features for radiotracking data in R
I have a radiotracking dataset (ca 5000 rows) like this
Animal Date Time Latitude Longitude
Pepe 21/12/2020 23:00:28 52.25938 15.50511
Pepe 21/12/2020 19:00:15 52.26251 15.52726
Pepe 21/12/...