Professional Documents
Culture Documents
3364741 ajp
oswaldo Arenas
ungeop@gmail.com
carlop1978@hotmail.com Lopez Misael ()
$$$$$$$$$$$$$$$$$ sql queryes
--Proyecto Putumayo
--Area total coca 2004
%%%%%%%%%% dia 4
-- ahora vamos a cortar los pedazos que esten por fuera de antioquia y solo cont
amos las distancias de adentro
select a.admin_name,b.layer,sum(length(transform(intersection(a.the_geom,b.the_
geom),32618)))
from departamentos as a, vias as b
where
a.admin_name='Antioquia'
and
a.the_geom && b.the_geom
group by a.admin_name, b.layer
;
-- selecccionamos todas las vias por dto
select a.admin_name,b.layer,sum(length(transform(intersection(a.the_geom,b.the_
geom),32618)))
from departamentos as a, vias as b
where
a.the_geom && b.the_geom
group by a.admin_name, b.layer
;
----------------------
Select AsKML(transform(buffer(transform(GeomFromText('POINT(-73.41941619116963
5.56709984295124)', 4326),32618),20000),4326)) as kmlpoly,
descriptor, sum(length(transform(intersection(the_geom,transform(buffer(transfor
m(GeomFromText('POINT(-73.41941619116963 5.56709984295124)', 4326),32618),20000)
,4326)),32618))) as length
from vias where the_geom && transform(buffer(transform(GeomFromText('POINT(-73.4
1941619116963 5.56709984295124)', 4326),32618),20000),4326)
GROUP by kmlpoly,descriptor;
--
select d.nom_dpto, sum(e.area) from departamentos as d, municipios as m, estad
istica_gral as e
where
d.codane=m.codane_depto and m.codane=e.codane and e.operacion='ASPERSION' AND e.
ano='2007'
and e.area != 0
group by d.nom_dpto
-+++++++++++++++++++++++=============
select d.nom_dpto, sum(e.area) from departamentos as d, municipios as m, estad
istica_gral as e
where
d.codane=m.codane_depto and m.codane=e.codane and e.operacion='ASPERSION' AND e.
ano='2007'
group by d.nom_dpto
having sum(e.area) > 0
order by d.nom_dpto
##############################
CREATE INDEX codane_idx_est_gral
ON estadistica_gral
USING btree
(codane);
%%%%%%%%%%%%%%%%%%%%%%%
select sum(area) from estadistica_gral
where
ano='2002' and operacion = 'ASPERSION'
300 212 01 55
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Distancia vertimiento-centroide del municipio
En este ejemplo creamos una linea imaginaria entre el centroide del municipio y
cada vertimiento , para determinar aquellos que por definición hayan sido mal ingr
esados al sistema.
SELECT v.id_vertimiento, v.identif_vertimie, makeline(centroid(m.the_geom), v.th
e_geom) AS the_geom, length(makeline(centroid(m.the_geom), v.the_geom)) AS long
FROM dp_municipio m
LEFT JOIN ve_vertimiento v ON m.cod_municipio::text = v.cod_municipio::text
WHERE v.id_vertimiento IS NOT NULL;
Formas de espacialzar tablas:
cargar shep: shaepsql ogr2org se agregan a la tabla geometry_columns
funcion postGIS: SELECT AddGeometryColumn (...)
-> las dos formas crean el resgistro en la tabal geometry_colums
sist. de referecia espacial 21892 Cod
Solo cuando se crean vistas
/* correccion en la vista
SELECT v.oid AS gid, v.id_vertimiento, v.identif_vertimie, makeline(centroid(m.t
he_geom), v.the_geom) AS the_geom, length(makeline(centroid(m.the_geom), v.the_g
eom)) AS long
FROM dp_municipio m
LEFT JOIN ve_vertimiento v ON m.cod_municipio::text = v.cod_municipio::text
WHERE v.id_vertimiento IS NOT NULL;
cuando se creen las tablas, no usar espacion ni mayusculasn */
##################################################
consulta por municipios
select m.nom_mcipio, e.area from departamentos as d, municipios as m, estadistic
a_gral as e
where
d.codane=m.codane_depto and m.codane=e.codane and e.operacion='ASPERSION' AND e.
ano='2007' and d.nom_dpto='ANTIOQUIA'
and e.area > 0
order by m.nom_mcipio
^^^^^^^^^^^^^^^^^^^^
select m.nom_mcipio, e.area from departamentos as d, municipios as m, estadistic
a_gral as e
where
d.codane=m.codane_depto and m.codane=e.codane and e.operacion='EMANUAL' AND e.an
o='2007' and d.nom_dpto='ANTIOQUIA'
and e.area > 0
order by m.nom_mcipio
######$%^&*()_
dir > myfile.txt --- copiar los archivos a un directorios
c:\falcon view datos\CTLM50\CT50Z0A>dir > c:\borra\a.txt
gdal_translate -of GTiff -co "TILED=YES" C:\borra\C C:\borra\CT50Z0A_tif\0QXG
1013.tif