Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [r]

Statistical computing language and software environment.

0
votes
1answer
19 views

Merging two spatial objects in R: spCbind gives error “row names not identical” [closed]

## Importing map of Brazil map <- readOGR ("UFEBRASIL.shp") class (map) plot (map, axes = F) title ("") ## importing file with case data data <- read.csv2 ("cases.csv") # Recognizing the names ...
0
votes
0answers
24 views

Joining CSV and shapefile by two fields?

I have CSV (mydata) and shapefile (nc). I want make such as merged = left_join(nc, mydata, by= nc."NAME", by mydata."Country") How make it?
0
votes
1answer
44 views

Joining CSV and shapefile to map using R?

I have one CSV file and one shapefile mydata <-readr::read_csv("~/map/done.csv") mymap <- shapefile("~/map/tyumen.shp") How merge it to one table and draw plot? map_and_data <- merge(...
0
votes
1answer
30 views

Use sf (R) to return the overlapping area between two polygons by rows?

I have two sfc data frames with the same number of rows (individual IDs), but each data frame contains a polygon assigned to the individual. For example, dataframe1 may have a circle assigned neared ...
1
vote
0answers
48 views

st_buffer() not preserving the shape of the original polygons [closed]

I am currently trying to create buffers of 5km around polygons of the region of interest. However, every time I increase the radius from 500 metres to 5000 metres, the shape of the buffer is not ...
1
vote
1answer
31 views

R or Python geometry checker that outputs results as table

Is there a R or Python solution that 1) checks the geometry validity of vectors and 2) outputs the results in form of a table (see table below). QGIS for example has a nice plugin that carries out ...
1
vote
0answers
63 views

After installation of gdal (to enable PostGIS tools) on Windows, sf gives warnings about dependencies?

To get a PostgreSQL/PostGIS setup working on my Windows 10 machine I had to manually install GDAL using these instructions: https://sandbox.idre.ucla.edu/sandbox/tutorials/installing-gdal-for-windows ...
3
votes
1answer
49 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
1answer
45 views

Combine bands with shapefile [duplicate]

I want to create a data frame in R combining the bands wth the shapefile. The final file will have the pixels as rows, the bands as well as the other columns from the attribute table from the ...
0
votes
1answer
41 views

Input points shapefile in shiny app

The application I created allows me to import a polygon shapefile into my Leaflet map. However, I would like to set up a point shapefile import on the same button. I tried several attempts, especially ...
0
votes
0answers
15 views

Day of the year values of pixels

