Skip to content

Instantly share code, notes, and snippets.

@ashnair1
ashnair1 / CUDA_Compilers.md
Created May 30, 2023 11:15 — forked from ax3l/CUDA_Compilers.md
CUDA Compilers
@ashnair1
ashnair1 / predict.py
Created September 21, 2022 12:28
torchgeo predict using Caleb's SingleRasterDataset
#!/usr/bin/env python3
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""torchgeo model inference script."""
import argparse
import os
from typing import Any, Callable, Dict, Optional, Tuple, Type, cast
@ashnair1
ashnair1 / Difference between EPSG 4326 & 3857
Created January 12, 2022 12:05 — forked from keum/Difference between EPSG 4326 & 3857
EPSG 4326 and EPSG 3857 of Web Mercator
EPSG: 4326 uses a coordinate system on the surface of a sphere or ellipsoid of reference.
WGS 84 - Earth as Geoid. -Mercator
EPSG: 3857 uses a coordinate system PROJECTED from the surface of the
sphere. Earth as perfectly sphere. -Web Mercator
Think of it as this way:
EPSG 4326 uses a coordinate system the same as a GLOBE (curved surface).
EPSG 3857 uses a coordinate system the same as a MAP (flat surface).
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 shutil
src_dir = "./Files"
dst_dir = "./Result"
"""
@ashnair1
ashnair1 / gdal_commands.md
Last active May 7, 2024 12:08
Useful gdal commands

1. Rescale specfic bands and write them to output tiff

gdal_translate -ot Byte -b 5 -b 3 -b 2 -scale_1 0 1970 0 255 -scale_2 0 1860 0 255 -scale_3 0 1174 0 255 WV.TIF WV_RGB.TIF

We take bands 5 (red), 3 (green) and 2(blue), scale them to 8 bit range and write it to an output file. Things to note:

a. Output scale by default is 0 to 255, so there's no real reason to specify. 
b. Once we pick the bands, they are thereafter referred w.r.t output. This is why we specify `scale_1` to rescale band 5 because band 5 in the input is band 1 of output.
@ashnair1
ashnair1 / merge-geojsons.py
Last active August 28, 2020 18:54 — forked from themiurgo/merge-geojsons.py
Merge two or more geojson files.
from json import load, dump
from argparse import ArgumentParser
from re import compile
import sys
import os
parser = ArgumentParser(description="Group (merge) multiple GeoJSON files.")
defaults = dict(outfile=sys.stdout)
@ashnair1
ashnair1 / Install NVIDIA Driver and CUDA.md
Created August 14, 2019 15:46 — forked from wangruohui/Install NVIDIA Driver and CUDA.md
Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
@ashnair1
ashnair1 / dota2coco.py
Last active August 5, 2019 05:50
DOTA2COCO_Converter
# -*- coding:utf-8 -*-
import os
import cv2
import json
import pprint
import numpy as np
from PIL import Image
category_dict = {'plane': 0, 'ship': 1, 'storage-tank': 2, 'baseball-diamond': 3, 'tennis-court': 4, 'basketball-court': 5,
'ground-track-field': 6, 'harbor': 7, 'bridge': 8, 'small-vehicle': 9, 'large-vehicle': 10,