Questions tagged [r]

Statistical computing language and software environment.

Filter by
Sorted by
Tagged with
6
votes
2answers
1k views

Generating random points inside raster boundary using R?

I have a projected raster shown in the image below (left). I want to generate random points inside the raster like the middle image. However, the result I am getting is the same as the image on the ...
6
votes
2answers
1k views

Return end-vertices of an sf linestring

I am trying to return the vertices of a linestring using the sf package. So far I have: ls <- st_sfc(st_linestring(rbind(c(0,0),c(0,1))), st_linestring(rbind(c(0,0),c(10,0)))) ...
6
votes
1answer
2k views

Calculating distances between two geometry columns using R?

I'd like to calculate the pairwise distance between two geometry columns. That is, I want to calculate the distance between several pairs of geometries without calculating the full distance matrix ...
6
votes
1answer
656 views

Wrap a raster at the 180° meridian

I have a raster file that extends longitudinally from 0° to 360°. Using R, I'd like to wrap the raster at 180°, so that longitudes between 180° and 360° are translated to the interval [-180°, 0°]. Is ...
6
votes
2answers
680 views

Map algebra in QGIS

How do you calculate standard deviation for each raster if you have set of rasters (100)? I was searching in raster calculator, but I didnt find it. Also google redirect me to using R or python. But I ...
6
votes
1answer
2k views

Clip raster by raster with data extraction and resolution change

I need to stack multiple maps (tif) together and clip them all according to extent of one small raster map (second raster at the top of picture below). However, the size of pixels in each map is ...
6
votes
2answers
780 views

Joining grid or polygon layers in R?

I have two grids. Cells in each grid have an attribute. Size of grid cells differs between the two grids and the two grids do not overlay each other perfectly. I would like to create a new layer, ...
6
votes
1answer
862 views

weighted mean across rasters in R

I have 2 rasters. One raster (bio1) contains temperature information across a continent. The other (sp) contains, for each cell, a probability of occurrence for a species. I would like to calculate ...
6
votes
3answers
4k views

Extracting values from raster according to Lat and long of values?

having 12 files with 12 hdrs for one year: these files are raster (projected WGS84,lat long): samples = 1440 lines = 720 bands = 1 header offset = 0 ...
6
votes
4answers
7k views

Dissolving ploygons in QGIS or Grass to new polygons of defined population sizes?

I have a shapefile with 3800 polygons representing the smallest administrative areas in Ireland. Many of these, in rural areas, have tiny populations, under 100 people. In urban areas, all would have ...
6
votes
2answers
312 views

Convert WKT coordinate reference system to PROJ4

I'm currently working on a better support of LAS 1.4 file format in the rlas R package. In LAS 1.4 format the CRS of the point cloud can be stored as a WKT string. For example this is what I read from ...
6
votes
1answer
1k views

Convert over 360 degree range of coordinates to +/-180 longitude range in R?

I'm working with data on sea surface currents from ftp://podaac-ftp.jpl.nasa.gov/allData/oscar/preview/L4/oscar_third_deg The data has the latitudes and longitudes saved in the following format: ...
6
votes
1answer
11k views

Assigning CRS to shapefile when it doesn't have one, in R?

I think that by using readOGR to import a shapefile renders worthless to put proj4string to the script since if any coords are available in the shapefile, it will be transported through the readOGR. ...
6
votes
1answer
2k views

How to create a US map in R with separation between states and clear labels?

I was trying to figure out how to create a map like down below in R on the Stack Exchange but maybe that's the wrong community and the GIS side is a better spot. Currently, I'm able to add the colours....
6
votes
3answers
813 views

How to do a looping to Interpolate a huge Rainfall Time-series in GRASS GIS or R

In GRASS GIS I have access to a table in PostgreSQL Database with this structure: Table Name: rainfall_time_series Columns: id | year | month | day | value_mm | x | y | gauge_code Setting g.region ...
6
votes
1answer
1k views

Kriging example with sf object

I am new to geo spacial analysis. I would like to learn kriging from a simple example. Say, we have four points with some z value. library(sf) library(gstat) library(tidyverse) dt<-tibble::...
6
votes
1answer
572 views

How to read a feature class in an Esri Personal GeoDatabase using R?

