Statistical computing language and software environment.

learn more… | top users | synonyms

1
vote
1answer
36 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 ...
2
votes
1answer
119 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
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
30 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 ...
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 ...
4
votes
0answers
70 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 ...
2
votes
1answer
45 views

R gdalUtils::ogrinfo error or very slow

I am pulling WFS data into R and using gdalUtils::ogrinfo to look at the available layer names on a WFS server. Using the same url in QGIS, this is very fast and gives complete information. With ...
5
votes
3answers
104 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 ...
2
votes
2answers
117 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 ...
0
votes
0answers
39 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 ...
2
votes
1answer
49 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
53 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
0answers
23 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
72 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 ...
1
vote
2answers
176 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", ...
0
votes
0answers
40 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 ...
2
votes
2answers
68 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? ...
1
vote
1answer
76 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
1answer
97 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 ...
2
votes
1answer
87 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
0answers
47 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 ...
1
vote
1answer
48 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
184 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 ...
0
votes
1answer
55 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, ...
0
votes
2answers
80 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
50 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 ...
3
votes
1answer
199 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 ...
1
vote
1answer
77 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 ...
0
votes
0answers
101 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 ...
3
votes
1answer
76 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
36 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 = ...
0
votes
1answer
169 views

How to create a continuous scale with distinct/custom color and value breaks with ggplot2 map

As stated in the title, I'm trying to create a continuous scale with distinct color and value breaks within the ggplot2 package in R. I'm using some dummy code to illustrate my problem: ...
2
votes
0answers
73 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 ...
2
votes
0answers
91 views

R: Setting pop-ups dependent on zoom level using leaflet

I have data that I would like to group differently, depending on the zoom scale in an interactive map made using leaflet. I have expenditure data and I would like to show expenditure by lake at ...
10
votes
2answers
401 views

Create area buffers that are limited by a coastline

I'm trying to use ArcGIS 10.2 to create a buffer of points based on a pre-defined area (e.g 400 sq km). Further to that, the buffers of some of the points are close to the coastline that requires the ...
1
vote
0answers
39 views

how to extract line features from a raster

I have a raster of land cover types where roads are represented by pixels (1 pixel = 25m x 25m = 625 m²). Is there a way to extract line features (here roads) from a raster ? ## Create raster as an ...
1
vote
0answers
42 views

How to do a Kernel Density map from weighted point observations using a Cauchy kernel?

I need to produce a kernel density map, but instead of using a common kernel function such as Gaussian, I need to use the Cauchy kernel function. I have tried the Kernel Density tool in ArcGIS and ...
3
votes
1answer
104 views

Error while comparing two raster layer in R

I have got a geographic point distribution with N prehistoric settlements with a size of x and want to compare the distribution with an economic simulation, which produces M settlements (Usally N > ...
1
vote
0answers
52 views

Spplot SpatialPolygonDataFrame and SpatialGridDataFrame

I have to plot in the same graph something like this: Then, I have elements from SpatialPolygonDataFrame class and others elements from SpatialGridDataFrame class. When I try to plot them in the ...
2
votes
2answers
60 views

Use function spplot

Does anybody know how to plot with "spplot" fuction two elements of diferents classes?. One element from "SpatialPolygonDataFrame" class and other from "raster" class.
0
votes
1answer
74 views

R: raster stack (time series) loop pixelwise and write layer number of value occurence into a single output layer

I have a raster stack of gridded RFE 2.0 rainfall data (time series of one year = 365 layers). Now I wanted to identifiy on which date during the year the first rainfall occurs for each Pixel. The ...
1
vote
1answer
137 views

Error when trying to plot legend for geom_point with ggplot2

Here's some mock code to go along with my problem: #read in libraries library(ggmap) library(sp) library(raster) library(ggplot2) #read in country shapefile, project, fortify for mapping with ...
0
votes
3answers
52 views

How to add two dataframe columns of city and state names to form single city-state column for geocoding in R? [closed]

I tried to search for an answer to this, but I couldn't seem to find the right search terms, so I decided to spell it out quite explicitly. I have a data frame with separate columns for cities, ...
0
votes
2answers
101 views

How can I convert a large csv of irregular lat/lons to regular raster GRID?

I have a large csv containing ~5 million rows containing Lat, Lon, and Depth bathymetry values. I want to generate a raster GRID (for use in Arc) from this, but the trouble is the lat/lons are ...
2
votes
0answers
76 views

R Efficient Way to Resample, Crop, and Mask a Raster Image

Does anyone know an efficient way to resample an image? I am currently trying to crop a large image and clip 2 regions from a shape file. From this clipped image, I would like to increase the pixel ...
2
votes
1answer
78 views

gBuffer(rGEOS) causing R to crash

I have downloaded a US federal lands data layer (fedlanp010g.shp.tar.gz) from http://nationalmap.gov/small_scale/atlasftp.html?openChapters=chpbound#chpbound In R, I am trying to create a buffer ...
1
vote
1answer
68 views

Get distances between boundaries from an SpatialPolygon and raster pixels

I am trying to calculate the distance from several pixels of a raster to a boundary of some polygons in R as it is showed in the image. I have two problems: How to correctly define a boundary from ...
1
vote
2answers
119 views

R calculate raster cell size in map units

I have a RasterLayer and would like to know the cell size. I haven't find any function in the packages :-S . Does someone have an idea ? info about the RasterLayer class : RasterLayer ...
0
votes
1answer
40 views

Defining the correct AEA proj4string for FEWSnet Rainfall Data (Southern Africa) in R [closed]

I have some general questions about how to go about solving this problem: I am trying to incorporate FEWSnet's monthly Rainfall Estimate data from 2014-2015 for Southern Africa into an analysis where ...
2
votes
0answers
43 views

Keys for merging US state/county ANSI's with GADM Unique identifiers?

I've got county-level data from USDA NASS, and I want to merge it with gridded climate data. A preliminary step is the associate the counties with the coordinates of their centroids. If I merge by ...