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
0
votes
0answers
6 views

Cannot bind Legend layer to Polygon layer in Leaflet/R

I try to plot a map of concentrations of chemicals. These have very different ranges, so a shared legend is not feasible. The ultimate goal is to have the different layers for the different chemicals ...
1
vote
2answers
26 views

R sf Polygon subtract 1000 from x coordinates

My aim is to subtract a value of 1000 from all x coordinates of an R sf object. How can I achieve this? When running the following code the value 1000 is subtracted from all coordinates (x and y ...
0
votes
0answers
10 views

R: gdal_translate/gdalwarp/gdalUtils for georreferencing raster

I am currently working on georreferencing a 530 X 587 .bmp file called my_raster.bmp with gdal_translate and gdalwarp from gdalUtils package, which is equivalent to using GDAL with those commands. ...
-1
votes
0answers
19 views

Is it possible to query a geopackage (.gpkg) for features within a given bounding box?

I have GIS data with a very large layer stored within a geopackage from where I want to select features that fall within a bounding box calculated in my R session. I begin by creating a query string: ...
1
vote
1answer
33 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
1answer
1k views

spTransform error (unable to find inherited method for function spTransform)

I am trying to reproject a shapefile. For example, the land shapefile from Natural Earth. library(sf) shape <- read_sf(".../ne_10m_land.shp") shape_proj<-spTransform(shape, CRS("+proj=gnom +...
1
vote
0answers
22 views

Image smoothing

I have 9 layer stacked DEM raster image in .tif format. I would like to smooth the image using focal() function in raster package in R. img <- brick("/stack.tif") img <- focal(img, w=matrix(1,...
6
votes
2answers
7k views

Converting NZMG (or NZTM) to latitude / longitude for use with R map library

I am a statistician with no background in GIS so apologies for the newbie question. We routinely use R for a range of statistical and graphic analysis and are interested in using its map library to ...
0
votes
1answer
55 views

Plot GeoTIFF using tm_rgb from R tmap package

I've exported a raster object from QGIS into GeoTIFF format and imported it into R as a raster brick using the brick() function from the raster package. The file is too large to share but it imports ...
1
vote
1answer
17 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 ...
9
votes
1answer
4k views

R fortify causing polygons to tear

I'm am having some trouble plotting my spatial data using ggplot2. The map looks fine when plotted using spplot, so I'm assuming that the tearing occurs at the fortify stage. The code is as follows: ...
2
votes
1answer
37 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
1answer
23 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 ...
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", ...
6
votes
1answer
2k views

Clipping raster brick object in R

I have MODIS NDVI TIFF files for a year I want to first clip it with a irregular polygon (not by its extent only) of my study area and save it as a multi band raster in TIFF format The TIFF image are ...
0
votes
0answers
14 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 ...
3
votes
1answer
36 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 ...
2
votes
0answers
18 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
0answers
25 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', ...
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 ...
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 ...
6
votes
2answers
2k views

Create raster with grid cells values based on area covered by polygons

I have a polygon data with area covered by the forests (data is here - https://www.dropbox.com/s/zgckliydalljw6a/sp_data.zip?dl=0). I want to convert polygons to raster. The value of each grid cell ...
-1
votes
0answers
22 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
1answer
22 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
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 ...
32
votes
4answers
24k views

Overlaying spatial polygon with grid and checking in which grid element specific coordinates are located using R [closed]

How can one use R to split a shapefile in 200 meter squares/sub-polygons, plot this grid (incl. ID numbers for each square) over the original map below, and evaluate in which square specific ...
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
0answers
26 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
32 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
82 views

Setting origin raster to resample using R?

I need to resample a raster from nrow= 467, ncol=805, res=0.0416667 degree to nrow=2335, ncol=4025, res=0.00833333 degree. Basically make the pixel size smaller, because I have too many small polygons ...
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 ...
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
36 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 (...
3
votes
1answer
53 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
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 ...
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
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 ...
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 ...
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 ...
4
votes
2answers
1k views

Merge rasters with different origins in R

I have a list of rasters with the same projection and resolution but different origins and I need to merge them in a single raster file. Here's my code l <- list.files('path', full.names=TRUE) ...
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 ...
5
votes
1answer
4k views

Using a fixed palette range to plot an NDVI raster in R

I would like to plot an NDVI raster with rasterVis packages using the normalized colors from red to green. I don't understand how fix the color scale from 0 to 1 even if my raster value are between 0....
4
votes
1answer
129 views

Using R-scripts in QGIS 3.4

I installed the Plugin, and activated R in the provider options. When I go to the processing toolbox R is available, but I don't have the use online R-scripts, which are mentioned in the documentation....
3
votes
2answers
300 views

Missing R scripts in QGIS 3 after install

After install Processing R Provider plugin (v.1.0.1) in QGIS 3.4 I only got test.rsx. I'm able to create new scritps but I can't acess scripts already installed in my OS (Linux Mint 19.1) trough R ...
0
votes
1answer
21 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 ...
3
votes
1answer
333 views

Counting points in polygons with sf package of R? [closed]

I'm quite new to R and especially GIS with R. So recently I had to proceed to a quite simple analysis: counting health centers (points) per administrative unit (polygons). Quite common process in ...
1
vote
0answers
10 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 ...
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 ...