Hot answers tagged

7

Your attempt is designed to fail. If you look at the image, you see the data arranged as a circle, with black triangles in the corners of the square, where the satellite view goes right into orbit. In your test data, you see only NODATA -32768 for those parts of the image. The extent is between +/-75 and +/- 78, but these values are only reached in the ...


5

You need to make a spatial points object and then reproject that: library(sp) library(maptools) data(wrld_simpl) wrld_simpl.trans <- spTransform(wrld_simpl, CRS = ("+proj=moll +lon_0=0 +x_0=0 +y_0=0")) plot(wrld_simpl.trans, col = 'lightgray')) latitudes <- c(-30, 0, 20, 50) longitudes <- c(-20, 10, 50, 80) Make an SPDF: pts <- ...


5

There is no way to define "outside only" in gBuffer. You have to go through the additional step of turning the inner polygon to null, and for a good reason. You can use the raster::erase function to remove the internal polygon. If you really want this as part of the gBuffer function why not just write your own modification of gBuffer that adds an "outside ...


3

The package PostGIStools can help. See for example the vignette. Another way could be to transform your Spatial*DataFrame geometry to WKT, insert into PostGIS using the classic RPostgreSQL package and re-create the geom there.


3

I suggest to remove projection information in R output raster and open it in ArcGIS. If successful, define projection from within latter. I applied this trick with vectors coming from MapInfo to ESRI products. Slight difference in projection naming by these two packages had devastating result with points being 200 m away from their true position. Good ...


3

As I pointed out, you had identical observations. Additionally, you were not using the "resolution" argument in the raster function so, were only creating 100 pixel observations to predict to. I had to fix the tab returns in the file that you posted on dropbox, which was not appreciated. Here is code that I got to work. library(gstat) ...


3

UPDATE: The above-mentioned approach by Oscar Perpiñán found here seems to work, if I only take a subset of the matrix the way Oscar did. For that to work I needed to know the subset boundaries and the static files, both available online for a few regions (such as North Africa). m = m[700:1850, 1240:3450, drop = FALSE] lon = raster("NAFR_LON.img") lat ...


3

I emphasize that this function might not be useful for everyone. It will depend on what you're trying to do, and your inputs, and how possible it is to do what you're trying to do given your inputs. For instance, if you have a complicated shape with concave sides, forget about it. In my case, I just wanted to cut a box filled with random points down to a ...


3

"I couldn't find it in any of them" ? CRAN Task View: Analysis of Spatial Data (Geostatistics) You can also use the SOS package directly in R library(sos) # find packages with a "spatial regularization" function unique( findFn("spatial regularization")$Package ) found 43 matches; retrieving 3 pages 2 3 Downloaded 29 links in 11 packages. [1] ...


3

Ok, this is not really an answer to the my question, but if you are interested in the biomass map I found a link from where you can download the actual data: http://whrc.org/publications-data/datasets/pantropical-national-level-carbon-stock/


2

Gdal Installation Install Gdal command line tools and check to see if its binaries are added to path environment variable. e.g. in windows: open Run and type: rundll32.exe sysdm.cpl,EditEnvironmentVariables Then follow the screenshot Download and install gdal python bindings from here according to your python and OS. install it using: pip.exe ...


2

