cli geoprocessing gdal/ogr

Click here to load reader

Post on 11-May-2015

2.942 views

Category:

Technology

1 download

Embed Size (px)

DESCRIPTION

DORS/CLUC 2010 Workshop Linux User Conference

TRANSCRIPT

  • 1.GIS na GNU/Linux-u Darko Boto APIS IT d.o.o . GIS analitiar CLI Geoproccesing GDAL/OGR

2. Sadraj :

    • Uvod
    • O radionici
    • Povijest FLOSS GIS-a
    • Anatomija FLOSS GIS-a
    • to je GIS?
    • Projekcije
    • Prostorni podaci
    • CLI geoprocesiranje - GDAL/OGR sa primjerima
    • Podeavanje PostGIS baze
    • PostGIS SQL upiti sa primjerima i skriptama
    • Pregled alata
    • WEB GIS

3. O radionici

    • OSGeo VM - Linux distribucija bazirana na Ubuntu-u
    • http://wiki.osgeo.org/wiki/Live_GIS_Disc
    • Arramagong - http://www.arramagong.com/Arramagong
    • Predinstaliran SW iskljuivo pod pokroviteljstvom OSGeofondacije
      • (http://www.osgeo.org)

4.

    • WEB arhitekture?
    • Desktop alati?
    • Osnove GIS-a?
    • CLI Geoprocesiranjeu duhu konferencije
    • Biblioteke u pozadini UI
    • Demistifikacija geoprocessing-a
    • Anatomija FLOSS GIS stack-a

5. Povijest FLOSS GIS-a

    • 1978 - MOSS
    • 1983 - Proj4
    • 1995 - UMN Mapserver
    • 1998 - GDAL/OGR
    • 1999 - GRASS GIS
    • 2000 - JTS Topology suite
    • 2001 - PostGIS
    • 2002 - Quantum GIS
    • 2002 - GEOS
    • 2006 - OSGEO

6. 7. to je GIS?

  • to je pored standardne radne okoline potrebno da bi bi sustav bio geografski tj. da bi nam omoguio podrku za prostorne analize?
  • Tri funkcionalna zahtjeva za prostorne analize (tj.GIS-a):
    • Data driver(GDAL - Geospatial Data Abstraction Library)
      • GDAL/OGR = u pravljaki program za rasterske/vektorske GIS formate podataka tj. omoguava da se pristupi raznim rasterskim/vektorskim zapisima prostornih podataka.
      • PostGIS (PostgreSQL extenzija za "geometry" tip podataka u bazi - Simple Feature Specification for SQL)
    • Geometry engine(GEOS - Geometry Engine - Open Source)
      • GEOS= C++ port od JTS-a
      • Omoguava operacije nad vektorima tj. logiku operacija nad skupovima te osnovne topoloke analize.
      • Ukljuuje prostorne operatore i Simple Features for SQL funkcije.
    • Projection engine(PROJ4 - Cartographic Projections library)
      • PROJ4= Podrka za geografske datume, projekcije i transformacije meu njima.

8. Projekcije http://spatialreference.org/ 9. Prostorni podaci Vektorski podaci: Arc/Info Binary Coverage, Arc/Info .E00 (ASCII) Coverage, Atlas BNA, AutoCAD DXF, CSV, ESRI Personal GeoDatabase, ESRI Shapefile, GeoJSON, GeoRSS, GML, GMT, GPX.... Simple features (OGC- http://www.opengeospatial.org/standards/sfa)POINT(6 10) LINESTRING(3 4,10 50,20 25) POLYGON((1 1,5 1,5 5,1 5,1 1),(2 2,2 3,3 3,3 2,2 2)) MULTIPOINT(3.5 5.6, 4.8 10.5) MULTILINESTRING((3 4,10 50,20 25),(-5 -8,-10 -8,-15 -4)) MULTIPOLYGON(((1 1,5 1,5 5,1 5,1 1),(2 2,2 3,3 3,3 2,2 2)),((6 3,9 2,9 4,6 3))) GEOMETRYCOLLECTION(POINT(4 6),LINESTRING(4 6,7 10)) POINT ZM (1 1 5 60) POINT M (1 1 80) Rasterski Podaci:Arc/Info ASCII Grid, Arc/Info Binary Grid, Bathymetry Attributed Grid, ESRI .hdr, Erdas Imagine Raw, Generic Binary (.hdr), Oracle Spatial GeoRaster,Graphics Interchange Format (.gif), GMT Compatible netCDF, GRASS Rasters, TIFF/BigTIFF/GeoTIFF (.tif), JPEG JFIF, JPEG2000, NetCDF, PNG, Netpbm (.ppm,.pgm), Rasterlite - Rasters in SQLite DB, SRTM HGT Format, Terralib, USGS ASCII DEM, OGC Web Coverage Server, WKTRaster, OGC Web Map Server.... $wgethttp://slobodniatlas.mapnix.org/~dboto/DORS_workshop.tar.gz&& tar -xvzf DORS_workshop.tar.gz 10. GDAL = GDAL+OGR

  • GDAL Raster(Geospatial Data Abstraction Library)
  • Omoguava manipulaciju rasterskim podacima
    • Frank Warmerdam 1998,
    • Veliki broj podranih formata (http://www.gdal.org/formats_list.html)
    • Koristi ga veliki broj i FLOSS i vlasnikog SW-a
  • (3D DEM Viewer, ESRI ArcGIS 9.2+, Feature Data Objects (FDO), FME, GeoServer, Google Earth, GRASS GIS, gvSIG, IDRISI, ILWIS, MapGuide, Mapnik, MapServer, MapWindow, QGIS...)
    • Vrlo dobar programski interface - API (SWIG):Python, Perl, Java, C#, Ruby
    • Dobro dokumentiran.

11. GDAL Utilities

    • gdalinfo- Iscrpan pregled metapodaka
    • gdal_translate-Transformacija izmeu razliitih rasterskih formata sa kontrolom output-a
    • gdalwarp- Transformacija slike prema koordinatnom sistemu,
    • gdaltindex -Izrada tile indexa za optimizaciju MapServer-a,
    • gdal_contour- Generiranje izolinija iz visinskih modela,
    • gdaldem- PerryGeo alati (1.7.0) osjenavanje, izraun nagiba i koloriziranje visinskih modela,
    • gdal_merge.py- Izrada mozaika od kolekcije georeferenciranih rastera,
    • gdal2tiles.py-Izrada TMS strukture i preglednika (OL),
    • gdal_rasterize- Rasterizacija vektora,
    • gdaltransform- Transformacija koordinata,
    • gdal_retile.py-Izrada piramida i retile-anje,
    • gdal_polygonize.py-Generiranje poligona iz rastera,
    • gdal_fillnodata.py- Punjenje "nodata" regiona.

12. gdalinfo $gdalinfo ASTGTM_N44E015_dem.tif Driver: GTiff/GeoTIFF Files: ASTGTM_N44E015_dem.tif Size is 3601, 3601 Coordinate System is: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.2572235629972, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0], UNIT["degree",0.0174532925199433], AUTHORITY["EPSG","4326"]] Origin = (14.999861111111111,45.000138888888891) Pixel Size = (0.000277777777778,-0.000277777777778) Metadata: AREA_OR_POINT=Area TIFFTAG_DOCUMENTNAME=created at TIFFTAG_IMAGEDESCRIPTION=SILC TIFF TIFFTAG_SOFTWARE=IDL 6.3, Research Systems, Inc. TIFFTAG_DATETIME=2008:10:27 20:50:05 TIFFTAG_XRESOLUTION=100 TIFFTAG_YRESOLUTION=100 TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch) Image Structure Metadata: INTERLEAVE=BAND Corner Coordinates: Upper Left ( 14.9998611, 45.0001389) ( 14d59'59.50"E, 45d 0'0.50"N) Lower Left ( 14.9998611, 43.9998611) ( 14d59'59.50"E, 43d59'59.50"N) Upper Right ( 16.0001389, 45.0001389) ( 16d 0'0.50"E, 45d 0'0.50"N) Lower Right ( 16.0001389, 43.9998611) ( 16d 0'0.50"E, 43d59'59.50"N) Center ( 15.5000000, 44.5000000) ( 15d30'0.00"E, 44d30'0.00"N) Band 1 Block=3601x1 Type=Int16, ColorInterp=Gray < format zapisa < veliina 0: last_val = key_list[-1] if z_value >= last_val: return color_dict[last_val] else: key_list.remove(last_val) # Print some info print "Creating %s" % (dst_file) # Open source file src_ds = gdal.Open( src_file ) src_band = src_ds.GetRasterBand(1) # create destination file dst_driver = gdal.GetDriverByName('GTiff') dst_ds = dst_driver.Create(dst_file, src_ds.RasterXSize, src_ds.RasterYSize, out_bands, gdal.GDT_Byte) # create output bands band1 = numpy.zeros([src_ds.RasterYSize, src_ds.RasterXSize]) band2 = numpy.zeros([src_ds.RasterYSize, src_ds.RasterXSize]) band3 = numpy.zeros([src_ds.RasterYSize, src_ds.RasterXSize]) # set the projection and georeferencing info dst_ds.SetProjection( src_ds.GetProjection() ) dst_ds.SetGeoTransform( src_ds.GetGeoTransform() ) # read the source file gdal.TermProgress( 0.0 ) for iY in range(src_ds.RasterYSize): src_data = src_band.ReadAsArray(0,iY,src_ds.RasterXSize,1) col_values = src_data[0]# array of z_values, one per row in source data for iX in range(src_ds.RasterXSize): z_value = col_values[iX] # print z_value# uncomment to see what value breaks color ramp [R,G,B] = MakeColor(z_value) band1[iY][iX] = R band2[iY][iX] = G band3[iY][iX] = B gdal.TermProgress( (iY+1.0) / src_ds.RasterYSize ) # write each band out dst_ds.GetRasterBand(1).WriteArray(band1) dst_ds.GetRasterBand(2).WriteArray(band2) dst_ds.GetRasterBand(3).WriteArray(band3) dst_ds = None #END scriptIli jednostavnije: $gdaldem color-relief ASTGTM_N44E015_dem.tif ramp.txt color.tif gdje je ramp.txt3500 white 2500 235:220:175 50% 190 185 135 700 240 250 150 0 50 180 50 nv 0 0 0 0100% 255 255 255 75% 235 220 175 50% 190 185 135 25% 240 250 150 0% 50 180 50 nv 0 0 0 16. gdal_contour Omoguava generiranje izo linija iz rastera sa visinskim podacima (SRTM, ASTER) $g

View more