Skip to content

Instantly share code, notes, and snippets.

View soiqualang's full-sized avatar
🙃
hihihaha

Đỗ Thành Long soiqualang

🙃
hihihaha
View GitHub Profile
@adriennn
adriennn / leaflet-css-divicon.txt
Created September 18, 2015 08:11
Create a lightweight L.divIcon for Leaflet using css and icon fonts
// modified from http://codepen.io/gisminister/pen/Hdorv
// Create a marker
var myMarker = L.divIcon({
className: 'map-marker marker-color-gray a-class',
iconSize: [28,28],
html:'<i class="fa fa-fw fa-2x fa-question"></i>' // FontAwesome.io
});
// Style with css
@CMCDragonkai
CMCDragonkai / npmatrix_to_geotiff.py
Last active June 28, 2019 02:34
Numpy Matrix to GDAL GeoTiff #python #gdal #numpy
import numpy as np
from osgeo import gdal, gdal_array, osr
def npmatrix_to_geotiff (filepath, matrices, gdal_type, transform = None, projection = None, nodata = None):
(y_res, x_res) = matrices[0].shape
driver = gdal.GetDriverByName('GTiff')
image = driver.Create(filepath, x_res, y_res, len(matrices), gdal_type)
if transform is not None:
image.SetGeoTransform(transform)
if projection is not None:
@soiqualang
soiqualang / postgresql-set-id-seq.sql
Created August 8, 2019 07:32 — forked from henriquemenezes/postgresql-set-id-seq.sql
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@shaystrong
shaystrong / Readme.md
Last active March 26, 2020 06:52
SWIR DG processing
  1. Image download from ftp --> upload to AWS s3 bucket

  2. Pull to AWS EC2 machine. Save off SWIR band ratios as tif with appropriate contrast. The SWIR data is an 8-band image. You need to first grab onnly the bands you need for visualization (8-3-1 or 6-3-1 make good combos)

import rasterio
import numpy as np

raster='18NOV09185526-A2AS-058669488010_01_P001.TIF'. #your file
#!/usr/bin/env python
from fiona.transform import transform_geom
from rasterstats import point_query
import mercantile
def make_dem_url(lon: float, lat: float, z: int = 14) -> str:
"""Returns a URL referencing the GeoTiff Digitial Elevation Model (DEM)
for the given point at a zoom level (default, max is 14).
@soiqualang
soiqualang / zonal_stats.py
Created March 28, 2020 14:42 — forked from perrygeo/zonal_stats.py
Python implementation of zonal statistics function. Optimized for dense polygon layers, uses numpy, GDAL and OGR to rival the speed of starspan.
"""
Zonal Statistics
Vector-Raster Analysis
Copyright 2013 Matthew Perry
Usage:
zonal_stats.py VECTOR RASTER
zonal_stats.py -h | --help
zonal_stats.py --version
@trolleway
trolleway / wfs_download.py
Created November 10, 2015 13:30
mass download vector data from WFS service. Generates a sh script with ogr2ogr calls.
from owslib.fes import *
from owslib.etree import etree
from owslib.wfs import WebFeatureService
wfs11 = WebFeatureService(url='http://example.com:8080/geoserver/wfs/', version='1.1.0')
f = open('download.sh', 'wb')
f.write('#!/bin/bash'+'\n')
f.write(''+'\n')
@emiliom
emiliom / AOOS_SOS_SensorML_owslib_AlaskaNDBCBuoy_1.ipynb
Created November 5, 2013 01:50
#IOOS #SOS #OWSLib #MMI Access the AOOS SOS GetCapabilities, issue a sample DescribeSensor request, then parse parts of the response. Includes examples of testing the validity of controlled vocabulary terms vs MMI (using the approach described on the IPython notebook http://nbviewer.ipython.org/6514804). This SOS test complements the one for Get…
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmcbride
bmcbride / gdal.txt
Last active January 11, 2021 17:48
GDAL commands to convert NYSDOP orthoimagery JPEG2000 files to GeoTiff & PDF
SINGLE FILE CONVERT
gdal_translate input_nysdop_ortho.jp2 output.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co JPEG_QUALITY=25 -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES -a_srs EPSG:2260
BATCH CONVERT
for /r %g in (*.jp2) do gdal_translate -of GTiff "%g" "%~dpng.tif" -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co JPEG_QUALITY=25 -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES -a_srs EPSG:2260
BUILT VIRTUAL RASTER (CATALOG)
gdalbuildvrt catalog.vrt e_06811416_06_05000_4bd_2011.jp2 e_06811414_06_05000_4bd_2011.jp2 e_06781416_06_05000_4bd_2011.jp2 e_06781414_06_05000_4bd_2011.jp2
gdalbuildvrt -allow_projection_difference -hidenodata -vrtnodata "255 255 255" nysdop.vrt *.jp2 -a_srs EPSG:2260