Skip to content

Instantly share code, notes, and snippets.

@schwehr
schwehr / bump_geemap_version_test.py
Created November 15, 2025 20:42
Draft bump_geemap_version_test.py - needs reformatting to geemap style
import builtins
import pathlib
import shutil
import sys
import tempfile
import textwrap
import unittest
from unittest import mock
from geemap.scripts import bump_geemap_version
@schwehr
schwehr / repr.py
Created October 30, 2025 15:47
A first attempt at text/rich mode for eerepr - does not work - https://github.com/aazuspan/eerepr/issues/68
# SPDX-License-Identifier: MIT
from __future__ import annotations
import html
from functools import _lru_cache_wrapper, lru_cache
from typing import Any, Literal, Union
from warnings import warn
import ee
@schwehr
schwehr / gtiff_test.cc
Created February 13, 2025 05:38
Renamed the file for Owen's gist for the gdal mailing list.
TEST_F(GTiffTest, CreateCopyPreservesMaskForBandInterleavedCog) {
constexpr char kFilename[] = "/vsimem/create_copy_with_mask.tif";
constexpr int kWidth = 2;
constexpr int kHeight = 2;
constexpr size_t kSize = kWidth * kHeight;
constexpr int kNumBands = 1;
GDALRegister_GTiff();
GDALDriver* driver = GetGDALDriverManager()->GetDriverByName(GTiff);
@schwehr
schwehr / inventory_test.cc
Created January 19, 2025 22:53
google gdal autotest2 inventory test for degrib
// Copyright 2017 Google Inc.All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@schwehr
schwehr / tiff_jxl.diff
Last active January 9, 2025 04:59
Enabling tif_jxl in libtiff
Same license as https://gitlab.com/libtiff/libtiff/-/blob/fa1d6d787fc67a1eeb3abccb790b5bee969d424b/LICENSE.md
Copied tif_jxl.c and tif_jxl.h from gdal/frmts/gtiff and then applied these changes
--- a/libtiff/tif_codec.c
+++ b/libtiff/tif_codec.c
@@ -90,6 +90,8 @@
{"ThunderScan", COMPRESSION_THUNDERSCAN, TIFFInitThunderScan},
{"NeXT", COMPRESSION_NEXT, TIFFInitNeXT},
{"JPEG", COMPRESSION_JPEG, TIFFInitJPEG},
@schwehr
schwehr / extelt.c
Created February 16, 2024 16:35
Patches to get extelt.c to work in a read only src environment (bazel inside of google3 forge)
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF. The full HDF copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF/releases/. *
* If you do not have access to either file, you may request a copy from *
@schwehr
schwehr / jpeginfo_test.py
Created October 13, 2023 17:35
jpeginfo: Possible starter test
#!/usr/bin/env python3
# Copyright 2023 Google Inc. All Rights Reserved.
"""Tests for jpeginfo command line app."""
import json
import subprocess
import unittest
@schwehr
schwehr / passing_data.py
Created July 5, 2023 16:41
Passing data in multiple different ways
#!/usr/bin/env python3
# SPDX-License-Identifier: Apache-2.0
# Copyright 2023 Google Inc. All Rights Reserved.
# I recommend that dataclass decorator option.
import collections
import dataclasses
@schwehr
schwehr / USGS_NLCD_RELEASES_2020_REL_NALCMS.json
Created June 12, 2023 23:42
USGS_NLCD_RELEASES_2020_REL_NALCMS with accents
{
"description": "The 2020 North American Land Cover 30-meter dataset was produced as part of\nthe North American Land Change Monitoring System (NALCMS), a trilateral\neffort between Natural Resources Canada, the United States Geological\nSurvey, and three Mexican organizations including the National Institute of\nStatistics and Geography (Instituto Nacional de Estadística y\nGeografía),\nNational Commission for the Knowledge and Use of the Biodiversity\n(Comisión\nNacional Para el Conocimiento y Uso de la Biodiversidad), and the National\nForestry Commission of Mexico (Comisión Nacional Forestal). The\ncollaboration is facilitated by the Commission for Environmental\nCooperation, an international organization created by the Canada, Mexico,\nand United States governments under the North American Agreement on\nEnvironmental Cooperation to promote environmental collaboration between the\nthree countries.\n\nThe general objective of NALCMS is to devise, through collective effort,
@schwehr
schwehr / NEON_CHM.json
Created May 22, 2023 19:34
NEON CHM STAC preview
{
"description": "Height of the top of canopy above bare earth (Canopy Height Model; CHM);\ndata are mosaicked over the AOP footprint onto a spatially uniform grid at 1\nm spatial resolution. The CHM is generated by creating a continuous surface\nof canopy height estimates across the entire spatial domain of the LiDAR\nsurvey, derived from the LiDAR point cloud. The point cloud is separated\ninto classes representing the ground and vegetation returns. The ground\nclassified points allow for calculation of a height normalized point cloud\nto provide a relative estimate of vegetation elevation. A surface is then\ngenerated using the height normalized vegetation points to produce the\nCHM. Any canopy heights less than 2m are set to zero for data collected with\nthe Optech Gemini LiDAR sensors, and less than 2/3m for the Riegl and Optech\nGalaxy sensors.\n\nSee [NEON Data Product DP3.30015.001](\nhttps://data.neonscience.org/data-products/DP3.30015.001) for\nmore details.\n\nDocumentation: [NEON DP3.30015.001