Skip to content

Instantly share code, notes, and snippets.

View metasim's full-sized avatar
🎹

Simeon H.K. Fitch metasim

🎹
View GitHub Profile
use futuresdr::anyhow::Result;
use futuresdr::macros::async_trait;
use futuresdr::runtime::BlockMeta;
use futuresdr::runtime::BlockMetaBuilder;
use futuresdr::runtime::Kernel;
use futuresdr::runtime::MessageIo;
use futuresdr::runtime::MessageIoBuilder;
use futuresdr::runtime::StreamIo;
use futuresdr::runtime::StreamIoBuilder;
use futuresdr::runtime::TypedBlock;
@metasim
metasim / warp_test.rs
Created November 3, 2023 20:13
Testing Reprojection Nodata
use std::ffi::CString;
use std::process::exit;
use std::ptr;
use gdal::errors::Result;
use gdal::spatial_ref::SpatialRef;
use gdal::Dataset;
use gdal_sys::{
CPLErr, CSLSetNameValue, GDALCreateWarpOptions, GDALDestroyWarpOptions, GDALResampleAlg,
GDALWarpInitDefaultBandMapping, GDALWarpInitDstNoDataReal,
@metasim
metasim / bidx.rs
Last active October 17, 2023 20:27
Safe Band Indexing for GDAL.
use std::fmt::{Display, Formatter};
use serde::{Deserialize, Serialize};
use std::num::NonZeroUsize;
/// Represents a band index, which may be either one-based (Fortran-style, as used by GDAL)
/// or zero-based (C-style, as used by collection libraries).
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
#[repr(u8)]
pub enum BIdx {
/// Zero-based indexing (i.e. C-style)
@metasim
metasim / rustdoc-output.sh
Created September 28, 2022 18:53
View output from rustdoc tests.
RUSTDOCFLAGS="-Zunstable-options --nocapture" cargo +nightly test --doc
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@metasim
metasim / Cargo.toml
Created March 7, 2022 14:38
Error reporting bug in JetBrains Rust Plugin
[package]
name = "ext-err"
version = "0.1.0"
edition = "2021"
[dependencies]
extend = "1.1.2"
ORG=not-important
REPO=gdal-pinned
brew tap-new $ORG/$REPO
brew extract --version 2.4.4 gdal $ORG/$REPO
brew install $ORG/$REPO/[email protected]

Tooling for Python Runtime Environments

Source: @amontalenti

There's a zoo of tools available for defining and managing Python environments, and for maintaining code quality. Here's one common and durable mix of third-party toos that do a good job with packaging, deployment, testing & linting.

Environments

For local development & local dependency environments, pyenv with its pyenv-virtualenv is very future-proof. Plus, pyenv has support for miniconda, Python 2 vs 3 issues, PyPy, etc. for situations where you need that. It's also a good choice for simple Python "environment-based" deployments to remote servers. See this StackOverflow link entry on why this is a solid choice. If you stick with pyenv and its built-in virtualenv/venv plugin, you'll be very future-proofed and very standard.

Dependencies

import geotrellis.raster._
import geotrellis.vector.Extent
import org.apache.spark.sql._
import org.apache.spark.sql.functions._
import org.locationtech.jts.geom.Point
import org.locationtech.rasterframes._
import org.locationtech.rasterframes.datasource.raster._
import org.locationtech.rasterframes.encoders.CatalystSerializer._
object ExplodeWithLocation extends App {
import org.apache.spark.sql._
import org.apache.spark.sql.functions._
import org.locationtech.rasterframes._
import org.locationtech.rasterframes.datasource.raster._
import org.locationtech.rasterframes.encoders.CatalystSerializer._
import geotrellis.raster._
import geotrellis.vector.Extent
import org.locationtech.jts.geom.Point
object ValueAtPoint extends App {