Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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 / 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 / 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
______________________________________________________________________
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 / gedi_to_csv.py
Created February 12, 2020 22:37
Python script to take GEDI level 2 data and convert variables to a CSV file. Usage `python gedi_to_csv.py <path> --variables [<var1>,<var2>,<var3>] --verbose`
import os
import fire
import h5py
import glob
import tqdm
import numpy as np
import pandas as pd
# requires h5py, tqdm, fire, numpy, and pandas to run
@KMarkert
KMarkert / gedi_to_vector.py
Last active October 7, 2023 06:53
Python script to take GEDI level 2 data and convert variables to a geospatial vector format. Usage `python gedi_to_vector.py <path> --variables [<var1>,<var2>,...,<varN>] --outFormat <extension> --filterBounds [<W>,<S>,<E>,<N>] --verbose`
import os
import fire
import h5py
import glob
import tqdm
import numpy as np
import pandas as pd
import geopandas as gpd
# requires fire, h5py, tqdm, numpy, pandas, and geopandas
@KMarkert
KMarkert / stac_search_example.ipynb
Last active March 4, 2020 09:17
stac_search_example.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import fire
import numpy as np
from osgeo import gdal
from scipy import ndimage
import dask.array as da
import tensorflow as tf
from tensorflow.python import keras
from tensorflow.python.keras import layers