I am trying to implement TWDTW model in R with dtwSat package. (You can find all the data here: https://www.jstatsoft.org/article/view/v088i05) In page 12, the paper gives a method to produce a land ...
0
votes
2answers
39 views

Reading shapefiles using for loop: Error in readOGR() : length(dsn) == 1L is not TRUE

I'm using a for loop to read in multiple shapefiles within a directory and manipulate them individually. Presently I cannot do this because the for loop results in the error: "Error in readOGR(...
0
votes
1answer
36 views

Mask with ring polygon in R?

I'm trying to mask a raster with a ring polygon using the function raster::mask, but only recognizes the outer edges of the polygon, can anyone help me with this? I only need the pixels within the ...
3
votes
0answers
22 views

Split a tmap legend and display in two locations

I would like to split the legend of a tmap object, so that one of the two elements is in the top left, and one in the top right. I have been through the documentation of tm_legend, but could not find ...
4
votes
1answer
92 views

How to use lastrees on a catalog with a function requiring a CHM raster?

I'm still fairly new to using LiDAR data and R, so please let me know if this isn't clear. I am using the lidR package to segment individual trees over a large landscape. I have been using the ...
1
vote
1answer
42 views

Splitting an administrative region into given number of parts

I have the following plot. I want to divide the administrative region into given number (say 20) equal parts. library(maps) data(world.cities) Pakistan <- data.frame(map("world", "Pakistan", ...
2
votes
0answers
27 views

Smoothing MODIS LAI? [closed]

I am trying to smooth 8 days LAI data from MODIS and managed to work around it with several algorithms such as loess, Savitzky–Golay, smooth.spline etc. This is pretty much going well if the level of ...
0
votes
1answer
24 views

Order features in a spatialpolygonsdataframe in ggplot2

I have a spatialpolygonsdataframe with many overlapping features. I want to create a map in which the smaller features are displayed on top of the larger ones so that the small ones aren't fully ...
0
votes
0answers
29 views

Using BFAST Spatial algorithm in R?

I have 65 monthly MOD11A2 (LST) images. The images came from the average of the original 8 day products. I have made them a time series stack using the timeStackMODIS function of the bfastSpatial ...
0
votes
0answers
17 views

How long should a spatial mixed model with spaMM take?

I have a dataset that's about 5k lines long, with a binomial response variable, five continuous fixed effects, and one random effect with seven levels. I initially ran a model with glmer{lme4}: glmer....
1
vote
1answer
24 views

What unit is returned by the ncf::correlog function?

I'm using the correlog function from the ncf package to figure out the distance between points at which spatial autocorrelation isn't detected. I was wondering what unit was being returned in the ...
0
votes
2answers
61 views

Dissolve only overlapping polygons in R using sf

I extracted information from open street map that contains many polygons, some of them overlapping. I want to union all polygons that overlap with other polygons. This question has been asked before ...
1
vote
0answers
44 views

Reset / Clear button, upload shapefile on R Shiny

I would like to create a button that would allow me to reset a fileinput, and delete the previously imported shapefile. Here is my code: server.r: library(shiny) library(shinydashboard) library(...
0
votes
0answers
34 views

Multiple break levels in color legend

Please look at the color legend of the image: This image was plotted in ferret program, which has different breaks, like 0-3 with 0.5 interval, 3-9 with 3 interval, 9-10 with 1 interval, 10-20 with ...
0
votes
0answers
17 views

Is there a way to get coordinates from a map using Leaflet on a Shiny app in R by clicking, but without a marker?

In this example I have some polygons and I click on the centroids (variable centroides) to get values from a raster (variable s). server <- function(input, output, session) { points <- ...
1
vote
1answer
67 views

What causes Error in ogrInfo when using readOGR to open a layer in a shapefile? [closed]

When I use readOGR to read a shapefile from thematicmapping.org, the shapefile is successfully displayed by leaflet in a shinyapp. However, when I use readOGR to read a shapefile from mt.gov, the ...
0
votes
1answer
21 views

Write a text file per image with same name in R

In R I would like to create a text file for each picture I have in a folder and with the same name. By example: Picture 1.png - Picture 1.txt Picture 2.png - Picture 2.txt But the text file name I ...
1
vote
0answers
38 views

Extract Raster Values with points in R

I have a raster file with gridded population raster26 class : RasterLayer dimensions : 132, 140, 18480 (nrow, ncol, ncell) resolution : 699, 931 (x, y) extent : 2248290, 2346150, ...
2
votes
2answers
33 views

st_transform producing spurious ribbons across region

I am trying to use st_transform on PERZONES shapefile available here . In its native projection, it looks like this: However, when I run the command: tansformedPF<-st_transform(PF,"+proj=sinu +...
0
votes
1answer
33 views

Correcting scale of heatmap data when plotting GeoTIFF file as map in R?

I'm trying to use R (and R studio) to examine a GeoTIFF file that I've gotten from NASA's Socioeconomic Data and Applications Center (SEDAC). I'm a complete beginner in GIS, so as a first step, I was ...
0
votes
1answer
47 views

Subdivide raster file by polygon in R

I am trying to get a raster file of nightlights data for Brazil and subdivide/regroup it into several rasters for each state, in a list or data.frame in R I managed to download the nightlights file, ...
1
vote
2answers
42 views

Create a circle in R, and plot it in a shapefile

I want to plot a circle with a radius of 5 miles around a hospital in Massachusetts. I was using some previous answers found here, but it is not working. st_buffer shows an error. library(sp) ...
0
votes
0answers
7 views

Is it possible to assign values from polygons to a new layer in an existing raster in R?

I'm a bit of an R novice and looking to see if there is any way to assign values to a raster layer based upon polygons. Some background - I am working on a mining project and have a regular grid of ...
1
vote
1answer
27 views

How to reproject a raster based on another raster when the datum is not said and get the same extent?

I am working with two rasters. I am trying to reproject r1 the same way as the raster r2. Rasters are available here r1 class : RasterLayer dimensions : 30286, 58025, 1757345150 (nrow, ncol,...
1
vote
1answer
40 views

Filling NA values of raster stack using R?

I am trying to fill NA values of a raster stack with interpNA but the first raster stays empty. I wish to obtain similar results as in substituteNA in a sense that all rasters of the stack are filled. ...
3
votes
1answer
58 views

Same equal area projection results in different areas when shifting the center of projection

I found that using an equal area projection results in different areas for the same polygons if you shift the center of projection (ie to minimize the distortion of your area of interest when you ...
1
vote
1answer
24 views

Raster calculation over multiple layers using a function or do-loop

I have a bunch of raster calculations that are working, but there must be a more efficient way to do this with a do-loop or function. Essentially I have a bunch of combinations of: rates (county ...
3
votes
0answers
56 views

Create foldable section in QGIS tool using R script

I am developping a GUI tool in QGIS using an R script and I am wondering how to add this kind of foldable section in the graphical interface.
1
vote
1answer
51 views

How to create georeferenced dataset from georeferenced satellite image? [closed]

I downloaded a nighttime light composite satellite image (https://ngdc.noaa.gov/eog/dmsp/downloadV4composites.html#AVSLCFC) which uses a scale for light intensity from 0 (no light) to 63 (max light). ...
-2
votes
1answer
17 views

Loading multiband image using brick() fails?

Here's my working environment, R version 3.4.4/R Studio version 1.0.143, below is the line of code that fails : Image<- brick(ImageName.tiff) brings the error below : Error in .local(.Object, ......
0
votes
1answer
31 views

Using st_read to create an owin in R

I have updated a program because readShapePoly has been replaced by st_read. Changing from: unzip(paste(mdir, "AU_Vic_POA_2011.zip", sep = "")) boundary.shp <- readShapePoly("...
1
vote
2answers
27 views

Errors fitting a Markvov Random Field GAM with multiple samples per Polygon

all, after reviewing this excellent tutorial, I'm trying to expand out my use of GAMs for space and time. I'm trying to use the Pennsylvania smoking and cancer data, but am running into a problem when ...
0
votes
1answer
32 views

Obtaining pixels between 2 raster layers (border)?

I have a rasterStack obtained from a stack of 3 raster layers by: image = stack(A, B, C) I would like to calculate the distance between the pixels of layer A and pixels of layer C. After ...
0
votes
0answers
27 views

Basin Delineation using R

I am trying to get the polygon of a basin boundary using R. I got a 7.5 arcsec DEM that I download from this page: https://topotools.cr.usgs.gov/gmted_viewer/viewer.htm I look through a lot of ...
1
vote
1answer
46 views

Importing shapefile into R [closed]

I don't understand why I should choose readOGR() over readShapePoly. What are all the different ways of doing this, and why should I choose one over another?
1
vote
1answer
24 views

R: polygons' id different than @data id after load from shapefile [closed]

I loaded a shapefile in R using readOGR and I named as data.map. I can see the shape pretty well by using plot(data.map) The issue is that polygons' id (the id of the plot) is not the same with the ...
1
vote
1answer
25 views

Range value of raster data varies before and after mosaic implementation

I am trying to raster::mosaic bunch of .tif files extracted from hdf4 MODIS files. My script is working fine but I am puzzled by the range of raster values (min, max) before and after data processing. ...
0
votes
1answer
52 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
vote
1answer
35 views

GLCM function for RasterStack using FOR loop in R

I would like to calculate glcm function in R for all (52) bands in my RasterStack. Using this code: LS<-stack(img1,img2,img3,img4,img5,img6,img7,img8,img9,img10,img11,img12,img13) names(LS) <- ...
0
votes
2answers
29 views

How to save a plot to disc with tmap in R

I have made a plot with these lines mainland print(Bornhold, vp = viewport(x = 0.7, y = 0.5, width = 0.3, height = 0.2)) One is mainland and the other an island. How can I save it to one one png ...