Tag Info

New answers tagged

0

I am also doing the same. So how do i extract the values below a threshold ?


0

(Posted this as an answer as it's too long for a comment. But atleast I can add an image!) I think you may need to install the rpy extension for Python as mentioned in this post: Resources on using R in QGIS for R users?. You should be able to install this extension using the OSGeo4W setup and selecting Advanced Install setting. Go through the options ...


2

I have also been looking for a proper way to perform a weighted bivariate kernel interpolation. The code below worked for me: # Download an example dataset - those are tree logs in a 100x100m plot. I used the volume of log, as weight. test <- read.csv("https://dl.dropboxusercontent.com/u/39606472/R_rep/test.csv") require(ks) # Evaluate effect of tree ...


0

I believe this is what you need to achieve this using R: # packages library("raster") library("igraph") # load your raster rast <- raster("your_raster.tif") Now it might be straightforward to do it for all classes at the same time but I will just illustrate how to do it for class 1, you may do it individually and then unite the results as it's easy to ...


1

NetCDF is incredibly general and writing slow code is easy. I routinely deal with tens of thousands of NetCDF files in R, using some combination of packages raster, ncdf, ncdf4, RNetCDF, or rgdal. The key is to leverage the cell index tools in raster so that the "cell-in-polygon" test occurs only once, then you can apply the extraction across all files. Many ...


4

I'm working with our local cycling group to anonymise GPX files on two criteria (primarily for security). I've never come across a standard way of anonymising data but this satisfies two concerns of our members, while preserving accuracy along roads and speed information: Personal locations, removing 'private' areas for individuals; Obscuring timestamps so ...


1

Problems: 1: the outcome of UnionSpatialPolygons is a spatial polygon 2: converting the result back into a spatial polygon data frame is a real pain -a. you need a very exact data frame to attach to a spatial polygon -b. data you used for UnionSpatialPolygons has more rows than the output and is not formatted in the way that is needed. My (ugly) ...


0

make an adjustment to the X and Y coordinate of each point by a random distance between a certain minimum and maximum offset. also make the direction of the offset (plus or minus) a random selection. Include in the randomisation that some points may have no adjustment to one or both parts of a coordinate pair.


0

I'll just post a few pointers here for now: when I get a chance, I'll try to make this a more comprehensive and easily-consumable answer. But for now: First off, consider changing your title better match (IIUC--ICBW) the terms folks in this domain use for this sort of usecase, and therefore to make it more findable. What you want to do is more usually ...


1

so, as whuber gave me the nice quick piece of code to create a raster with the values that are the same between rasters, i thought i'd finish the entire job; create rasters and subtract one from the other to get a 'change' raster (full of 0s that need examining as well); r <- raster(ncol=10,nrow=10) r[] <- sample(c(1,2,4,8),size=100,replace=T) ...


5

What you want is a conditional calculation: return the value of r whenever r and r1 are equal and otherwise set the output to NA. The cell-by-cell arithmetic operations seem to be fastest. (They are much faster than, say, using mask or the reclassification functions.) Since they do not appear to offer an actual conditional operator, use two time-honored ...


3

The official definition for EPSG:3857 is +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs As you see, it is calculated on a sphere (a=b). Your formula is a bit contradictory: You define a lat-long coordinate system on the WGS84 ellispoid, then you add +init=epsg:3857 which should ...


1

Just in case anyone has come here for a problem like this one here are a few notes: • epsg: 3577 (as Steven Kay used) is the correct spatial reference in this case (Australia) because it preserves area. Spatial references that don’t exactly preserve area (like epsg:4283) will return a slightly wrong area. Everything will need to be re-projected to the ...


1

You would calculate it exactly as you would any variogram: by estimating the values of (Z(i) - Z(j))^2/2 as a function of the distance between data locations i and j. You have many choices of distance, but the natural ones would be either distance along the routes or travel time along the routes. If the routes are one-way, additional techniques borrowed ...


1

Convert points to individual lines using Points to Line (Data Management). Place points along the line at regular interval. To do so you might use linear referencing, alternatively search this site, something will pop-up. Calculate distance for each point along the line (Chainage in below table) . Search this site, let me know if fail, I’ll post script or ...


0

The "Without PoK" data is a shapefile that has been converted from an image. The shapefile extents are (0,0) and (1496,1497) which represent the cell/pixel sizes of the original image. If you have the original image, you could try georeferencing it directly to your other data. Otherwise, you could try using the Spatial Adjustment toolbar, again to ...


1

Use ceiling. Here is an example in which a raster with values in the interval [1,180] is generated randomly and reclassified. The code then produces a scatterplot of the original and reclassified values to show it has worked correctly. To make it clear that the endpoints of each class are being treated properly (because this is where bugs can arise), the ...


0

This is very simple with the reclassify function from the rasterpackage which takes a 3 column matrix with the values (from, to, becomes) or a vector that can be converted to such with byrow=True. In your case: rcl_vec <- c(0,10,1, 11,20,2, ...) rcl_mat <- matrix(rcl_vec, ncol=3, byrow=True) reclassified_raster <- ...


2

No features at that location! center_bbox takes the arguments center_lon, center_lat, width, height - looks like you're requesting a box centred on 53.3528, -0.4468. That's off the coast of Mogadisho, all blue water, and no features, on OpenStreetMap: Looking at 'bb': left bottom right top 51.3213580 -0.4784529 51.3842420 ...


0

"Extract value to point" will extract the cell values for each point. If you want to remove duplicate points (several points in one cell), you could compute the row and column values of each point in the coordiante system of the grid cell, then you can identify duplicate entries (using "Find identical"). for the corresponding row/column values, take the X ...


0

I'm not sure I'm understanding the question properly but I believe you simply want to write a multispectral raster to disk. If, for example, you want a multilayer geotiff you just have to run the following line of code: writeRaster(yourStackObject, filename="multilayer.tif", options="INTERLEAVE=BAND", overwrite=TRUE) In filename you can include whichever ...


1

This question is similar to: Clip raster by raster with data extraction and resolution change, but coming from a different angle. However, I think the answer is likely the same. First off, choose which raster you wish to be definitive. I'll repeat my previous answer here for ease: Load required libraries: library(raster) library(rgdal) Read rasters: r1 ...


1

Have you tried unionSpatialPolygons() from the maptools package?


2

API conditions constantly change, but this should work right now. OSM: devtools::install_github("hrbrmstr/nominatim") library(nominatim) b1 <- osm_geocode("Berlin, Germany") b1[c("lat", "lon")] Yahoo: devtools::install_github("trestletech/rydn") library(rydn) options(RYDN_KEY="yourAPIkey", RYDN_SECRET="yourSecret") b2 <- find_place("Berlin, ...


0

Yes. You need to resample your rasters in order for them to be the same size and have the same extent. R doesn't deal with that by itself. Given that neither of your rasters fully contain the other, you should consider creating a minimum-extent raster with your preferred resolution, and then resample and crop the others to match that.


1

The "landsat-util" Python package used to support querying Landsat images based on a boundary defined by a shapefile until version 0.5.0, where it was removed to get rid of some dependencies. You could try using a version before that, e.g. v0.2.0. It's only a year old, so there is a chance it might still work. The good news is that the package's devs are ...


1

Geodetic area calculations are not part of GDAL. You would probably need to write your own function to do it and exact solutions are computationally intensive. You're better off using an Equal-Area projection, such as Albers, Azimuthal, or Lambert azimuthal (https://en.wikipedia.org/wiki/Category:Equal-area_projections). For largish regions in Africa, ...


0

You are over complicating this a bit. In ArcGIS you can save your raster(s) as tiff or img formats. In R you can use the raster package to read the rasters (using raster(), stack() or brick() functions) and covert to a matrix or array in a single step. If you have a single raster then you would use the raster() function. However, if you are working with a ...


0

Zonal anisotropy is not something you can remove, but you can try to model it. R package gstat lets you model it by geometrically anisotropic models with very large ranges; try library(gstat) demo(zonal)


1

The following code might seem a little long-winded as it represents a manual approach rather than relying on OpenStreetMap, but maybe it's of any help to you anyway. I took the country boundaries and the referring country labels from the wrld_simpl dataset (class 'SpatialPolygonsDataFrame', projected in EPSG:4326) that comes with maptools. The shapefile data ...


1

Thanks everyone. Converting the layer to a raster and exporting as a text file was exactly what I needed for the time being. I used the convert to Raster function in the toolbox. . You can then use the raster to ASCII function to save the data as a txt file which can then be read by my r package.


5

You can: Load required libraries: library(raster) library(rgdal) Read rasters: r1 = raster("./dir/r1.tif") r2 = raster("./dir/r2.tif") Resample to the finer grid r.new = resample(r1, r2, "bilinear") If required (for masking), set extents to match ex = extent(r1) r2 = crop(r2, ex) Removed unrequired data r.new = mask(r.new, r2)


2

If you reproject a raster with labels, you will obviously get squeezed labels. The only way to avoid this is to render the raster from vector data directly into the desired projection. You might want to look into mapnik, tilemill or maperitive to do this from Openstreetmap raw data (which is vector data). The R openstreetmap package only offers raster ...


0

@aaryno Thanks for the detailed explanation. I tried using your code but it produces different output. I had to make a small change by substituting in the following line "cld" mat$landuse<-getValues(resample(cld,r,method='ngb')) with "clip1".After that, it works just fine. I tried deploying the below code to a windows machine and it works. ...


2

You can use either rgdal or raster (with an additional step of coersion) to export the prediction, prediction variance or prediction standard deviation as rasters. The sums of squares is stored as a vector where the fit and experimental variogram models are data.frame objects. You will have to attribute a column and output them into a single data.frame or ...



Top 50 recent answers are included