This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: utf-8 | |
| import tornado.httpserver | |
| import tornado.iostream | |
| import tornado.ioloop | |
| import tornado.web | |
| import tornado.process | |
| import tornado.concurrent | |
| import concurrent.futures | |
| import subprocess |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.3/leaflet.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/openlayers/2.13.1/OpenLayers.js"></script> | |
| <script> | |
| var map = null; | |
| var macroarea = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.dispatch import receiver | |
| from django.db import models | |
| from django.contrib.auth.models import User | |
| @receiver(models.signals.post_migrate) | |
| def create_superuser(sender, **kwargs): | |
| if not User.objects.filter(username='admin').first(): | |
| User.objects.create_superuser('admin', 'admin@localhost', 'admin') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import dballe | |
| from itertools import groupby | |
| import sys | |
| def do_report(db, station, date, records): | |
| """Create a report from a list of records of the same station,date.""" | |
| keyfoo = lambda r: ( | |
| r.get("timerange"), r.get("level") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import requests # http://docs.python-requests.org/en/latest/ | |
| import json | |
| def upsert_records(records, ckan_url, resource_id, ckan_api_key=None): | |
| """Send a list of records to CKAN Datastore and return a requests.Response | |
| object (see http://docs.python-requests.org/en/latest/api/#requests.Response). | |
| Example: | |
| url = "http://mysite.org/ckan" | |
| resource_id = "7d33cafe-0118-4b9a-8d8d-e82d1935e2ea" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import date, timedelta | |
| import calendar | |
| def daterange(start, end, step=timedelta(days=1)): | |
| d = start | |
| while d <= end: | |
| yield d | |
| d += step |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| trap cleanup EXIT | |
| cleanup() | |
| { | |
| [[ -n "$tmpdir" ]] && rm -rf $tmpdir | |
| } | |
| show_help() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.http import HttpResponse | |
| from django.db.models import BinaryField, Func, F, Value, CharField | |
| from .models import MyModel | |
| def view_png(request): | |
| """Return a PostGIS raster as a PNG image.""" | |
| # MyModel is a django model with a RasterField named "rast". | |
| # Note: ST_AsGdalRaster can reproject the data, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # encoding: utf-8 | |
| # | |
| # Crea un GeoJSON dei comuni a partire dal raster di precipitazione in cui | |
| # aggiunge i seguenti attributi alle feature: | |
| # - preci_count: numero di celle nel comune | |
| # - preci_sum: somma della precipitazione nel comune | |
| # - preci_max: massima precipitazione nel comune | |
| # - preci_threshold_50mm_count: numero di celle nel comune che superano i 50mm | |
| # - preci_threshold_50mm_alert: "green" se nessuna cella supera i 50mm, | |
| # "yellow" se la superano meno di dieci, "red" se la superano 10 o più |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| print_help() | |
| { | |
| echo "Usage: $0 ENVI_FILE OUTPUTDIR" | |
| echo "" | |
| echo "Convert a 52 band ENVI file in 52 GeoTiff files with colortable" | |
| } | |
| if [[ "$1" == "-h" || "$1" == "--help" ]] |
OlderNewer