Skip to content

Instantly share code, notes, and snippets.

View FelipeSBarros's full-sized avatar

Felipe Sodré M. Barros FelipeSBarros

View GitHub Profile
#!/bin/bash
# forma de uso ./exportar <host> <porta> <nome_do_banco_de_dados> <usuario> <senha> <caminho> <formato>
# este script depende de: lib32z1 lib32ncurses5 lib32bz2-1.0 e filegdbapi
export SHAPE_ENCODING="ISO-8859-1"
SERVIDOR=$1
PORTA=$2
BANCO_DADOS=$3
USUARIO=$4
SENHA=$5
@FelipeSBarros
FelipeSBarros / eigenvariables.fct.R
Last active February 8, 2017 19:26
Small function to create PCA analysis and spatial eigenvariables
eigenvariables.fct <- function(vars, name, proportion = 0.95){
library("raster")
if (file.exists("./pca") == FALSE) dir.create("./pca")
#Running PCA:
# Counts not NA cels
non.na <- sum(!is.na(values(vars[[1]])))
# Sample the study area with n-non.na and creates an environmental table
sr <- sampleRandom(vars, non.na)
# faz o PCA dessa tabela padronizada
pca <- prcomp(scale(sr))
@FelipeSBarros
FelipeSBarros / tmux-cheatsheet.markdown
Created February 4, 2016 17:37 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
ID:LC08_L1TP_225079_20170109_20170311_01_T1
Acquisition Date:09-JAN-17
Path:225
Row:79
@FelipeSBarros
FelipeSBarros / rasterTableDB.csv
Created September 12, 2017 20:56
RasterDataTable
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 9.
"Path","nome","data_source","resolution","description","period"
"./worldclim/v2/30sec/presente/wc2.0_bio_30s_04.tif","bio4","worldclim v2","30s","Temperature Seasonality (standard deviation *100)","presente"
"./worldclim/v2/30sec/presente/wc2.0_bio_30s_01.tif","bio1","worldclim v2","30s","Annual Mean Temperature","presente"
"./worldclim/v2/30sec/presente/wc2.0_bio_30s_19.tif","bio19","worldclim v2","30s","Precipitation of Coldest Quarter","presente"
"./worldclim/v2/30sec/presente/wc2.0_bio_30s_02.tif","bio2","worldclim v2","30s","Mean Diurnal Range (Mean of monthly (max temp - min temp))","presente"
"./worldclim/v2/30sec/presente/wc2.0_bio_30s_16.tif","bio16","worldclim v2","30s","Precipitation of Wettest Quarter","presente"
"./worldclim/v2/30sec/presente/wc2.0_bio_30s_05.tif","bio5","worldclim v2","30s","Max Temperature of Warmest Month","presente"
"./worldclim/v2/30sec/presente/wc2.0_bio_30s_03.tif","bio3","worldclim v2","30s","Isothermality (BIO2/BIO7) (* 100)","presente"
"./worldclim/v2/30sec/presente/wc2
#Atenção:
# comandos meramente ilustrativos. Vários parâmetros dos comando usados (shp2pgsql) foram ignorados!
# ${a%.*} remove a extenção .shp do nome
for a in *.shp; do echo "Convertentado $a"; shp2pgsql $a schema.table > ${a%.*}.sql; done
# Depois, para cada .SQL:
for b in *.sql; do psql -d iis -f $b; done
@FelipeSBarros
FelipeSBarros / geoCoding.py
Created September 20, 2017 12:38
Small function for geocoding using GraphHopper API. From Adress, recieve json with lat/long point location
import requests
import urllib
def geocode(address, city, state, zip_code):
try:
location_param = ("%s+%s+%s+%s" % ("Pedernera", "Posadas", "Misiones", "2037"))
#url_request = "http://nominatim.openstreetmap.org/search?q=" + location_param + "&format=json&polygon_geojson=1"
#url_request = "maps.googleapis.com/maps/api/geocode/json?address=%s&sensor=false" % location_param
url_request = "http://graphhopper.com/api/1/geocode?q=" + location_param + "&key=PUT_YOUR_KEY_HERE"
result = requests.get(url_request)
/*
This is an example Overpass query.
Try it out by pressing the Run button above!
You can find more examples with the Load tool.
*/
[out:json][timeout:25];
//Buscando area "Posadas"
area(3602294383)->.searchArea;
//Results
(
library(ggplot2)
library(ggmap)
library(maps)
library(mapdata)
library(dismo)
#Usando dados do pacote "mapdata"
usa <- map_data("usa") # Definindo qual dado queremos trabalhar
ggplot() +
geom_polygon(data = usa, aes(x=long, y = lat, group = group)) + # Aqui estamos usando o data frame "usa" para plotar-lo como poligono
coord_fixed(1.3)
@FelipeSBarros
FelipeSBarros / Py_install.sh
Last active February 10, 2018 17:53
Few libs for completely install python
sudo apt-get update &&
sudo apt-get upgrade &&
sudo apt-get autoremove &&
sudo apt-get autoclean &&
sudo apt-get clean &&
sudo apt-get install sqlite3 &&
sudo apt-get install -y python3-pip &&
sudo apt-get install build-essential libssl-dev libffi-dev python-dev &&
sudo apt-get install -y python3-venv python3-bs4 python3-pandas*