I have feature classes in a personal geodatabase on a Win 8.1 machine (r 3.4.2, rgdal 1.2-15) and, as mentioned here, there is a requirement for Access users to also interact with them. I have ...
6
votes
1answer
11k views

How to create custom discrete color scheme for polygon attributes in ggplot2?

Back again with more questions. :) Data: Zipped ea.ml1 shapefile can be found here, and the country outline can be downloaded here at the GADM site. I've been using the Ethiopia ESRI shapefile. As ...
6
votes
1answer
2k views

How can I parse modis MOD13Q1 quality layers in R?

I'd like to parse MOD13Q1 VI quality layers in R. My original code must have been incorrect, because it gave lots of "deep ocean" flags in the middle of Brazil. After the changes suggested by Mikkel,...
6
votes
2answers
4k views

Is there an R equivalent of NEAR in ESRI ArcGIS?

I have 54 points in one data set A I have 300+ data points in a dataset B. I wish to find the distance for each point in dataset-set B, to points in dataset A. Nearest Neighbor packages appear to ...
6
votes
3answers
1k views

Create a rectangular buffer from point shapefile using QGIS/GRASS/SAGA GIS/R

I have a points shapefile and I want to create a rectangular buffer (22 x 16 km) around each point. My goal is to create a 16x22 km grid where each of the points is the centroid of the grid. Seed the ...
6
votes
1answer
736 views

Why covariance values are different in R and ArcGIS?

I've calculated covariance between 7 rasters using R and ArcGIS. It gives me different results. Each times covariance values from R are approximately 1.874 times higher than ArcGIS values. R - ...
6
votes
1answer
3k views

Is it possible to create and run custom R scripts in QGIS 2.0?

I am new to QGIS and most of the tutorials I have found are for 1.x and the overhaul has me confused. I would like to create R scripts and run them in QGIS. I have read here that it's possible using ...
6
votes
1answer
4k views

Anyway to remove points outlying shape in ggplot2?

I am to map a plot of an area and then plot points over it (given by Easting and Northing). However, I found out that there are certain mistakes in the data entered for Easting and Northing resulting ...
6
votes
2answers
695 views

Using rpy2 in ArcGIS

I have a 3rd party python geoprocessing script that requires rpy2, and thus also r. What is the best way to get these working together? Using R with ArcGIS Desktop says the most useful option for ...
6
votes
5answers
5k 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 ...
6
votes
1answer
73 views

Addressing just the outermost cells in a raster?

