You can do this using the command line tool gdal_translate. This is available for Windows, Linux, and Mac OSs (you don't state your OS).
will show the info on the file, including the compression type and the locations:
Size is 204, 228
Coordinate System is:
In addition to @Spacedman's answer, you can set up a loop in R to compress tiffs using LZW with the writeRaster function in the raster package, which still uses GDAL. The options argument allows you to apply LZW compression.
In this example, the file is not overwritten but rather has an "_LZW" appended to the original name. To just overwrite the original ...
Your reclassification matrix isn't right - I suspect the 0.990 on rows 3 and 4 should be 0.099 - as it is the rows make up overlapping classes so the function throws an error:
[,1] [,2] [,3]
[1,] -0.500 -0.251 1
[2,] -0.251 -0.101 2
[3,] -0.101 0.990 3
[4,] 0.990 0.269 4
[5,] 0.269 0.439 5
[6,] 0.439 0.659 6
Starting with nc borders from the example(st_read) code, I'll first make a set of lines like in your data and then put them back together again. So we start with 100 North Carolina polygons in a spatial sf data frame:
 100 15
First, to take them apart, convert to lines and intersect them so the overlaps are gone:
> ncl = st_cast(...
For shapefile it has to be the name of the file without extension, so whatever you nominate as layer will be the file name, if you try to separate these by giving an explicit filename in dsn then the layer will be ignored.
u <- "http://geoportal.statistics.gov.uk/datasets/8edafbe3276d4b56aec60991cbddda50_2.geojson"
d <- rgdal::readOGR(u)
Your data must be projected to WGS84 before plotting:
adm_proj <- spTransform(adm, ‘+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs’)
addPolygons(data=adm_proj, weight = 2, fillColor = "yellow", popup=popup)
Thanks a lot, @Spacedman and @JepsonNomad for your comments. The comment by @Spacedman was very helpful. This line of code worked for me:
soil_raster2 <- rasterFromXYZ(moisture_data,res = 0.125,
crs = "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0",
digits = 3)
Given x a SpatialPoints object:
class : SpatialPoints
features : 50
extent : 0.0006317429, 0.9926516, 0.02675848, 0.9901886 (xmin, xmax, ymin, ymax)
coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
...you can convert to SpatialPointsDataFrame with as:
First I'll set up some data like yours:
Extents and coordinate systems:
> eland = extent(-79.39998, -79.32998, 43.61302, 43.63498)
> cland = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
> ewater=extent(-79.39958, -79.32958, 43.61292, 43.63458)
> cwater = "+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0"
Make land ...
There isn't an assignment for x in the code above so I can't generate your exact output, but you should be able to plot non-0 entries in your histogram by using hist(r[r!=0]).
Here's an assignment for x (just a placeholder) and some artificially-crafted 0's for the raster values that demonstrate the difference between hist(r) and hist(r[r!=0]):
x = seq(-1,...
The R equivalent of the ST_SnapToGrid in PostGIS is in the lwgeom package:
# Snap to grid of 5000 m
Works well to solve the non-noded intersection problem, and is quicker than applying a buffer of the same tolerance.
If these values:
bbox: xmin: 313368.6 ymin: 4832795 xmax: 314211.3 ymax: 4833629
(which are the range of the data location values) are latitude-longitude:
proj4string: +proj=longlat +ellps=clrk66 +no_defs
then something is terribly wrong with the shape of the earth.
Lat-long coordinates should only ever be (-180,180),(-90,90) - your ...
The lidR package relies on the rlas package to read and write las file. The rlas package has a recent support of LAS 1.4 files (v1.3.0 release date: 2019-02-03). Moreover the point record formats >6 are a bit different than former point formats. Your code is correct and you actually found a bug in function write.las from rlas that occurs with point format 6 (...
The addLayer function works by stacking all its arguments - to add a layer to an existing raster or stack make it the first argument. This is shown in the help:
file <- system.file("external/test.grd", package="raster")
s <- stack(file, file, file)
r <- raster(file)
s <- addLayer(s, r/2, r*2)
Running with only one argument produces that ...
Your terminology is bit unclear but I think it boils down to you trying to save spatial features vectors and expecting each element to have some attributes. You can't do that with vectors, you have to make spatial features data frames.
If you have an object that is an sfc class:
 "sfc_GEOMETRY" "sfc"
then saving it as a ...
You can read in irregular data if you know the max number of columns by giving column names and a fill argument:
> data = read.table("./lines.txt",col.names=c("x","y"),fill=TRUE, stringsAsFactors=FALSE)
1 ID1 NA
2 3285.48 -63.32
3 3285.14 -64.14
4 3284.67 -63.56
5 3285.00 -62.77
6 ID2 NA
7 3299.84 -76.82
You can find the code from each chapter at https://github.com/Robinlovelace/geocompr/tree/master/code/chapters.
The code for the first animation is at https://github.com/Robinlovelace/geocompr/blob/master/code/08-urban-animation.R, and for the second one at https://github.com/Robinlovelace/geocompr/blob/master/code/08-usboundaries.R.
I don't think you need to create new objects if all you want to do is sample points in a raster according to a criteria. You can simply filter the cells you want using the which() function.
Using the raster library, you can call the values(r) function to get a list of values, or just use r (where r is the raster object.)
The which() function will tell ...
There's no mention of what happens with layer names in the documentation for calc so I suspect the answer is "just because". If you rely on layer names in your code then you should probably explicitly set them any time you think they might change.
Note that arithmetic can change layer names - even though both operands here have the same name, the output is ...
The following code works including the load_output option. Just out of curiosity, are you running RQGIS3 from within RStudio? Because in my case running RQGIS3::open_app() crashes the RStudio R session. This was also confirmed by several other users (see the github issue tracker of RQGIS3). Since RQGIS3 works when run from the CLI, I am not really sure what ...
For me, run_qgis creates a bundle of .sdat files in the working directory:
 "aspect.sdat" "crossSectionalCurvature.sdat"
 "flowLineCurvature.sdat" "generalCurvature.sdat"
 "longitudinalCurvature.sdat" "maximalCurvature.sdat"
 "minimalCurvature.sdat" "...
readOGR syntax can be a bit unfriendly at times. Here's a suggestion.
Assuming your shapefile path is - C:/Users/Merry/Desktop/ro_judete_polgion.shp, the following should work:
#try without specifying a layer
ro_judete_poligon <- readOGR("C:/Users/Merry/Desktop/ro_judete_poligon.shp")
Maybe I'm misunderstanding the problem, but to plot two sets of data using two different aesthetics and hence get two different legends in ggplot is done like this:
First some data, points will do:
> d1 = data.frame(x=runif(10),y=runif(10),z=runif(10))
> d2 = data.frame(x=runif(10),y=runif(10),z=runif(10))
Now make a plot of ...
You have an error in your code. SpatialPoints cannot be constructed from an atomic vector of coordinates. The following works fine:
f <- tempfile(), mode='wb')
p <- readOGR(file.path(tempdir(), '...
I found a solution on my own (thank you for your suggestion @spacedman).
The problem was due to the way I defined the basemap aestetics. Initially, I was defining the map aesthetics in ggplot()
basemap.110.gilbert <- ggplot(data = shape.110.tidy, aes(x=long, y=lat, group=group)) +
coord_map("gilbert", ylim = c(-60, 70)) +