Skip to content

Instantly share code, notes, and snippets.

curl -s "http://webservices.rm.ingv.it/fdsnws/event/1/query?lat=43.587007&lon=11.316179&maxradiuskm=30&starttime=2014-12-19T00:00:00&endtime=2014-12-20T23:59:59&minmag=2&maxmag=5" | xml2json | jq "[.\"q$quakeml\".eventParameters.event[] | {latitude:.origin.latitude.value[],longitude:.origin.longitude.value[],magnitude:.magnitude.mag.value[]}]" | in2csv -f json | csvjson --lat latitude --lon longitude | jq . > output.json
@giohappy
giohappy / lengthalongline.py
Last active September 29, 2015 14:54
Lenght along linestring to point
# -*- coding: utf-8 -*-
#
# Copyright © 2012 Giovanni Allegri (Gis3W s.a.s.)
# Licensed under the terms of the LGPLv2 License
from qgis.core import *
import math
def pointInterpolate(geom,point):
geomType = geom.wkbType ()
@giohappy
giohappy / webviewgl.qml
Created February 11, 2015 14:57
WebView with WebGL
import QtQuick 2.0
import QtWebKit 3.0
Rectangle {
width: 800
height: 600
WebView {
url: "http://stemkoski.github.io/Three.js/Model-Animation.html";
anchors.fill: parent
}
@giohappy
giohappy / export_wkt.py
Created October 29, 2015 17:18
QGIS script for Processing to export WKT geometry representation
##Geometry=group
##Export WKT to file=name
##Input_Layer=vector
##Output_File=output file
from qgis.core import *
from PyQt4.QtCore import *
import processing
v_in = processing.getObject(Input_Layer)
@giohappy
giohappy / webservice_output.txt
Created November 15, 2016 08:57
ISIDE output
#EventID|Time|Latitude|Longitude|Depth/Km|Author|Catalog|Contributor|ContributorID|MagType|Magnitude|MagAuthor|EventLocationName|web_id_locator(deprecated)
4730151|2014-12-20T22:37:25.350000|43.6097|11.2563|6.7|SURVEY-INGV||||ML|2.6|SURVEY-INGV|Firenze|4004730151
4730041|2014-12-20T22:35:09.980000|43.5848|11.2553|10.2|SURVEY-INGV||||ML|2.0|SURVEY-INGV|Firenze|4004730041
4729881|2014-12-20T22:25:33.310000|43.6218|11.2432|7.4|SURVEY-INGV||||ML|2.2|SURVEY-INGV|Firenze|4004729881
4729581|2014-12-20T21:39:40.560000|43.6218|11.2445|5.7|SURVEY-INGV||||ML|2.3|SURVEY-INGV|Firenze|4004729581
@giohappy
giohappy / mapblender.py
Created June 16, 2017 16:44
mapblender.py
#!/usr/bin/env python
import os
import sys
from optparse import OptionParser
from collections import OrderedDict
from osgeo import gdal
import numpy as np
from PIL import Image
from matplotlib.colors import LinearSegmentedColormap
@giohappy
giohappy / mvt.py
Created October 20, 2017 16:11
MVT Django view snippet
import os
import shutil
import logging
import psycopg2
from django.conf import settings
from django.shortcuts import render, render_to_response
from django.http import HttpResponse
import mercantile as mc
@giohappy
giohappy / flask_mvt.py
Last active July 23, 2024 14:42
OL + Flask + PostGIS for MVT rendering
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import shutil
import math
import psycopg2
from flask import Flask, render_template, make_response
app = Flask(__name__)
@giohappy
giohappy / mvt.html
Last active October 23, 2017 10:08
Flask + OL MVT vector layer
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>MVT</title>
<link rel="stylesheet" href="{{ url_for('static', filename='css/ol.css') }}">
</head>
<body>
<div id="map"class="map"></div>
<script src="{{ url_for('static', filename='js/ol-debug.js') }}"></script>
# data test for PostGIS BRIN Indexes
# a small dataset ( ~400K rows for roads)
wget http://download.geofabrik.de/europe/france/bretagne-latest.shp.zip
unzip bretagne-latest.shp.zip
shp2pgsql -s 4326:2154 -I landuse.shp landuse | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I natural.shp natural | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I places.shp places | psql -h localhost -p 32770 -U pggis -d pggis
shp2pgsql -s 4326:2154 -I points.shp points | psql -h localhost -p 32770 -U pggis -d pggis