Skip to content

Instantly share code, notes, and snippets.

View marcellobenigno's full-sized avatar
😃
Python ❤

Marcello Benigno marcellobenigno

😃
Python ❤
  • João Pessoa / Paraíba / Brazil
View GitHub Profile
@marcellobenigno
marcellobenigno / my_classes.cpt
Last active August 29, 2015 13:56
Cores para as classes de declividade do script mosaic.sh
# created by: Marcello Benigno
0 102 153 153
1 236 241 230
10 176 242 205
50 180 246 179
100 207 250 177
150 242 252 179
200 220 238 145
250 147 208 93
300 69 179 53
@marcellobenigno
marcellobenigno / mosaic.sh
Last active August 29, 2015 13:56
Creating beautiful relief shaded DEMs using GDAL and Imagemagic
#!/bin/bash
# Author: Marcello Benigno, Mar/2014; copyright: GPL >= 2
# Purpose: Create a beautiful SRTM Hillshade color Map
# Usage: ./mosaic.sh
## Required programs:
## imagemagick
## gdal >=1.7.0
## my_classes.cpt - download at
## <https://gist.github.com/marcellobenigno/9289976>
@marcellobenigno
marcellobenigno / gist:9983805
Last active August 29, 2015 13:58
Dicas GDAL
# Adicionar uma projeção a um shapefile:
ogr2ogr -a_srs "EPSG:4291" output.shp input.shp
# Converter projeções:
ogr2ogr -t_srs "EPSG:4326" -s_srs "EPSG:4291" output.shp input.shp
# Ver os metadados sobre projeção:
ogrinfo -so input.shp input
@marcellobenigno
marcellobenigno / create_obras_table.php
Last active August 29, 2015 14:01
Migration Create Obras
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateobrasTable extends Migration {
/**
* Run the migrations.
*
@marcellobenigno
marcellobenigno / Obras.php
Last active August 29, 2015 14:01
Model Obras.php
<?php
class Obra extends Eloquent {
protected $fillable = array('nome_obra', 'geom');
public static $rules = array(
'nome_obra'=>'required|min:3',
/* OBS: os campos abaixo servem para validação da coluna geom
e não existem na tabela Obra */
@marcellobenigno
marcellobenigno / ObrasController.php
Last active August 29, 2015 14:01
Controller ObrasController.php
<?php
class ObrasController extends BaseController {
public function getIndex() {
$obras = DB::table('obras')
->select(DB::raw('ST_X(geom) as lng, ST_Y(geom) AS lat, nome_obra'))
->get();
@marcellobenigno
marcellobenigno / Municipio.php
Created May 10, 2014 14:03
Model Municipio.php
<?php
class Municipio extends Eloquent {
public static function checkCoords($x, $y) {
$query = Municipio::whereRaw(
"ST_Contains(geom, ST_GeomFromText('POINT($x $y)', 4326))"
)->first();
@marcellobenigno
marcellobenigno / gist:335a9635bb0a4cf94d77
Last active August 29, 2015 14:02
Perfil Longitudinal de um rio utilizando o GRASS e o R
# 1) Criação de um camada de pontos, contendo os vértices do rio principal
v.to.points -i -v -t in=out_dem_filled_mainchannel out=mchannel_pts type=line dmax=1000
# 2) Exportação dos vértices para um arquivo txt
v.out.ascii mchannel_pts > coords.txt
# 3) Remoção dos pipes ("|") e da coluna cat do arquivo txt
cat coords.txt | awk -F "|" '{print $1,''$2}' > xy.txt
# 4) Substituição dos espaços por vírgulas
@marcellobenigno
marcellobenigno / gist:2a5a9138b298e540f55c
Last active August 29, 2015 14:05
Run Time Substitution no Mapserver - Mapfile 1
MAP
NAME 'ceara'
EXTENT 168894 9143291 801185 9695478
SIZE 650 600
UNITS meters
SHAPEPATH 'shp'
PROJECTION
'init=epsg:29185'
END
@marcellobenigno
marcellobenigno / gist:9e06576dd7a37e8fefa3
Created August 8, 2014 11:20
Run Time Substitution no Mapserver - Mapfile 2
LAYER
NAME 'municipios_selecao'
STATUS DEFAULT
TYPE POLYGON
DATA 'municipios.shp'
FILTER ([idmun]=%idmun%)
VALIDATION
'idmun' '^[0-9]{1,3}$'
END
CLASS