Skip to content

Instantly share code, notes, and snippets.

View gledsoncruz's full-sized avatar

Gledson Cruz gledsoncruz

View GitHub Profile
SELECT sum(st_area(e.the_geom)) as total_ed FROM edificacao e, loteamentos l
WHERE st_intersects(e.the_geom, l.the_geom) AND l.nome = 'LOTEAMENTO JARDIM IMPERIAL'
SELECT sum(st_area(e.the_geom)) AS total_ed FROM edificacao e, loteamentos l
WHERE st_disjoint(e.the_geom, l.the_geom) AND l.nome = 'LOTEAMENTO JARDIM IMPERIAL'
--Quais logradouros que se cruzam com os limites do “LOTEAMENTO VOLTA GRANDE - 3 ETAPA” ?
select log.nome from trecho_logradouroS log, loteamentos lot
where st_crosses(log.the_geom, lot.the_geom) and lot.nome = 'LOTEAMENTO VOLTA GRANDE - 3 ETAPA'
--Quais os loteamentos que interceptam os limites do bairro SANTO AGOSTINHO?
SELECT lot.nome FROM loteamentos lot, bairros b
WHERE st_overlaps(lot.the_geom, b.the_geom) AND b.nome = 'SANTO AGOSTINHO'
--Qual ou quais ruas tocam no limite do bairro SANTO AGOSTINHO?
SELECT lot.nome FROM trecho_logradouros lot, bairros b
WHERE st_touches(lot.the_geom, b.the_geom) AND b.nome = 'SANTO AGOSTINHO'
--Quais os loteamentos que estão dentro do bairro SANTO AGOSTINHO ?
SELECT lot.nome FROM loteamentos lot, bairros b
WHERE st_within(lot.the_geom, b.the_geom) AND b.nome = 'SANTO AGOSTINHO'
-- Qual a distância entre a C.M. Madre Teresa de Calcutá e o bairro Aero Clube ?
SELECT st_distance(e.the_geom, b.the_geom) FROM educacao e, bairros b
WHERE e.nome = 'C.M. Madre Teresa de Calcuta' AND b.nome = 'AERO CLUBE'
--Relacione todos os lotes que estão à 300 metros da Escola Municipal Espírito Santo.
SELECT l.insc_base FROM lotes l, educacao e
WHERE st_dwithin(e.the_geom, l.the_geom, 300) AND e.nome = 'E.M. Espirito Santo'
--Obter coordenada X e Y das unidades educacionais
SELECT e.nome, st_X(e.the_geom), st_Y(e.the_geom) FROM educacao e
@gledsoncruz
gledsoncruz / getIntersects.py
Last active January 9, 2018 10:06
QGIS function
"""
Define new functions using @qgsfunction. feature and parent must always be the
last args. Use args=-1 to pass a list of values as arguments
"""
from qgis.core import *
from qgis.gui import *
@qgsfunction(args='auto', group='GCFunctions')
def GetIntersectGeoms(layer_name, field_name, feature, parent):