Statistical computing language and software environment.

learn more… | top users | synonyms

31
votes
4answers
39k views

How to open a Shapefile in R?

I need to open a shape file from ArcMap in R to use it for further geostatical analysis. I've converted it into ASCII text file, but in R it is recognized as data.frame. Coordinates function doesn't ...
1
vote
0answers
52 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 ...
3
votes
3answers
166 views

Converting SpatialLinesDataFrame to SpatialPointsDataFrame in R?

In R I have a SpatialLinesDataFrame (for example from a coastline shapefile) and I want to convert it to a SpatialPointsDataFrame. I want to keep all the vertices from the line shapefile to become ...
1
vote
1answer
51 views

How do I get rid of edge effects while using focal in R to smooth a raster?

I am trying to use R with the focal function from the raster package to smooth raster images. I am working with Radar images that have already been preprocessed. As part of that, some calculations ...
8
votes
2answers
3k views

Removing rows in shapefile in R

I've imported a shapefile into R, and joined it to a table. My shapefile contains all the census ids, while my table only contains selected census ids. I'm now trying delete all the rows didn't get a ...
3
votes
2answers
81 views

How to generate a buffer outside polygons having a given pixel value?

For example, I would like to build a 20-m buffer (represented in yellow in the image below) outside polygons having a value of 2 (represented in green) and to assign the value of 3 to buffer cells. ...
1
vote
1answer
32 views

Deciphering coord. ref. in R – very basic question

I'm trying to make sense of the coord. ref. parameters for rasters in R. For example, for a given raster, crs() gives the following: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 ...
0
votes
0answers
70 views

collocated cokriging with gstat in R

I am trying to perform cokriging with temperature as the target variable and elevation as a secondary variable. Elevation (the secondary variable) is collocated with temperature (the target variable) ...
0
votes
0answers
29 views

Using the extract function in raster package for R with polygons

I have a shape file that contains some polygons and an unprojected raster. I'd like to extract the cells within the polygons using R, so I use code like this: # Load my polygons MyPoly <- ...
0
votes
1answer
40 views

Tabulate intersect in R

I would like to get the areas related to the polygons resulting from the intersection between two SpatialPolygonsDataFrames: 'A' and 'B'. SpatialPolygonsDataFrame 'B' has 3 different 'classes', which ...
3
votes
1answer
36 views

Problem with automated data storing during raster::crop (‘legend’ is not a slot in class “RasterStack”)

I am working with a set of raster layers containing CHIRPS monthly rainfall amounts over Africa. For purposes of reproducing the below code, I staged the decompressed tif files on Dropbox. Now, let'...
0
votes
0answers
29 views

Estimating Daily average temperature from 2021-2050 in R

For my study I am dealing with daily temperature modeled data from 2021 to 2050. My data is in ncdf format. I want to calculate the average daily temperature across this period i.e the result should ...
1
vote
1answer
77 views

Find NoData values inside a polygon area from a raster

I have a raster (representing a polygon in black) which contains NA values (represented by white pixels) that are located inside the polygon and outside the polygon. How can I get the index value ...
0
votes
1answer
42 views

Converting data from data frame into raster file using R?

I have the following data frame (long, lat, value) (all coordinates are within Colombia): Spoints: x y z 1 -75.67083 7.57916667 7.328901e-19 2 -74.59583 ...
1
vote
1answer
46 views

Finding and loading global population density raster data into R?

I am using the Bioclim dataset for a maxent project right now, but I want to add demographic predictors along with climatic ones. I have the 19 layer raster data from Bioclim and I'm hoping to use the ...
4
votes
1answer
81 views

Great circles path not curved (in R)? Conventions and convertions problems?

I am given the great circle equations of two paths. The first one is Longitude = 168 degree. and the second one is: tan(Lattitude)=.11 cos(Longitude) + .64 sin(Longitude) However, I am ...
1
vote
0answers
69 views

Troubling using MODIS package in R (mac). Error with gdal

I'm new to using MODIS data, and have been trying to set up a a way to use the HDF files produced by MODIS on R. I had trouble with gdal (could only download the package through system dialog), and ...
0
votes
1answer
58 views

