Вы находитесь на странице: 1из 29

GEOPROCESAMIENTO CON GDAL

Y POSTGIS RASTER
Jorge Arvalo http://about.me/jorgeas80 GDAL committer PostGIS committer

Quin soy?

martes 25 de junio de 2013

Qu es GDAL?

Librera Open Source + utilidades de lnea de comandos Manipulacin de datos tanto en formato raster como vectorial Abstraccin 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

Para qu se usa?

Principalmente, para convertir entre formatos Tambin para reproyectar capas raster/vector ... pero tiene MUCHOS ms usos

martes 25 de junio de 2013

GDAL ES SEXY
PAMELA GDALNDERSON!
por @carlosazaustre

martes 25 de junio de 2013

GDAL ES SEXY II
DAVID GDALSSELHOF!
por @carlosazaustre

martes 25 de junio de 2013

QUIZ #1
En qu ao comenz el desarrollo de GDAL?

martes 25 de junio de 2013

gdalinfo: datos capa raster


ECW: 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=METERS GDAL: 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.ecw Size is 110680, 74840 Coordinate System is `' Origin = (511960.000000000000000,4686950.000000000000000) Pixel Size = (0.250000000000000,-0.250000000000000) Metadata: COLORSPACE=RGB COMPRESSION_RATE_TARGET=10 VERSION=2 Corner 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, 216x146 Band 2 Block=256x256 Type=Byte, ColorInterp=Green Description = Green Overviews: 55340x37420, 27670x18710, 13835x9355, 6917x4677, 3458x2338, 1729x1169, 864x584, 432x292, 216x146 Band 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

gdal_translate: clip
gdal_translate -a_srs epsg:25829 -projwin 522222.0661435421 4675944.730194233 522941.44762708514 4675225.314583662 PNOA_MR_OF_ETRS89_HU29_h50_0223.ecw monte_do_castro.tif

martes 25 de junio de 2013

gdal_translate: clip

martes 25 de junio de 2013

gdal_translate: reducir resolucin


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

Resolucin al 10% de la original

martes 25 de junio de 2013

gdalwarp: remuestrear
gdalwarp -ts 22136, 14968 -r cubicspline PNOA_MR_OF_ETRS89_HU29_h50_0223_red.tif PNOA_MR_OF_ETRS89_HU29_h50_0223_2x.tif

Especicamos el tamao deseado y el algoritmo de remuestreo a utilizar

martes 25 de junio de 2013

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

Optimizando
gdal_translate -co TILED=YES -co COMPRESS=DEFLATE -co INTERLEAVE=PIXEL PNOA_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

QUIZ #2
Cuntos drivers maneja GDAL/OGR?

martes 25 de junio de 2013

Mapa de elevacin
gdal_contour -a elev -i 25 MDT25-0223-H29.asc dem_vigo.shp

martes 25 de junio de 2013

Mapa de relieve
gdaldem hillshade MDT25-0223-H29.asc hillshade_vigo.tif

martes 25 de junio de 2013

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

Qu tal las dos cosas? gdal_rasterize


Monte de O Castro

martes 25 de junio de 2013

Y PostGIS Raster?
Nueva versin! Buen rendimiento en visualizacin (QGIS, Mapserver)

Desde 2013-06-19

https://github.com/jorgeas80/gdal_postgis_raster_driver.git
martes 25 de junio de 2013

GDAL + PostGIS Raster


Cargamos en PostGIS el SHP generado a partir del DEM
shp2pgsql -s epsg:25829 -I dem_vigo.shp > dem_vigo.sql psql -d geocamp -f dem_vigo.sql

Cargamos en PostGIS Raster el TIFF generado a partir del DEM


raster2pgsql -s epsg:25829 -I -M -C -t 50x50 hillshade_vigo.tiff > hillshade_vigo.sql psql -d geocamp -f dem_vigo.sql

martes 25 de junio de 2013

GDAL + PostGIS Raster


Obtenemos la interseccin de ambas capas nicamente en los puntos en los que la altitud es mayor a 600 m
create table hillshade_up_from_600 as select st_clip(rast, geom) as rast from 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

GDAL + PostGIS Raster

martes 25 de junio de 2013

Quiz #3
En qu orden muestra GDAL los drivers disponibles?

martes 25 de junio de 2013

Quiz #3
a) Orden alfabtico 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

OGR: Geocoding
En C
/* 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);

En SQL
SELECT ST_Centroid(ogr_geocode('Paris')) returns: OGRFeature(SELECT):0 POINT (2.342878767069653 48.85661793020374)

Ms info

http://erouault.blogspot.fr/2012/12/a-geocoding-client-api-in-gdalogr.html
martes 25 de junio de 2013

Ms funcionalidades sexy de OGR


http://trac.osgeo.org/gdal/wiki/rfc39_ogr_layer_algebra

OGR lgebra

http://gdal.org/ogr/ogr_sql_sqlite.html

SQL sobre capas no SQL (soporta dialecto SQLite)

martes 25 de junio de 2013

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

Crditos

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

MUCHAS GRACIAS
Escrbeme!
Jorge Arvalo jorge.arevalo@geomati.co jorgearevalo@libregis.org Junio 2013

martes 25 de junio de 2013

Вам также может понравиться