Skip to content

Instantly share code, notes, and snippets.

@oscarfonts
oscarfonts / ecw_to_geotiff.sh
Last active Oct 21, 2020
ECW to GeoTIFF conversion with ginetto/gdal
View ecw_to_geotiff.sh
FILENAME=Me1956
# fetch image
docker pull ginetto/gdal:2.4.1_ECW
# convert ecw to geotiff
docker run --rm -it --name gdalecw -v $PWD:/home/datafolder ginetto/gdal:2.4.1_ECW \
gdal_translate -co "TILED=YES" -co "COMPRESS=JPEG" -co "PHOTOMETRIC=YCBCR" -co "NUM_THREADS=ALL_CPUS" -co "BIGTIFF=YES" /home/datafolder/${FILENAME}.ecw /home/datafolder/${FILENAME}.tif
# add external overviews
@oscarfonts
oscarfonts / image_utils.md
Last active May 4, 2020
Custom area screenshot & image optimization
View image_utils.md

Add Alt + PrintScreen keyboard shortcut

mate-screenshot -ai

image_half.sh

#!/usr/bin/env bash
mogrify -resize 50% "$@"

png8.sh

View compress_video.sh
#!/usr/bin/env bash
targetfilename="${1%.*}"
ffmpeg -i "${1}" -acodec mp2 -vcodec libx265 -crf 30 -vf "scale=iw/2:ih/2" "$targetfilename-compressed.mp4"
View install-telegram.md

Install telegram

wget -O- https://telegram.org/dl/desktop/linux | sudo tar xJ -C /opt/
sudo ln -s /opt/Telegram/Telegram /usr/local/bin/telegram-desktop

Create menu entry

wget https://telegram.org/img/t_logo.png -O /usr/share/pixmaps/telegram.png

Create /usr/share/applications/telegram.desktop file with the following contents:

@oscarfonts
oscarfonts / gdal_ecw.sh
Created Feb 3, 2020 — forked from 1papaya/gdal_ecw.sh
Install GDAL 2.3 with ECW support on Ubuntu 18.04
View gdal_ecw.sh
#!/bin/bash
##
## Tested on: Ubuntu 18.04 & ECW 5.4 & GDAL 2.3.1
##
## Download the ERDAS ECW JP2 SDK v5.4 Linux
## https://download.hexagongeospatial.com/downloads/ecw/erdas-ecw-jp2-sdk-v5-4-linux
## Download GDAL v2.3 Source (ex. 2.3.1)
@oscarfonts
oscarfonts / gdal_ecw.sh
Created Feb 3, 2020 — forked from 1papaya/gdal_ecw.sh
Install GDAL 2.3 with ECW support on Ubuntu 18.04
View gdal_ecw.sh
#!/bin/bash
##
## Tested on: Ubuntu 18.04 & ECW 5.4 & GDAL 2.3.1
##
## Download the ERDAS ECW JP2 SDK v5.4 Linux
## https://download.hexagongeospatial.com/downloads/ecw/erdas-ecw-jp2-sdk-v5-4-linux
## Download GDAL v2.3 Source (ex. 2.3.1)
@oscarfonts
oscarfonts / 34M_17.bin
Created Aug 15, 2018 — forked from andrewharvey/34M_17.bin
Add 3D model to a Mapbox GL JS map
View 34M_17.bin
This file has been truncated, but you can view the full file.
@oscarfonts
oscarfonts / web.xml
Created Aug 7, 2018 — forked from essoen/web.xml
CORS * for GeoServer with Tomcat add following to `/var/lib/tomcat7/webapps/geoserver/WEB-INF/web.xml`
View web.xml
<filter>
<filter-name>CorsFilter</filter-name>
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
<init-param>
<param-name>cors.allowed.origins</param-name>
<param-value>*</param-value>
</init-param>
<init-param>
<param-name>cors.allowed.methods</param-name>
<param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
@oscarfonts
oscarfonts / postgresql_quantiles.md
Created May 31, 2018 — forked from hrwgc/postgresql_quantiles.md
Calculate quantile distributions for PostgreSQL column
View postgresql_quantiles.md
SELECT
ntile,
CAST(avg(length) AS INTEGER) AS avgAmount,
CAST(max(length) AS INTEGER)  AS maxAmount,
CAST(min(length) AS INTEGER)  AS minAmount 
FROM (SELECT length, ntile(6) OVER (ORDER BY length) AS ntile FROM countries) x
GROUP BY ntile
ORDER BY ntile;
View get_cadastre_building_floors.py
"""Calculate building floors from the Spanish Cadastre GIS files (SHP).
Once logged, data can be downloaded from https://www.sedecatastro.gob.es/
and the data specification is at
http://www.catastro.minhap.gob.es/ayuda/manual_descriptivo_shapefile.pdf
This python script is to be used in the QGIS 2.x field calculator.
The "CONSTRU" field stores volumetric data and other attributes in the form
of a structured text code. Floor numbers are in roman numerals.
As for example, "-II+IV+TZA" is a building part with two underground floors,