This may be easier using the Orfeo toolbox (https://www.orfeo-toolbox.org/), this is provided with OSgeo4W and can be accessed usign QGIS or a command line interface. This tutorial uses mean shift segmentaion to generate objects, which can be the classified using SVM/random forests etc. ...


2

As I didn't find the existing answers to this problem on StackExchange to be satisfying, I will add my own solution here. This uses geosphere package to calculate distance between two polar (latitude, longitude) coordinates. For a data frame: > head(coordinates) lat lng distance 21 51.73832 10.72805 6000 31 51.76656 10.85404 6000 64 ...


2

Try fs <- list.files(path="F:\\MODIS\\Modis EVI\\HDF8 EVI", pattern = "tif$", full.names = TRUE) library(raster) s <- raster::stack(fs) writeRaster(s, "hdf8_EVI.TIF") I have no idea what stackSave is. Please read about asking questions here and look into the basics of the raster package. Don't use assign, and don't use setwd - both are really bad ...


2

A simple function can do that for you. Here's how: allKmlLayers <- function(kmlfile){ lyr <- ogrListLayers(kmlfile) mykml <- list() for (i in 1:length(lyr)) { mykml[i] <- readOGR(kmlfile,lyr[i]) } names(mykml) <- lyr return(mykml) } use it with: kmlfile <- "se\\file.KML" mykml <- allKmlLayers(kmlfile)


1

I can not help you within R, but using GDAL takes you further: gdalinfo acpcp.2000.nc tells you that the first two bands contain the lat and lon coordinates, and they are in WGS84 degrees: SUBDATASET_1_NAME=NETCDF:"acpcp.2000.nc":lat SUBDATASET_1_DESC=[277x349] latitude (32-bit floating-point) SUBDATASET_2_NAME=NETCDF:"acpcp.2000.nc":lon ...


1

The rioja package provides functionality for constrained hierarchical clustering. For what your are thinking of as "spatially constrained" your would specify your cuts based on distance whereas for "regionalization" you could use k nearest neighbors. I would highly recommend projecting your data so it is in a distance based coordinate system. require(sp) ...


1

If the original data was rescaled to 8-bit it should be 0-255 and not 0-200. That aside you can take a normalization approach but shift the centrality over so the distribution will bound into the negative. Two normalization formulas that will do this are: Formula 1: [(x - "x min") / ("x max" - "x min") - 0.5) * 2] Formula 2: ["new min" + (x - "x min") * ...


1

Your raster and your polygon do not overlap. If they do: > r1 = raster(extent(c(107,110,38,40))) > polygon_mus <- extent(c(107, 111, 37, 40)) > cell <- extract(r1, polygon_mus) Then that works. If they don't: > r1 = raster(extent(c(112,114,38,40))) > cell <- extract(r1, polygon_mus) Error in (function (classes, fdef, mtable) : ...


1

You just need to loop over the combinations you need. > combn(1:length(Sl),2) [,1] [,2] [,3] [1,] 1 1 2 [2,] 2 3 3 that gets you (in columns) the line indexes. So then do: MyLines = apply(combn(1:length(Sl),2),2, function(x){ gIntersection(Sl[x[1]], Sl[x[2]]) }) Then MyLines[[1]] is the ...


1

The output of extract is a list of cell numbers and values stored in matrices, it needs tidying to a data frame. (Data frames are best since they can store different types of data, like integer cell numbers and numeric values - which is essentially what cellnumbers=TRUE is for). library(raster) r <- raster(volcano) ## simplify the values r <- (r %/% ...


1

Looks like ESRI decided to define their own projection parameters: http://osgeo-org.1560.x6.nabble.com/Question-about-Krovak-projection-and-ESRI-XY-Plane-Rotation-parameter-td4291471.html There has also been some discussion on the GDAL list recently: http://comments.gmane.org/gmane.comp.gis.gdal.devel/42132 I suspect the raster package is applying some ...


1

I would just read directly from the source HDFs with raster, you'll need to make sure you have the right HDF libraries installed when GDAL is installed / built. What Linux are you on? On Ubuntu with apt-get I use (something like) this install script: https://github.com/mdsumner/nectar/blob/master/r-spatial.sh That has fuller notes about RStudio and other ...


1

Here's a potential approach: I haven't tried this so your mileage may vary, but it should be quite doable (but it might require rather heavy-duty scripting). I'm starting to think in a similar direction for some projects I'm working on. Ingredients: QGIS PostGIS (likely the best storage medium for relational data but others could potentially be used) ...


1

It is not clear on weather you want to subset bands upon reading into R or extract a single band from an existing raster stack. Once illustrated, both are quite simple. We can use the 3 band R logo as an example. library(raster) fn <- system.file("external/rlogo.grd", package="raster") To subset a band from an R raster stack/brick you use a double ...


1

The UK Data Service: Census Support host UK administrative geography shapefiles that can be downloaded directly through their Easy Download service. In an Rmd file to download and load parishes it can be as easy as inserting the following code into an appropriate chunk: if (dir.exists("parishes") == FALSE) { dir.create("parishes") } ...


1

The answer to my own question is that the local firewall settings prevented me from downloading the tiles from OSM. The way how to solve it was to set proxy (from within R > link). The con of this solution is that the viewer still doesn`t deliver tiles as the proxy settings at the moment do not apply to RStudio Viewer. Although, the leaflet output appears ...


1

As of one week ago, this can now be achieved with the development version of mapview: # devtools::install_github("environmentalinformatics-marburg/mapview", ref = "develop") library(mapview) library(sp) # video pt <- data.frame(x = 174.764474, y = -36.877245) coordinates(pt) <- ~ x + y proj4string(pt) <- "+init=epsg:4326" mapview(pt, popup = ...



Only top voted, non community-wiki answers of a minimum length are eligible