Skip to content

jiachengzhao/prerequisite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prerequisite for a new PC/Mac before they can do scientific analyses

Google Earth Engine (GEE)

  • Command line tool installation (for PC)

    1. Make sure you have a valid VPN

    2. Conda install
      Follow this page.
      Maybe add other channels, e.g.,
      conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
      conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
      conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
      conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
      conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
      conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
      conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
      Change conda to default channel: conda config --remove-key channels
      Set environment variables following this page.

    3. Install the Google Cloud CLI
      Follow this page.

    4. Authentication Earth Engine
      First set environment variables as
      name: http_proxy
      value: socks5://server:port (e.g., socks5://127.0.0.1:7890)
      name: https_proxy
      value: socks5://server:port (e.g., socks5://127.0.0.1:7890)
      and then authenticate Earth Engine

      set http_proxy=socks5://127.0.0.1:7890
      set https_proxy=socks5://127.0.0.1:7890
      earthengine authenticate
      set http_proxy=
      set https_proxy=
      
      
    5. Make python3 available
      Follow this page.

    6. Install geeup
      First re-open Terminal, and enter the ee environment you just created by conda activate ee. Install geeup by the command pip install geeup. After installation, test it by geeup -h.

    7. Disable python aliases (optional)
      Follow this page.

    8. Set up geeup (cookies)
      Follow this page.

    9. Examples

      • help
      geeup -h
      
      • get metadata
      geeup getmeta --input "C:/Users/zhao_/Nutstore/1/Nutstore/wc_10m_prec" --metadata "C:/Users/zhao_/Nutstore/1/Nutstore/wc_10m_prec/metadata.csv"
      
      • image batch upload
      geeup upload --source "C:/Users/jzhao/Downloads/tif" --dest "projects/ee-jzhao-external-dataset/assets/raster/urban-climate-in-europe/paris" -m "C:/Users/jzhao/Downloads/tif/metadata.csv" -u "[email protected]"
      
      • delete image/image collection
      geeup delete --id projects/ee-jzhao-crop-response-to-o3/assets/viirs-sr-red-500-filling
      
      • upgrade geeup
      pip install --upgrade geeup
      
  • Command line tool installation (for Mac)

    1. Use /bin/sh
      Open Terminal on Mac then command + , to Preferences. Change Default login shell to /bin/sh.


    2. Conda install
      Follow this page.
    3. Install the Google Cloud CLI
      Follow this page.
    4. Install pip on Mac
      Follow this page. You may need to install the command line developer tools.
    5. Set up environmental variables
      • Create a profile file if you don't have one by opening Terminal and issuing the command touch .profile, then close Terminal.
      • Add the two lines below to the profile file either manually (the file should be hidden in /Users/<your username>/.profile) or by vim ~/.profile.
      export PATH=/Users/<your username>/miniconda3/bin:$PATH
      export PATH=/Users/<your username>/google-cloud-sdk/bin:$PATH
      
    6. Install geeup
      First re-open Terminal, and enter the ee environment you just created by source $HOME/miniconda3/bin/activate and then conda activate ee. Install geeup by the command pip install geeup. After installation, test it by geeup -h.
    7. Set up geeup (cookies)
      Follow this page.

    geeup getmeta --input "C:/Users/jzhao/Downloads/nc" --metadata "C:/Users/jzhao/Downloads/nc/metadata.csv"

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings https://stackoverflow.com/questions/65348890/python-was-not-found-run-without-arguments-to-install-from-the-microsoft-store

  • Image batch upload
geeup upload --source "D:/Data/MSWX/Monthly/Processed" --dest "projects/ee-jzhao-external-dataset/assets/raster/mswx/past/monthly" -m "D:/Data/MSWX/Monthly/Processed/metadata.csv" -u "[email protected]"
  • Reproject image1 to image2
image1.resample('bilinear').reproject({
    crs: image2.projection().crs(),
    scale: image2.projection().nominalScale()
});

R

  • Import Windows fonts to R
install.packages('remotes')
remotes::install_version('Rttf2pt1', version = '1.3.8')
install.packages('extrafont')
extrafont::font_import()
extrafont::loadfonts(device = 'win')
  • Rstudio header
snippet header
	## ----------------------------------
	# Title: 
	# Objective: 
	# Created by: Jiacheng Zhao
	# Created on: `r Sys.Date()`
	# Copyright (c) Jiacheng Zhao, `r format(Sys.Date(), "%Y")`
	# Nanjing University of Information Science & Technology (NUIST)
	# Email: [email protected]
	## ----------------------------------
snippet par
	# cex --------------------------------
	cex.axis = 1.1
	cex.point = 1.7
	cex.legend = 1
	cex.label = 0.7
	cex.axis.label = 0.8
	cex.title = 1.5
	
	# font -------------------------------
	font = 'Calibri'
	
	# lwd --------------------------------
	lwd = 0.5
	medlwd = 1.3
	boxwex = 0.18
	lwd.axis = 0.5
	
	# axis -------------------------------
	x.axis.line = 2.2; y.axis.line = 1.8
	mgp1 = c(3, 0.1, 0)
	mgp2 = c(3, 0.2, 0)
	mgp3 = c(3, 0.1, 0)
	mgp4 = c(3, 0.2, 0)
	tck = 0.03
	
	# legend -----------------------------
	inset = c(0, 2)
	x.intersp = 0.9; y.intersp = x.intersp
	
	# color ------------------------------
	col = 'red'
	cols = c('seagreen', 'gold')
	
	# par --------------------------------
	par(
	cex.axis = cex.axis,
	family = font,
	las = 1,
	lwd = lwd,
	mai = c(0, 0.5, 0, 0.2),
	mfrow = c(6, 1),
	oma = c(6.5, 1.5, 2, 1),
	tck = tck
	)

  • Create an r package
require(devtools)
setwd('C:/Users/jzhao/Documents/Nutstore/Projects')
create('smot')
  • Pattern matching and replacement
DT[grep('(?=.*A)(?!.*W)', group, perl = T)]

era5cli

  • Requests of ERA5-Land hourly data
    era5cli hourly --land --variables 2m_temperature  --startyear 1950 --endyear 1950 --splitmonths True
    

7zip

  • Batch unzip
    "C:\Program Files\7-zip\7z.exe" e *.zip
    

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages