Can you create an XYZ directory from geotiff - projection

Can you create and XYZ directory structure with GDAL? I have a bunch of geotiffs and I would like to re-project them with GDAL and create am XYZ directory structure.

I was able to modify the gdal2tiles.py script with some help:
https://gis.stackexchange.com/questions/63024/gdal2tiles-maptiles-from-bsb-kap-are-switched

Related

Reading data csv file from folder level above app.R file in shiny

I am trying to use a general path to read in my csv for a shiny app. I moved my app.R file in to a folder 'R' and my data folder is in the same level as the R folder so that it looks like this structure:
myAppFolder:
data (includes csv to read into app.R)
R (includes app.R)
I have written my path as follows:
df <- read_csv("./../data/myData.csv")
But I'm getting an error that my csv does not exist in the directory 'R' folder. How can I make it go up one level to access my data folder?
Thank you!
Assuming that your working directory is set as the "R" folder, you can access files from the other folder using just the two .. before the /. The .. brings you up one folder from the working directory and then you can work you way forward again as specified...
df <- read_csv("../data/myData.csv")

loading downloaded data to Rstudio

mission on online course:
Download this RData file to your working directory. Then load the data into R with the following command:
load("skew.RData")
so I have downloaded it to my computer but where is my working directory? or how do I load the downloaded file to Rstudio
You can see your working directory by executing getwd().
In order to load the data you need to change it to the folder path where the data is stored.
setwd("C:/your/path")
load("skew.RData")
You can set you working directory in RStudio on the right side manually and then save the files there and open them like :
load("skew.RData")
If your file is saved somewhere else, you should define the path to it:
load("path/to/your/file/skew.RData")

Save R output to a different directory

I am running some R code on a Windows computer using RStudio and my code generates Excel files and netCDF files periodically (dozens of them eventually). I don't want them to clutter my working directory. Is there a way to save the files to a directory called "Output" (ex: C:/.../original file path/Output) in the parent directory? I would like a way to change my current working directory to a different directory. I understand there is getwd() and setwd() but how do I set the path to the output directory without typing out the entire windows path (for example: setwd(current source file path for windows or Mac/output). My collaborator uses a Mac and he would have his output stored there as well.
You have a file argument in your write* function. If your Output directory is in your working directory, it works like this:
write.xlsx(df, file = "Output/table.xlsx")
write.csv(df, file = "Output/table.csv")
You can specify an argument in your write.csv function and other similar write functions which specifies your path.
#Output path
OutPath<- "C:/blah/blahblah/op/"
#Table to dump as output
OutTbl <- iris
write.csv(OutTbl, file = OutPath)
Source: https://stat.ethz.ch/R-manual/R-devel/library/utils/html/write.table.html

Unzipping a folder( not empty ) to a new named folder

I have a folder called newfast.zip in my remote server. I required to unzip as xyz folder. ( say xyz is my new folder name ), I tried like this:
[xxxxx#xxxxxautosuggest unzip]$ unzip newfast.zip xyz
Archive: newfast.zip
caution: filename not matched: xyz
[mohamear#stic-scm-autosuggest unzip]$ cl
But I turn with error. any one help me here please?
And any one suggest me the good tutorial page to learn all useful command of putty
Suggested work around: Create a directory, lets say zipcontent and then unzip the content into that dir: unzip file.zip -d zipcontent/
Suggested workaround: Unzip the folder to whatever it unzips to and rename it afterwards.

changing home directory in R

In R, if I use the command
write.csv(res,"~/table1_n500.csv")
, then the result is saved in C:\Users\John Smith\Documents.
But I expected it to be saved in C:\Users\John Smith\.
Can I change this home directory (referred by ~ mark) to C:\Users\John Smith\?
From my personal experience, i usually import data from a file (for example in the directory C:\Users\John Smith\DATA)
then i will set working directory as
setwd("C:/Users/John Smith/DATA")
While i want to save the output file in other directory like "C:\Users\John Smith" but not in the data folder.
so i will set relative working directory like
setwd("../")
And when you type getwd()
you will get [1] "C:/Users/John Smith"
Wish this help.
There are two ways to deal with this problem.
1.) Use the function setwd() to set the working directory (or home directory). All save and read commands will look for files in that working directory. I use this only sparingly, and for quick tiny project.
2.) A more preferred approach is to define a variable like dataInputDir, and use function file.path(dataInputDir, <your filename>) to generate a file path. The advantage is that if you are reading (writing) data from (to) multiple directories, you can do this more efficiently:
file.path(dataInputDir1, <your file or dir name>)
file.path(dataInputDir2, <your file or dir name>)
file.path(dataOutputDir1, <your file or dir name>)
file.path(dataOutputDir2, <your file or dir name>)
This approach is really handy for large complicated projects, and is highly recommended.
This is also helpful, if your program is to be executed on multiple platform like Windows, Mac, Linux. You'll have to change the directory location only at one place, and everything else will work smoothly.
Additionally, following functions/handles will be useful for dealing with directory names:
Quick fix:
setwd("../") # setwd to parent folder of current working directory (getwd())
More robust:
setwd(dirname(dataInputDir)) # Setwd to parent folder of dataInputDir

Resources