I have a DEM cropped to the extends of a shapefile with different glaciers (see here for data: https://drive.google.com/open?id=1ERFdsqDGLH1a_FbxwawE_gPm0Au0Q9vT). DEM <- raster("***Glacier_Clip1....
6
votes
1answer
2k views

Split polyline by point using 'sf' package in R

I'm learning the sf package in R and would like to locate about 450 sites along the nearest reaches of a river network and to obtain the upstream and downstream distances along the reach where the ...
6
votes
1answer
4k views

Unable to install ‘sf’ R package on Ubuntu 16.04 LTS

I'm not able to install sf R package on Ubuntu 16.04 LTS. I tried install.packages("sf") as well as devtools::install_github("r-spatial/sf") after running sudo add-apt-repository ppa:ubuntugis/...
6
votes
1answer
183 views

Modify a script in the R Script repository in QGIS

I'm trying to use to R scripts available in QGIS via the processing Panel, and in the "Get R scripts from on-line script collection". I spotted some errors in the script "Kriging" that prevents it ...
6
votes
2answers
4k views

gDistance to determine closest point to polygon: does changing projection change results qualitatively?

I'm using gDistance from the rgeos package for R to find the nearest point to a polygon. The projection of both points and the polygon is +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,...
6
votes
1answer
457 views

Having trouble finding out what coordinate system a map is using, and how to convert it

I'm using Small Area shapefiles in Ireland from the Central Statistics Office (CSO) website. The link to these is here http://census.cso.ie/censusasp/saps/boundaries/ED_SA%20Disclaimer1.htm (Look for ...
6
votes
1answer
2k views

Self organizing maps and spatially Constrained Clustering in R

There are a few algorithms to perform spatial clustering in R but most of them focus on point pattern analysis (for example here). I would like to perform spatial constrained clustering for polygon ...
6
votes
1answer
1k views

Stats on individual grid points nearest neighbours

I have shp of points where each point is the centroid of the individual cells of a 1*1km grid (~ 500 000 points). For each of these points, I have their coordinates and elevation. What I want: for ...
6
votes
1answer
10k views

How to plot points on maps using ggplot2 and R?

Thanks for help me in GIS 101 Problem #1, now I have geocoded a few hospital in Connecticut using google map, I have able to visualize them in QGIS, now I am trying to do it in R. ct <- ...
6
votes
1answer
4k views

Spatial distance join between polygon and points using R?

I'm figuring out how to do a Intersection (Spatial Join) between point and polygons from shapefiles. My idea is to get the closest points and those points that match completely inside the polygons. In ...
6
votes
2answers
6k views

How to hide/toggle legends with layer controls in Leaflet for R

In the package leaflet for R, you have the ability to toggle layers on and off with the addLayersControl() option. If you use legends for each individual layer, however, these layers are not toggled ...
6
votes
1answer
3k views

How to calculate distance on large raster in R?

I'm trying to do some raster algebra and one of my layers is a distance from a coastline layer. I'm using rasters with 12.5m resolution and when I use the distance function, I seem to run into memory ...
6
votes
1answer
664 views

How to calculate turn rate from a GPS log?

I'd like to calculate a rate of turn from a GPS log (GPX file). Each trackpoint in a GPX track has location and time, and in addition to speed (a common calculation and sometimes embedded in a ...
6
votes
1answer
740 views

Segmentation of a big raster

I'm trying to convert one raster into a SpatialPolygons. I've got a big raster (12 millions pixels) with a lot of zeros, and some negative values (representing some depression in a DEM). I would like ...
6
votes
1answer
1k views

Classical or robust variogram for incorporation into generalized linear model

I'm modeling counts of organisms over time at eleven locations. I'd like to account for temporal autocorrelation in the counts, assuming it's present. As the data are not equally spaced in time, I'...
6
votes
2answers
3k views

How to split a polygon using R

I have an irregular polygon which is a spatial object. I want to divide it into multiple polygons (say, n=25) with equal height. To show how I want to divide it, I've plotted grids on the background ...
6
votes
2answers
1k views

R packages for deriving spatial clusters from origin-destination matrix

I have a matrix of origin-destination flows and I am trying to figure out the best way to derive X number of functional spatial clusters from the data. I haven't done this particular type of analysis ...
6
votes
1answer
4k views

How to create a crisp topographical/terrain map with ggplot2?

I am trying to produce a high quality vector based map (in greyshades) in order to report locations. I tried this by getting maps from GADM and SRTM to make a raster as a base for plotting in ...
6
votes
1answer
803 views

NA values in my raster after changing the resolution, extent, and origin

I'm working with two rasters that differ in their origin, extent, and resolution. I have a bathymetry raster, with a very high resolution (x=0.0008333333, y=0.0008333333) and a MUCH great spatial ...
6
votes
1answer
416 views

Krovak projection EPSG 5514: Correct data transfer between R and ArcGIS?

I have a problem which many ArcGIS, QGIS and R users from Czech Republic and Slovakia may encounter. In ArcGIS, I am working EPSG: 5514, Projected Coordinate System, defined as: S-...
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 ...
6
votes
1answer
904 views

How to perform a non-linear regression pixel by pixel?

Using nlsLM from Package ‘minpack.lm’ is straightforward for a simple example like this: MODEL:y=(exp(a*x+b*z+c)+d)^f x=c(0.5,0.3,0.2,0.4) z=c(0.1,0.6,1,0.9) y=c(0.2,0.3,0.9,0.9) fit=nlsLM(y~(exp(a*x+...
6
votes
1answer
1k views

How to convert an Erdas training set to .csv?

I am working with Erdas Imagine's Signature Editor to perform maximum likelihood classification. I need to use the same training set created in Erdas for other classification using R. Is there a way ...
6
votes
2answers
2k views

rpy2 installation on Mac OSX. A still unresolved problem on StackExchange and rpy-list [closed]

following lgautier's advice on rpy2 installation on Mac OSX, I posted my request on rpy-list and got in touch with Yair Benita who said he could only install rpy2 through his default Mac OS X python ...