Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)
-
Upload
jorge-arevalo -
Category
Documents
-
view
156 -
download
0
description
Transcript of Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)
![Page 1: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/1.jpg)
GEOPROCESAMIENTO CON GDAL
Y POSTGIS RASTER
Jorge Arévalohttp://about.me/jorgeas80
GDAL committerPostGIS committer
¿Quién soy?
martes 25 de junio de 2013
![Page 2: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/2.jpg)
¿Qué es GDAL?
• Librería Open Source + utilidades de línea de comandos
• Manipulación de datos tanto en formato raster como vectorial
• Abstracción cara a aplicaciones, para poder trabajar con cualquier formato soportado de manera transparente
• Multiplataforma: Linux - Windows - Mac
• Creada por Frank Warmerdam
martes 25 de junio de 2013
![Page 3: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/3.jpg)
¿Para qué se usa?
• Principalmente, para convertir entre formatos
• También para reproyectar capas raster/vector
• ... pero tiene MUCHOS más usos
martes 25 de junio de 2013
![Page 4: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/4.jpg)
GDAL ES
SEXY
¡PAMELA GDALNDERSON!
por @carlosazaustre
martes 25 de junio de 2013
![Page 5: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/5.jpg)
GDAL ES
SEXY II
¡DAVID GDALSSELHOF!
por @carlosazaustre
martes 25 de junio de 2013
![Page 6: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/6.jpg)
QUIZ #1
¿En qué año comenzó el desarrollo de GDAL?
martes 25 de junio de 2013
![Page 7: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/7.jpg)
gdalinfo: datos capa rasterECW: FileInfo: SizeXY=110680,74840 Bands=3 OriginXY=511960,4.68695e+06 CellIncrementXY=0.25,-0.25 ColorSpace=4, eCellType=0
ECW: projection=NUTM29, datum=ETRS89, units=METERSGDAL: GDALOpen(PNOA_MR_OF_ETRS89_HU29_h50_0223.ecw, this=0x8da42a8) succeeds as ECW.Driver: ECW/ERDAS Compressed Wavelets (SDK 3.x)Files: PNOA_MR_OF_ETRS89_HU29_h50_0223.ecwSize is 110680, 74840Coordinate System is `'Origin = (511960.000000000000000,4686950.000000000000000)Pixel Size = (0.250000000000000,-0.250000000000000)Metadata: COLORSPACE=RGB COMPRESSION_RATE_TARGET=10 VERSION=2Corner Coordinates:Upper Left ( 511960.000, 4686950.000) Lower Left ( 511960.000, 4668240.000) Upper Right ( 539630.000, 4686950.000) Lower Right ( 539630.000, 4668240.000) Center ( 525795.000, 4677595.000) Band 1 Block=256x256 Type=Byte, ColorInterp=Red Description = Red Overviews: 55340x37420, 27670x18710, 13835x9355, 6917x4677, 3458x2338, 1729x1169, 864x584, 432x292, 216x146Band 2 Block=256x256 Type=Byte, ColorInterp=Green Description = Green Overviews: 55340x37420, 27670x18710, 13835x9355, 6917x4677, 3458x2338, 1729x1169, 864x584, 432x292, 216x146Band 3 Block=256x256 Type=Byte, ColorInterp=Blue Description = Blue Overviews: 55340x37420, 27670x18710, 13835x9355, 6917x4677, 3458x2338, 1729x1169, 864x584, 432x292, 216x146
Tip:export CPL_DEBUG=ecw
martes 25 de junio de 2013
![Page 8: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/8.jpg)
gdal_translate: clipgdal_translate -a_srs epsg:25829 -projwin 522222.0661435421 4675944.730194233 522941.44762708514 4675225.314583662PNOA_MR_OF_ETRS89_HU29_h50_0223.ecw monte_do_castro.tif
martes 25 de junio de 2013
![Page 9: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/9.jpg)
gdal_translate: clip
martes 25 de junio de 2013
![Page 10: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/10.jpg)
gdal_translate: reducir resolución
Resolución al 10% de la original
gdal_translate -outsize 10% 10%-a_srs epsg:25829 PNOA_MR_OF_ETRS89_HU29_h50_0223.ecw PNOA_MR_OF_ETRS89_HU29_h50_0223_red.tif
martes 25 de junio de 2013
![Page 11: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/11.jpg)
gdalwarp: remuestreargdalwarp -ts 22136, 14968-r cubicsplinePNOA_MR_OF_ETRS89_HU29_h50_0223_red.tifPNOA_MR_OF_ETRS89_HU29_h50_0223_2x.tif
Espec ificamos e l t amaño deseado y el algoritmo de remuestreo a utilizar
martes 25 de junio de 2013
![Page 12: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/12.jpg)
gdal_edit.py: editar metadatos
gdal_edit.py -a_nodata -32768 -a_srs epsg:25829 PNOA_MR_OF_ETRS89_HU29_h50_0223.tif
martes 25 de junio de 2013
![Page 13: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/13.jpg)
Optimizandogdal_translate -co TILED=YES -co COMPRESS=DEFLATE -co INTERLEAVE=PIXELPNOA_MR_OF_ETRS89_HU29_h50_0223.tif PNOA_MR_OF_ETRS89_HU29_h50_0223_tiled.tif
gdaladdo PNOA_MR_OF_ETRS89_HU29_h50_0223_tiled.tif 2 4 8 16 32 64
martes 25 de junio de 2013
![Page 14: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/14.jpg)
QUIZ #2
¿Cuántos drivers maneja GDAL/OGR?
martes 25 de junio de 2013
![Page 15: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/15.jpg)
Mapa de elevacióngdal_contour -a elev -i 25 MDT25-0223-H29.asc dem_vigo.shp
martes 25 de junio de 2013
![Page 16: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/16.jpg)
Mapa de relievegdaldem hillshade MDT25-0223-H29.asc hillshade_vigo.tif
martes 25 de junio de 2013
![Page 17: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/17.jpg)
¿Qué tal las dos cosas? gdal_rasterize
gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 0 -burn 0 -where 'elev > 500' -l dem_vigo dem_vigo.shp dem_vigo_rasterized.tif
gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 100 -burn 0 -where 'elev > 350 and elev <= 500' -l dem_vigo dem_vigo.shp dem_vigo_rasterized.tif
gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 180 -burn 130 -where 'elev > 200 and elev <= 350' -l dem_vigo dem_vigo.shp dem_vigo_rasterized.tif
gdal_rasterize -b 1 -b 2 -b 3 -burn 190 -burn 180 -burn 80 -where 'elev > 100 and elev <= 200' -l dem_vigo dem_vigo.shp dem_vigo_rasterized.tif
gdal_rasterize -b 1 -b 2 -b 3 -burn 0 -burn 255 -burn 0 -where 'elev <= 100' -l dem_vigo dem_vigo.shp dem_vigo_rasterized.tif
martes 25 de junio de 2013
![Page 18: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/18.jpg)
¿Qué tal las dos cosas? gdal_rasterize
Monte de O Castro
martes 25 de junio de 2013
![Page 19: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/19.jpg)
¿Y PostGIS Raster?¡Nueva versión! Buen rendimiento en visualización (QGIS, Mapserver)
Desde 2013-06-19
https://github.com/jorgeas80/gdal_postgis_raster_driver.git
martes 25 de junio de 2013
![Page 20: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/20.jpg)
GDAL + PostGIS RasterCargamos en PostGIS el SHP generado a partir del DEM
Cargamos en PostGIS Raster el TIFF generado a partir del DEM
shp2pgsql -s epsg:25829 -I dem_vigo.shp > dem_vigo.sqlpsql -d geocamp -f dem_vigo.sql
raster2pgsql -s epsg:25829 -I -M -C -t 50x50 hillshade_vigo.tiff > hillshade_vigo.sqlpsql -d geocamp -f dem_vigo.sql
martes 25 de junio de 2013
![Page 21: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/21.jpg)
GDAL + PostGIS RasterObtenemos la intersección de ambas capas únicamente en los puntos en los que la altitud es mayor a 600 m
create table hillshade_up_from_600 asselect st_clip(rast, geom) as rastfrom hillshade_vigo, dem_vigo where st_intersects(rast, geom) and elev > 600
alter table hillshade_up_from_600 add column rid bigserial primary key;
select addrasterconstraints('hillshade_up_from_600', 'rast')
gdal_translate PG:"dbname=geocamp table=hillshade_up_from_600 mode=2" hillshade_up_from_600.tif
martes 25 de junio de 2013
![Page 22: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/22.jpg)
GDAL + PostGIS Raster
martes 25 de junio de 2013
![Page 23: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/23.jpg)
Quiz #3
¿En qué orden muestra GDAL los drivers disponibles?
martes 25 de junio de 2013
![Page 24: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/24.jpg)
Quiz #3a) Orden alfabético
b) Como les da la gana a los desarrolladores
c) Primero los compilados de manera interna y luego los enlazados externamente
martes 25 de junio de 2013
![Page 25: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/25.jpg)
OGR: Geocoding
http://erouault.blogspot.fr/2012/12/a-geocoding-client-api-in-gdalogr.html
/* Create a session with default options */OGRGeocodingSessionH hSession = OGRGeocodeCreateSession(NULL);
/* Now query the service */ OGRLayerH hLayer = OGRGeocode(hSession, "Paris", NULL, NULL);
/* Use the result layer (the first feature is generally the most relevant) */
/* Cleanup */OGRGeocodeFreeResult(hLayer);OGRGeocodeDestroySession(hSession);
SELECT ST_Centroid(ogr_geocode('Paris'))
returns:
OGRFeature(SELECT):0POINT (2.342878767069653 48.85661793020374)
En C En SQL
Más info
martes 25 de junio de 2013
![Page 26: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/26.jpg)
Más funcionalidades sexy de OGRhttp://trac.osgeo.org/gdal/wiki/rfc39_ogr_layer_algebra
http://gdal.org/ogr/ogr_sql_sqlite.html
OGR álgebra
SQL sobre capas no SQL(soporta dialecto SQLite)
martes 25 de junio de 2013
![Page 27: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/27.jpg)
Enlaces útiles
• http://www.gdal.org/
• http://trac.osgeo.org/gdal/
• http://home.gdal.org/~warmerda/
• http://erouault.blogspot.fr/
• http://trac.osgeo.org/postgis/wiki/WKTRaster
• http://trac.osgeo.org/gdal/wiki/frmts_wtkraster.html
martes 25 de junio de 2013
![Page 28: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/28.jpg)
Créditos
• Roger Andre (http://download.osgeo.org/gdal/presentations/OpenSource_Weds_Andre_CUGOS.pdf)
• Even Rouault (http://even.rouault.free.fr/)
martes 25 de junio de 2013
![Page 29: Geocamp ES 2013: Geoprocesamiento con GDAL (y PostGIS Raster)](https://reader033.fdocuments.net/reader033/viewer/2022052701/55cf9d61550346d033ad6230/html5/thumbnails/29.jpg)
MUCHAS GRACIAS
Jorge Aré[email protected]@libregis.org
Junio 2013
¡Escríbeme!
martes 25 de junio de 2013