Crop Raster from using Polygon shapefile in R

I am trying to crop a raster by a polygon in R to the state of Sergipe-Brazil. My raster is a raster brick criated by 7 .tif files which are EVI (vegetation index) time series. Since the EVI archives ...
3
votes
1answer
116 views

Create polygons of the extents of a Raster in R

I want to create two polygons. One is of the rectangular extents of my raster. I know I can obtain the extent of the raster using r <- raster("band5.tif") e <- extent(r) but don't know how ...
1
vote
2answers
781 views

NA values in dbf when exporting shapefile from R with writeOGR?

I´m writing an esri shapefile from R (2.14.1) on windows, using writeOGR in the rgdal package, in the resulting dbf file, NA values in the spatialpointdataframe (in numeric columns) are not translated ...
0
votes
0answers
33 views

Find Maximum value per month in rasterstack/brick and corresponding timestamp R

When dealing with raster images, I found the raster and rts packages in R to be very flexible for analysing my raster data unlike ArcGIS. In my learning efforts, I have had to do some stacking/...
2
votes
0answers
107 views

Differences in MaxEnt between 'Biomod2' and 'Dismo' package

I am trying to run an ensemble species distribution, however the the results I am getting for MAXENT.Phillips model are not reasonable projections compared to the Random Forest and Boosted Regression ...
2
votes
1answer
42 views

Error writeOGR using R

I am learning how to use writeOGR to write a GPX file. When I run the line of code I get an error message: Creation of output file failed. Example set of data dput(head(location_information)) ...
3
votes
1answer
61 views

extract() function from r raster package returns different cells if “weights” parameter is TRUE or FALSE

I am trying to extract cell values from a RasterLayer based on a SpatialPolygons object. I create the raster with library(raster) rasterValues <- matrix(rnorm(20),4,5) r <- raster(rasterValues)...
0
votes
1answer
38 views

Find Lat and Long points on land only

I'm new to R and GIS so please forgive me if this is a simple request. I was looking for a way to find out if a Lat/Long point is on land or ocean. I found this previous post from a couple of years ...
0
votes
0answers
52 views

Changing/ updating dimension values of ncdf file in r

I posted this question to SO but in hindsight, gis.se is a much more suitable place: I have several ncdf files that do not have the correct spatial dimension values so I want to update these values. ...
0
votes
0answers
55 views

How to clip MrSID Files in R and export to GeoTiff?

I would like to use R to: Read in an MrSID raster (.sid format) Clip the extent using a shapefile Save the new clipped raster as a geotiff I am fine with steps #2 and 3, but I can't find any ...
1
vote
1answer
272 views

Error in downloading MODIS image using R script

