I posted this question earlier but I like to repeat it again.  I have 50 folders. Each folder consists of 40 rasters. Each raster has a value that I need to extract. These rasters share the same x&amp;y. Finally, I need to put them all in one data frame. To do so, I tried to run a loop to read all rasters from all folders and combine them by row. For example, I have 50 Rain rasters, so these will fall under the same column and so on. Is there any way to do that?  Here are the codes:  Reading &lt;- function(raster) {   df &lt;- stack(raster) }  All_raster &lt;- dir("E:/50_folders/", recursive=TRUE, full.names=TRUE, pattern=".tif$")# This is to read rasters from 50 folders All_tif &lt;- sapply(All_raster, Reading) ALl_tif &lt;- as.data.frame(All_tif , xy =TRUE)   And this is the error I get Error in as.data.frame.default(x[[i]], optional = TRUE) :    cannot coerce class ‘structure("RasterStack", package = "raster")’ to a data.frame
121725
I could read many rasters as one list of ratsers but when I want to convert them to data frames I get an error.   Is there any way to convert them?  library(raster) Pro &lt;- function(s) {   df &lt;- stack(s) }  files &lt;- dir("path", recursive=TRUE, full.names=TRUE, pattern=".tif$")  agg &lt;- sapply(files, Pro)  df &lt;- as.data.frame(agg)
32832
I have a raster and a vector point file. I need to generate another raster of same resolution showing how many points are inside the corresponding pixels of the original raster.  Something like that:   Is there a way of doing that in QGIS?   I just want the number of points, no attributes involved.
81944
I'm trying to reclassify only a certain part of a raster...not the entire raster.  Here's the problem.  I have a LULC raster of the entire US.  There are some issues with the raster that I want to fix, namely some cells that should be water are classified as wetlands.  These are mainly off the coast, not inland.  However, some cells that are classified as wetlands should really be wetlands (mainly inland) and I don't want these to change.  I plan on using a ZIP Code boundary file to determine which cells are considered "off the coast" and which ones are not.  I have access to ArcGIS 10.1 and R with the appropriate raster packages I need so a solution in either software would be fine.  Can anyone help me figure this out?
89071
Is there a way to replicate the Split Vector Layer function from QGIS in R?   I have a Shapefile containing around 20 polygons that I'd like to split into 20 separate files.   I guess since it's in QGIS there would be a solution in Python, but I'd like to integrate it into a R workflow if possible.
81970
Let's say I have a directory tree like this:  FOLDER:     file1     file2     file3     Subfolder1:         file1         file2     Subfolder2:         file1         file2   If I used rm -r FOLDER/*, everything in FOLDER would be deleted including sub-directories. How can I delete all files in FOLDER and in its sub-directories without deleting actual directories?
97939
Can someone tell me what is wrong with this loop?    The error that I have is on the line 107 (first line of the loop). It says:      [V2016057174800: command not found.    I am trying to associate two the same filename from two different documents (if that makes sense).
112069
I have multiple files with the same header and different vectors below that. I need to concatenate all of them but I want only the header of first file to be concatenated and I don't want other headers to be concatenated since they are all same.   for example: file1.txt  &lt;header&gt;INFO=&lt;ID=DP,Number=1,Type=Integer&gt; &lt;header&gt;INFO=&lt;ID=DP4,Number=4,Type=Integer&gt; A B  C   file2.txt  &lt;header&gt;INFO=&lt;ID=DP,Number=1,Type=Integer&gt; &lt;header&gt;INFO=&lt;ID=DP4,Number=4,Type=Integer&gt; D E  F   I need the output to be   &lt;header&gt;INFO=&lt;ID=DP,Number=1,Type=Integer&gt; &lt;header&gt;INFO=&lt;ID=DP4,Number=4,Type=Integer&gt; A B C D E  F   I could write a script in R but I need it in shell?
8872
I've got a folder full of folders, and some of those folders may or may not have folders in them. It looks something like this:  ~/stuff/01.d/01/files ~/stuff/02.d/files ~/stuff/03.d/files ~/stuff/04.d/lol/files ~/stuff/05.d/files   I want to make separate .rars for each of the folders in ~/stuff, so I was going to do for f in *.d; do rar a "${f//.d/.rar}" "$f"; done which worked great, and gave me the rars. But I'd rather have no directory structure in the rars at all, just files. Is there an easy way to do this? It seemed like one of the switches looked like it might have done what I wanted, but the man page is a bit confusing. I'll try a few things.  I may end up trying to figure out a bash script to cd into the directory, check if it's the files, if so make the .rar in the parent (../${f//.d/.rar}), else go into the directory again and make the rar two parents up (../../${f//.d/.rar}). In this case, I'd want rar a ../"${f//.d/.rar}" * I think, I haven't tested it.
63647
I have a series of continuous rasters representing the same phenomenon over time, so I need to use the same symbology across them all.  So I set the stretched symbology of the first raster, with a color ramp from the min/max values:    Now in the second raster, I import the symbology from the first raster. Unfortunately, although the labels match, the actual min/max values are not the same as the first layer:    So the red in the second raster corresponds to a value of 0.47, rather than 0.66.  How can I ensure that both rasters are using a consistent symbology?
102684
I have 6500 processed and clipped rasters that indicate snow levels on a daily basis in the northern hemisphere. I need to create a raster that represents a sum of the snow for the season. The winter season would then go from September 1999 to march 2000. I was just wondering how I would go about recalling the daily rasters into R using the loop function/ how i would go about calculating the seasonal sums. Keep in mind that the rasters span two different years and that I don't want to include all 1999 snow data because that would include the previous winter(98/99) as well.
110839
I have some multi-spectral data, where the individual bands are separate Raster files.  How do I layer stack these rasters so that I get one raster with 3 bands instead of 3 different rasters?  This is quite easy to do in ERDAS and ArcGIS, but I haven't figured out how to do it in QGIS
118780
I'm having a problem using the group function in TraMineR. I have a data set that contains SPELL data, so multiple rows per case. I also have demographic data per case, at one row per case. I merge these together and end up with data that has a demographic covariate per row, so multiple rows per case. An example of this data would be:  id startmin stopmin activity educ4 4      1      20       work    HS 4      20     40       play    HS 8      1      15       sleep   College 8      15     40       work    College   I can make sequence data from this, but when I try to run a plot using the group command        seqiplot(atus.seq, group = atus.seqdata$educ4, border=NA,                 withlegend="right",  cex.plot=.55)   it tells me:       &gt;"Error: group must contain one value for each row in the sequence object".   I have gotten this to work with the example of the mvad data in the training manual, but I can't seem to get it to work with the groups, whether I link to the original demographic data, the merged data, or try to pass the covariates by seqformat and seqdef. Ideas?
43966
When I cut one raster with clip raster by mask layer I get the expected result.  But when applying batch processing with the same vector file, and the same rasters, the rasters aren't clipped and the values are changed to 0 and NaN?  The rasters are landsat 5 images, and the vector has the same datum.  Edit: I've figured out this is the gdal command used when processing individually:  gdalwarp -ot Float32 -q -of GTiff -cutline "some_shape.shp" -co COMPRESS=DEFLATE -co PREDICTOR=1 -co ZLEVEL=6 -wo OPTIMIZE_SIZE=TRUE "original_raster.tif" "clipped_raster.tif"  And this one is used in batch processing:  gdalwarp -ot Byte -q -of GTiff -cutline "some_shape.shp" -co COMPRESS=NONE -wo OPTIMIZE_SIZE=TRUE "original_raster.TIF" "clipped_raster.tif"  Why the differences?
30632
I'm very new with R and stats in general, but I need to make a scatterplot that I think might be beyond its native capacities.  I have a couple of vectors of observations and I want to make a scatterplot with them, and each pair falls into one out of three categories. I would like to make a scatterplot that separates each category, either by colour or by symbol. I think this would be better than generating three different scatterplots.  I have another problem with the fact that in each of the categories, there are large clusters at one point, but the clusters are larger in one group than in the other two.  Does anyone know a good way to do this? Packages I should install and learn how to use? Anyone done something similar?  Thanks
54956
I am trying to export existing raster layers as tif files. I just want to avoid saving each raster manually. this is the code I am trying to use, but it doesn't seem to work:  from PyQt4.QtCore import * from qgis.core import * from qgis.gui import * import os import sys  layers = iface.layerTreeView().selectedLayers() for layer in layers:     output='Desktop'%layer.name%'.tif'   As specified in a comment below, I modified my code to this:  from PyQt4.QtCore import * from qgis.core import * from qgis.gui import * import os import sys   layers = iface.layerTreeView().selectedLayers()  for layer in layers:      file_name = 'D:\tif' + layer.name() + '.tif'      file_writer = QgsRasterFileWriter(file_name)      pipe = QgsRasterPipe()      provider = layer.dataProvider()       if not pipe.set(provider.clone()):         print "Cannot set pipe provider"      continue       file_writer.writeRaster(         pipe,         provider.xSize(),         provider.ySize(),         provider.extent(),         provider.crs())   I can't seem to get it to work and I am not getting any error.  I already selected the layers and it still does not work.
101676
Context: I want to store the TIFF data to use it for running a linear regression model later on. Ultimate goal: Create a carbon map using field data as a basis. Libraries: library(sp) library(raster) library(tidyverse) library(rgdal)  plotcoord &lt;- SpatialPointsDataFrame(AGCplot[,3:4], AGCplot[,1:2],proj4string=CRS('+proj=longlat'))  pspcoord&lt;-spTransform(plotcoord, CRS('+proj=utm +zone=21')) #Omzetten naar UTM21N (= S1) plot(pspcoord)  s1 &lt;- stack('Some.tif')  colnamen = c(&quot;plotid&quot;,&quot;AGC&quot;,&quot;B2&quot;,&quot;B3&quot;,&quot;B4&quot;,&quot;B5&quot;,&quot;B6&quot;,&quot;B7&quot;,&quot;B8&quot;,&quot;B8A&quot;,&quot;B11&quot;,&quot;B12&quot;,&quot;NDVI&quot;,&quot;NDWI&quot;,&quot;MMRI&quot;,&quot;IRECI&quot;,&quot;MASI&quot;,&quot;VV&quot;,&quot;VH&quot;)  s1_e &lt;- extract(s1,pspcoord,method='bilinear')  Upon extraction I get the following message: Warning message: In proj4string(x) : CRS object has comment, which is lost in output
107815
I have about 300,000 CSV files which I want to convert to shapefiles, but ArcGIS and QGIS can only convert one CSV at a time.  Are there any ways to batch convert my CSVfiles?  x y z1 z2 z3 z4 1 2 3  4  5  6   My csv files just have a few columns like above  Can any one help me?