Skip to content

Instantly share code, notes, and snippets.

View KMarkert's full-sized avatar
👨‍💻

Kel Markert KMarkert

👨‍💻
View GitHub Profile
import math
def dd2dms(dd):
if dd < 0:
degrees = math.ceil(dd)
else:
degrees = math.floor(dd)
minutes = 60 * (dd%1)
seconds = 60 * (minutes%1)
@KMarkert
KMarkert / vrg2timerseries.py
Created September 9, 2017 17:33
Grabs NRT precipitation data from the FTP service of vrsg-servir.adpc.net and creates daily timeseries for a given polygon
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
vrg2timeseries.py, SERVIR-Mekong (2017-07-26)
Downloads data from SERVIR-Mekong's Virtual Rain and Stream Gauge (VRSG)
(vrsg-servir.adpc.net) and calculates a time series of the daily data over
an area
______________________________________________________________________
@KMarkert
KMarkert / dd2meter.py
Last active February 21, 2017 18:45
This Gist is focused on converting decimal degrees length to meters (or vise versa) for a specific point on the globe. It is based on an approximation and only should be used as a general measurement (errors around 10 m).
import numpy as np
def dd2meters(inPt,scale=0.1):
"""Function to convert decimal degrees to meters based on the approximation
given by: https://en.wikipedia.org/wiki/Geographic_coordinate_system
Args:
inPt (list or array): A Y,X point provided in geographic coordinates
in that order.
@KMarkert
KMarkert / grid_amsrL2Swath.py
Last active October 21, 2019 09:23
This Python script takes NASA LANCE lvl 2 AMSR2 swath data from the GHRC DAAC and grids the data to a GeoTIFF output
#*****************************************************************************
# FILE: grid_amsrL2Swath.py
# AUTHOR: Kel Markert
# EMAIL: [email protected]
# MODIFIED BY: N/A
# ORGANIZATION: UAH/ESSC
# CREATION DATE: 02/10/2017
# LAST MOD DATE: 02/11/2017
# PURPOSE: This scripts takes LANCE L2 swath AMSR2 data from GHRC, grids the
# data, and outputs a geotiff
@KMarkert
KMarkert / parse_landsat_xmlMetadata.py
Last active August 24, 2020 15:48
This Python script takes the metadata from the USGS Landsat Bulk Metadata Service in XML format and finds coincidence dates for water quality station samples
import datetime
import xmltodict
import numpy as np
import pandas as pd
"""
XML metata data file is take from https://landsat.usgs.gov/landsat-bulk-metadata-service
"""
# Define input files
@KMarkert
KMarkert / bulk_download_swbd.py
Last active October 6, 2023 06:07
This script is used to bulk download SRTM Water Body Data from the USGS over a defined AOI
import os
import glob
import urllib2
import numpy as np
outFolder = "J:/africa_srtm/org_zip/" #change output path
lats = np.arange(-35,33)#change lat bounds
lons = np.arange(-18,52)#change lon bounds