I am trying to download "MOD13A3" MODIS image using R script (http://r-gis.net/?q=ModisDownload) but each time it's ending in error. How to make it work ? =============================================...
6
votes
4answers
592 views

Estimating river Channel Width using Python/ArcGIS/MATLAB/R?

I am trying to estimate the river channel width from digitized polygon or poly-lines shapefiles. To do so, I converted poly-line shape files to points.shp at regular intervals (at 1 cm). Later, I ...
8
votes
2answers
3k views

use proj4 to specify Robinson projection with R ggmap and ggplot2 packages?

I want to project this map in robinson projection: library(ggmap) world <- map_data("world") ggplot() + geom_path(data = world, aes(long, lat, group = group)) ...
0
votes
1answer
47 views

Downloading MODIS data of cloud cover less than 10%

I use ModisDownload from rts package for downloading MODIS data. But is it possible to specify cloud cover and view angle before downloading? e.g. if I want to download MODIS data for cloud cover less ...
2
votes
1answer
48 views

How do you extract the mean fire frequency (raster) for each point within a given buffer size using R?

I am trying to extract fire data (mean and max fire frequency) for each point within a given buffer size (250m) around multiple points. Currently, my point data is in Lat and Long. For the raster ...
0
votes
1answer
220 views

Spatial Join in R

I'm fairly new to using R for spatial work so bear with me. I have found questions similar to this but nothing that answers this question specifically enough for me to implement it. I have point data ...
0
votes
0answers
83 views

Convert raster stack to RGB GeoTIFF for use as a background image in maps (in R)

I've been trying to use R to download google maps images as rasters, then convert them into GeoTIFF files which can be imported as a geo-referenced background layer in GIS programs. I've been ...
14
votes
3answers
796 views

Ecological geospatial conundrum

I am looking for a different, more elegant solution to a spatial statistics problem. Raw data consists of an x-y coordinate for each individual tree (i.e. converted to a point .shp file). Although ...
2
votes
0answers
48 views

How to clip a .osm.pbf file to a shapefile in R

I have (1) an OpenStreetMap file of a large area in .osm.pbf format that I would like to clip with (2) a shape file .shp of a smaller area using R. The output output I would like to get is a .osm....
1
vote
1answer
43 views

How can I plot points with proportional circles, but also by colour from another attribute? [duplicate]

I have point data of population density that I have plotted to show density with proportional circle symbols. This is straightforward with many ways of achieving this in different software and ...
3
votes
1answer
135 views

Identifying value of closest non-NA pixel

I have a raster representing a large landscape, where pixel values indicate particular land classes. I have been using the "distance" function in Package 'raster' in R to calculate the distance from ...
17
votes
5answers
9k views

How best to fix a non-noded intersection problem in PostGIS?

I'm using a PL/R function and PostGIS to generate voronoi polygons around a set of points. The function that I am using is defined here. When I use this function on a particular dataset I get the ...
0
votes
2answers
89 views

Remove lines from inside a polygon (shapefile) in r

I have this code which prints the Galápagos Islands. But inside the islands, there are lines that I want to get rid off. How is this possible in R? library(rgdal) library(ggplot2) URL <- "https:/...
1
vote
2answers
391 views

R package spatstat: How to use point process model covariate as factor when pixel image values are numeric

I am trying to model a point process with an image covariate using the ppm() function in the spatstat package in R. I convert my raster to an im object for use with spatstat, and I run into a problem ...
0
votes
1answer
76 views

Change the values of NA cells in a raster by using a geographic subset of the raster as a condition

I would like to replace the NA cells that are within a specified extent (here rectangular area defined by drawExtent in the code bellow) of a raster object. My idea was to use the functions ...
0
votes
2answers
54 views

Create shapefile connecting points “as the crow flies” in R

I have a set of locations (with latitude and longitude). I know how to get the distance between these points, but I want to create a line that connects them with the shortest path ("as the crow flies")...
0
votes
0answers
28 views

Link between arcgis and R

I am modelling vector abundance using R-INLA package. Next I need to made a map of vector distribution and I use ArcGIS, raster calculator tool. Is there any form to link R and ArcGIS for this purpose?...
2
votes
1answer
36 views

GIS Least Cost Spanning Tree in R

Is there an R package/function that computes a least cost spanning tree given a shapefile or vector containing the latitude/longitude of each point and a raster file that contains the cost of ...
2
votes
0answers
39 views

non-finite value supplied by optim when I use estiStAni or fit.StVariogram

I have computed an empirical spatio-temporal variogram and I want to fit it into a model I built using vgmST. However, whenever I call fit.StVariogram I get the error "non-finite value supplied by ...
21
votes
6answers
14k views

How to cluster spatial data in R?

I am very new to R. I have bunch of data points with latitude and longitude. I want to use R to cluster them based on their distance. I have already taken a look at this page and tried clustTool ...
4
votes
0answers
91 views

Which statistical methods to compare the spatial distribution of two different variables in two raster maps?

I am working with two global raster maps using the R Software (original file: netCDF for map 1 and GeoTIFF for map 2), with a resolution of 5 min of arc. Map 1 contains data on the share of the land ...
13
votes
6answers
6k views

Get Raster Values from a Polygon Overlay in Opensource GIS Solutions

I have two layers. A polygon-shape-layer with many tiles and a raster-layer containing CORINE 2006 land cover with many categories in a colourmap. I want to obtain for each polygon in the shapelayer a ...
0
votes
0answers
14 views

glcm texture in R (mean_Envi)

I am running a Image texture measures from grey-level co-occurrence matrices (GLCM) using the glcm package in R and I would like to know what is the difference between mean' and 'mean_ENVI' / '...