Skip to content

Instantly share code, notes, and snippets.

View bennyistanto's full-sized avatar

Benny Istanto bennyistanto

View GitHub Profile
@bennyistanto
bennyistanto / NetCDF_to_Tiff.py
Last active May 12, 2018 02:08
TRMM binary data export
#!/usr/bin/env python
"""
SYNOPSIS
NetCDF_to_Tiff [-h,--help] [-v,--verbose] [-i,--input] [-o, --output]
DESCRIPTION
This script converts a NetCDF time-series to a set
of TIFF images, one for each time step. It is designed
@bennyistanto
bennyistanto / MaxDate.py
Created April 22, 2020 06:08
Get maximum and date value from time-series rainfall data
import sys
import numpy as np
import arcpy
arcpy.env.overwriteOutput = True
ft = {'bool': lambda x: repr(x.astype(np.int32)),
'float_kind': '{: 0.3f}'.format}
np.set_printoptions(edgeitems=5, linewidth=120, precision=2, suppress=True,
threshold=100, formatter=ft)
@bennyistanto
bennyistanto / gt_threshold.py
Last active June 19, 2020 08:19
Extract pixel greater than the threshold for different return periods
#!/usr/local/bin/python
import arcpy
import os
import numpy
import pandas as pd
import glob
from arcpy.sa import *
#---------------------------Set environment settings------------------------------------#
@bennyistanto
bennyistanto / join_dbf_zonal.py
Created April 24, 2020 13:01
Merge DBFs from ArcGIS Zonal Statistics as Table
import arcpy
import os
import pandas as pd
import glob
#dbf to csv conversion
dbf_folder = "Z:\\Temp\\TIMESAT\\DBF\\adm2\\SOS\\2018_2020" #adjust this folder
csv_folder = "Z:\\Temp\\TIMESAT\\DBF\\adm2\\SOS" #adjust this folder
arcpy.env.workspace = dbf_folder
@bennyistanto
bennyistanto / rainfall_sst_regression.r
Created May 17, 2020 06:27
Pixel-wise regression between two raster time-series
#####
# Installing packages
install.packages(c('raster','readr','tidyr','dplyr','RColorBrewer','GISTools','sp',
'sf','ggplot2','bioimagetools','plyr',"orcutt","lmtest"), dependencies = T)
library(raster)
library(readr)
library(tidyr)
library(dplyr)
library(RColorBrewer)
@bennyistanto
bennyistanto / radiation.frm
Created May 19, 2020 10:31
Calculate radiation
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
' Program untuk menghitung Radiasi
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub cmdCal_Click()
Dim LAT As Double
Dim lon As Double
Dim MONTH As Double
Dim hari As Integer
@bennyistanto
bennyistanto / longterm_chirps_dekad.py
Last active June 6, 2020 00:48
Longterm MEAN, MAXIMUM, MINIMUM, STD for CHIRPS dekad data using arcpy
#!/usr/bin/env python
# Import system modules
import optparse, sys, os, traceback, errno
import ast
import re
import json
import ConfigParser
import re
import logging
import arcpy
@bennyistanto
bennyistanto / rainanom_chirps_dekad.py
Last active June 8, 2020 00:07
Rainfall anomaly using CHIRPS dekad
#!/usr/bin/env python
# Import system modules
import optparse, sys, os, traceback, errno
import ast
import re
import json
import ConfigParser
import re
import logging
import arcpy
@bennyistanto
bennyistanto / longterm_16days_chirps.py
Created June 15, 2020 14:17
Longterm MEAN, MAXIMUM, MINIMUM, STD based on MODIS 16days calendar for CHIRPS daily data using arcpy
# -*- coding: utf-8 -*-
import os
import arcpy
# MODIS 16 days calendar using Julian Date
chirps_16days_data = ['001', '017', '033', '049', '065', '081', '097', '113', '129', '145', '161', '177',
'193', '209', '225', '241', '257', '273', '289', '305', '321', '337', '353']
# Change the data and output folder
data_folder = "X:\\01_Data\\01_Global\\Rasters\\Climate\\Precipitation\\CHIRPS\\By16days"
@bennyistanto
bennyistanto / max_valueof_rasters.py
Created June 16, 2020 14:07
Extract MAXIMUM value from daily CHIRPS rasters in a folder
# -*- coding: utf-8 -*-
import arcpy
import os
from datetime import date
from datetime import timedelta
import multiprocessing
#Overwrite the output if exist
arcpy.env.overwriteOutput = True