Skip to content

Instantly share code, notes, and snippets.

@Adizlois
Adizlois / Analyze_data_first_draft.ipynb
Last active November 2, 2018 14:01
Rovbase predator database analysis using pandas. First draft. In case there are backend issues and the file is not properly displayed, use nbviewer: http://nbviewer.jupyter.org/urls/gist.githubusercontent.com/Adizlois/d04c8c02d3d96d533770ecc6466b7c61/raw/89e882845cc76b842dace095dd40c4d325149f78/Analyze_data_first_draft.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Adizlois
Adizlois / Lowpassfilter.ipynb
Created July 28, 2017 15:28
Lowpass filter
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Adizlois
Adizlois / Despro_v2.py
Last active August 1, 2017 16:47
Despro (descarga de proyectos - project downloader) makes it possible to store a local backup of a project from the Epicollect 5 server csv file and pictures). See https://github.com/Adizlois/Despro.git for further information
import requests
from bs4 import BeautifulSoup
import wx
import datetime
import sys
import os
import zipfile,StringIO
import json
import csv
"""
@Adizlois
Adizlois / GoogleLogin_Mechanize.py
Last active August 26, 2022 16:49
Google login using mechanize in python....
import mechanize
import cookielib
#Dealing with Unicode encoding....
import sys
reload(sys)
sys.setdefaultencoding('utf8')
#Emulate browser....
br = mechanize.Browser()
@Adizlois
Adizlois / GoogleID_Request.py
Last active May 6, 2017 17:29
Using Google authentification in order to grab a file that requires so.....
import requests
from bs4 import BeautifulSoup
#THIS SEEMS TO WORK OK....REQUESTS.SESSION() SHOULD DEAL WITH THE COOKIES AND KEEP THE USER LOGGED BUT IT DOESN`T...
class SessionGoogle:
def __init__(self, url_login, url_auth, login, pwd):
self.ses = requests.session()
login_html = self.ses.get(url_login)
soup_login = BeautifulSoup(login_html.content).find('form').find_all('input')
my_dict = {}
@Adizlois
Adizlois / XML.py
Last active May 5, 2017 09:08
XML extraction example (including pictures downloading) for an epicollect project
#!/usr/bin/env python
import urllib2
import urllib
import xml.etree.ElementTree
#UPDATE
address="http://epicollectserver.appspot.com/getMapXML?projectKey=ahZzfmVwaWNvbGxlY3RzZXJ2ZXItaHJkchQLEgdQcm9qZWN0GICAgO7L-YsKDA"
Remote_XML = urllib2.urlopen(address)
Local="Local_XML.xml"
@Adizlois
Adizlois / clouds.py
Created March 16, 2016 11:10
Taking 4 variables as an input (shapefile of our region of interest, basename of the ROI for Landsat image (e.g.LC8009061), year, first doy (day of year) and number of images to analyze) this program creates a result layer in which the frequency of cloud appearance for each pixel is shown. It downloads the Landsat Quality band files (if not pres…
import os
import subprocess
import urllib2
import sys
import numpy as np
from osgeo import gdal
GDAL_OPTS = ["COMPRESS=LZW","INTERLEAVE=PIXEL", "TILED=YES",\
"SPARSE_OK=TRUE", "BIGTIFF=YES" ]
"""Taking 4 variables as an input (shapefile of our region of interest, basename of the ROI for Landsat image (e.g.LC8009061), year, first doy (day of year)
@Adizlois
Adizlois / Dec_to_Binary.py
Last active February 25, 2016 13:05
A home-made decimal-binary converter...
"""by Alfonso Diz-Lois"""
def Binary_from_decimal(number,bitcount=None):
Binary=[]
while number>1:
if number%2==0:
Binary.insert(0,0)
if number%2==1:
Binary.insert(0,1)
number=number/2
@Adizlois
Adizlois / distances.py
Last active December 7, 2015 10:42
Bhattacharyya distance, Euclidean distance, and Spectral angle calculator for multivariate samples
""" - Bhattacharyya distance, Euclidean distance, and Spectral angle calculator for multivariate samples -
It assumes that there are the same amount of non-valid values in every band.
Input files are multiband raster layers
Alfonso Diz-Lois <dizlois@gmail.com>"""