Statistical computing language and software environment.

learn more… | top users | synonyms

5
votes
3answers
87 views

Merge a list of spatial polygon objects in R

I have a list of spatial buffers (30000 buffers) that I built with the function lapply: buff.pts <- lapply(1:nrow(pts.prj), FUN=function(l){ buff <- gBuffer(pts.prj[l,], width=1000) ## 1km ...
0
votes
1answer
34 views

How to create SpatialPixelsDataFrame from Latitude and Longitude data?

I have a data frame that contains latitude and longitude data with density point. I want to do kriging but my main problem is that I can not create SpatialPixelsDataFrame from my data. My data is ...
1
vote
0answers
39 views

Correcting for offset

I have a shape file with RTK measurements as a line feature, which more or less corresponds with visible features in a raster layer (shaped as lines). These measurements however are not accurate ...
0
votes
1answer
90 views

Counting raster values using another raster as mask in R?

I would like to count the frequency of values in one raster, using another raster (different resolution) as the zonal condition. The premise is that the coarser resolution raster represents the area ...
0
votes
0answers
37 views

Export image from PL/R on postgres

I'm trying to export an TIFF image from a PL/R Function in my PostgreSQL database. The output of the image appear be corrupted, because when I'll open the image, is showing the message: "Loading ...
0
votes
1answer
194 views

For loops + boxplot for raster

I have several Rasterstacks (b1_mask, b2_mask,...) of several layers representing only a determined pixel-intensity range. (So point "A" in some layers is "NA" - in others a "value" of that certain ...
3
votes
2answers
57 views

How to remove points which are out of shapefile (or raster) extent

My problem is quite simple. I have thousands of points (coordinates) to analyse, however some of them are so inaccurate that they "hit" the sea. I need to get rid of them. I was trying to find some R ...
1
vote
2answers
70 views

How to extract values from a raster using R?

I'm a beginner at using R software, and I'm attempting to perform a percent linear stretch on the following raster data: > KBnew #class: RasterLayer #dimensions : 27018, 26389, 712978002 ...
1
vote
2answers
86 views

Extract raster layer data by attributes in RasterStacks R

I have a RasterStack with 2 raster layers of the same area, one from a SpatialPolygonsDataFrame (layer1) and another NDVI satellite image (NDVI). layer1 has a series of polygons, each with various ...
1
vote
2answers
51 views

Attaching data to SpatialPolygonsDataFrame

As this is a more GIS related question (and maybe solvable with ogr/gdal functions I'm not aware of), I try it here first, although working with R. What I want to achieve: I have some data, based on ...
2
votes
3answers
412 views

How to reclassify only a part of a raster but keep the rest unchanged (ArcGIS or R)

I'm trying to reclassify only a certain part of a raster...not the entire raster. Here's the problem. I have a LULC raster of the entire US. There are some issues with the raster that I want to ...
1
vote
0answers
27 views

rasterize (R package raster) fail to rasterize island polygons?

I am having problem in rasterezing a polygon shapefile: "island" polygons (I mean polygons which are totally included into a larger one) are ignored and do not appear in the raster. My code is: seg ...
2
votes
1answer
62 views

buffer in spsample for distance between randomly selected points

I wanted to know if there is a way to add a buffer in the function spsample in the sp package. I am randomly selecting points within 28 polygons and would like to specific a minimum distance the ...
3
votes
1answer
154 views

Spearman correlation between two rasters in R

I have two rasters of the same area. The only difference is that they were created using two different methods. I would like to compare them and see how correlated they are pixel by pixel. Any ideas ...
0
votes
1answer
34 views

Transforming a .txt file into a raster in R

I have a .txt file which consists of 160 rows and 320 columns. It covers the geographic region from 34 to 41.95 in latitude and 19 to 34.95 in longitude. Its spatial resolution is 0.05 x 0.05. I use ...
1
vote
1answer
29 views

How to assign the attributes of the largest overlapping polygon area to each overlapping gridcell?

I am new to R, and I am trying to use it to calculate the areas of polygons that overlap with each gridcell, in order to assign the attributes of the largest overlapping polygon area to the ...
5
votes
0answers
98 views

Resampling air temperature gridded data to sub-grid resolution

I'd like to obtain a 30-m resolution gridded dataset of air temperature from the ~1km gridded data of WorldClim, of Hijmans et al., 2005) for a mountainous region. The easiest procedure (I thought ...
2
votes
1answer
92 views

Fill the gaps using nearest neighbors

I want to fill the NA values using the average values of the nearest neighbors: r <- raster(matrix(1:16, nrow=8, ncol=8)) r[r==12] <- NA
2
votes
2answers
110 views

Extract the edge between two raster cells with different values

Is there a way in R to create lines (black lines in the figure below) along the edge between two raster cells that have different values ? Update I'm trying the functions clump() and ...
1
vote
0answers
10 views

Georeference .txt file to SpatialGridDataFrame

I have a matrix file in a .txt format and I want to georeference this matrix using latitude and longitude. How could I do this in R, so that I can transform my .txt file into a SpatialGridDataFrame ...
0
votes
0answers
29 views

Incomplete/incorrect extraction of raster values from shapefile in R

I am having trouble correctly extracting raster data from all the polygons from a given shapefile in R. The raster and shapefile have identical CRS in QGIS (EPSG:32654, WGS84 / UTM zone 54N). After ...
4
votes
0answers
67 views

Crop raster based on another raster R

library(raster) How can one clip one raster based on another raster? RasA: class : RasterLayer dimensions : 459, 533, 244647 (nrow, ncol, ncell) resolution : 10000, 10000 (x, y) extent ...
3
votes
1answer
64 views

Export Shapefile from Arc for use in R

I am trying to export a shapefile from the ArcMap (Made in both 10.2 and 10.3; same problem) environment to be used in R. Unfortunately, it seems that the projection information is somehow not ...
0
votes
1answer
140 views

Exporting point shapefile from ArcGIS for Desktop to R?

I am having several problems in exporting my point shapefile from ArcGIS 10 to R. I tried to save the shapefile as a CSV, but R reads all in one row; somebody in another question answered to use ...
2
votes
2answers
60 views

Reclassification of CORINE map using R

I am trying to reclassify the CORINE map for Hungary to 4 classes in R. but after reclassification, when I import the asc file to QGIS it loads it empty. Am I doing something wrong? ...
0
votes
0answers
50 views

Change raster projection in R

I'm trying to change raster projection using R and its raster library. The input raster projection is Lambert Azimuthal; this one and other params can be seen here: ...
2
votes
4answers
1k views

How to create random point in according polygon for each dataset entry in a list (with R)

I have an area divided into polygons, and a dataset of observations which has a common field with the polygon layer. I now would like to generate a random point for each dataset entry within the ...
2
votes
1answer
44 views

Convert CSV file format to Breakline CSV format file [closed]

I have a csv file with almost 36000 rows.The format of csv file is x,y,Polygon number, Z I would like to arrange this csv file in the below mentioned format. Let’s say in this example, Polygon ...
0
votes
0answers
32 views

map.axes control in R

I am learning how to use map functions in R. How can you control the axis labels in R when using map.axes ()? Right now the map displays only the degrees. I would like to have finer control so that ...
1
vote
2answers
144 views

Rasterizing polygons with the function “gdal_rasterize” in R

I'm using the function gdal_rasterize in R (package gdalUtils) to convert a polygon shapefile into a raster. Here is my code: r.test <- gdal_rasterize(src_datasource="df.shp", ...
2
votes
0answers
22 views

In QGIS 2.12 processing R scripts fails (plots remain blank) due to a wrong variable name - Is there a workaround?

I am trying to execute r scripts in 2.12. All of them fail. Plots remain blank. It seems that the variable "Layer[[Field]]" returns NULL: E.g: hist(Layer[[Field]],main=paste("Histogram ...
3
votes
1answer
63 views

Plotting netCDF4 data with the right projection

I guess this will sound simple to you but I just cannot get the right plot within R. I have a netcdf4 file and would like to visualize it within R just like I would do in QGIS and ArcGIS. sample data ...
7
votes
4answers
1k views

Assigning RGB values from Geotiff image to LiDAR data, using R

I have given a Geotiff image and its corresponding Lidar data (x,y,z) in UTM coordinates. I need to merge the Lidar data with the RGB values from the image. That means, at the end, I need to plot ...
23
votes
4answers
8k views

How to efficiently read a kml file into R

I'm working with huge .kml files (up to 10 Gb) and need an efficient way to read them into R. Until now I've been converting them to shapefiles via QGIS and then back into R with readShapePoly and ...
1
vote
0answers
34 views

Clear QGIS plot results window

How do you clear old plots from the plots result window in QGIS? Is there a line of R code that you'd need to run to do so, or is there a means of doing so through the GUI?
1
vote
1answer
63 views

Inverse Distance Weighted (IDW) Interpolation with Radial Basis Function (RBF) in R

I want to perform an IDW interpolation with R. I am aware that I can do that with gstat::idw. But I want to change the parameter 'idp' with a radial basis function (RBF): where is the ...
0
votes
0answers
41 views

Plotting Raster in R gives error

I know this is not much to go off of, but I can't seem to find the answer anywhere. I was plotting this raster image on Friday and it worked, and now when I try to plot it, I get this error. The image ...
2
votes
1answer
74 views

Building predictive maps of response variables in R

I am a novice in spatial statistics in R. So, I am looking for some advises. In particular, I would like to create a predictive map of capture success from a generalized linear mixed-effects model ...
0
votes
2answers
73 views

Failure of the code calling the function “rasterize” in R: NAs or no slots

I have some problems to convert a shapefile into a raster. I used the function rasterize (package raster) but all raster values are equal to NA. Following the answers to this question rasterize ...
1
vote
1answer
42 views

Tearing of SpatialLinesDataFrame and problem with gClip function

I am trying to use ggmap with geom_map and geom_path commands to add a SpatialPolygonsDataFrame of African countries and a SpatialLinesDataFrame over a raster. When I use the defined function gClip() ...
1
vote
1answer
121 views

Creating spatial population heat map

I have some data that contains crab males population based on latitude and longitude. I am trying to plot the population distribution on map (not point density). For example I like to show which areas ...
5
votes
1answer
207 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: ...
0
votes
1answer
52 views

Increase speed of reverse clip (erase) for large shapefiles in R

I would like to do a reverse clip (or erase in ArcMap) from shapefiles (polygons) then to merge the two shapefiles into a single shapefile. From this post How to 'reverse clip' (erase) in R, ...
3
votes
1answer
568 views

Spatial Interpolation Methods like PRISM

I am looking for some kind of software (free software) that allows me to make an interpolation like PRISM software. The interpolation used in PRISM is a local regression and accounts for ...
1
vote
1answer
45 views

Correct Projection for calculating centroids of a group of points?

I have a long list of points covering all of North America for which I would like to calculate the centroid (by grouping points based on the "Name" column). My approach is to take the WGS84 ...
0
votes
0answers
87 views

R raster() function failed to read tif file

I wrote a few lines to load data in TIFF to R. The function I used was: library(raster) test <- raster("file name.tif",package="raster") and it worked perfectly last week. However, now I am ...
1
vote
1answer
62 views

How to manually assign new names to attributes in a spatial data frame column with NA values

Data can be found here (Admin 1- States and Provinces, first download button): http://www.naturalearthdata.com/downloads/10m-cultural-vectors/ I have a shapefile of the world that I'll be pulling ...
3
votes
1answer
71 views

Tearing of polygons using ggmap and readOGR

I'm trying to incorporate a shape file of US states with ggmap and keep getting "tearing" of my polygons. I tried changing group=id to group=group which helped, but didn't seem to resolve the ...
2
votes
1answer
33 views

problem when doing algebra with raster layers in R

I'm trying to combine bioclim raster layers to create the following layer. (Q) = AnnPrec/[(Tmax+Tmin)*(Tmax-Tmin)]*1000 For that, I import a bioclim stack: envirc = ...
2
votes
0answers
62 views

Adding a custom color scale for a sp.points layer to levelplot() legend

I'm wondering how I can add a customized color palette that I used to display a sp.points layer in a call to levelplot (lattice plotting) in the rasterVis package in R. I used a function that Dave X ...