Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédente | |||
| main:logiciels:gdal:couteau_suisse:faq_raster [2010/01/12 13:52] – correction d'une typo JRM | main:logiciels:gdal:couteau_suisse:faq_raster [2026/10/23 03:40] (Version actuelle) – supprimée - modification externe (Date inconnue) 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | [[start|Retour au sommaire]] || [[faq|FAQ]] | ||
| - | ====== F.A.Q. Raster ====== | ||
| - | * [[faq_general|Généralité]] | ||
| - | * [[faq_install|Installation et configuration]] | ||
| - | * [[faq_raster|Raster]] | ||
| - | * [[faq_vecteur|Vecteur]] | ||
| - | * [[faq_proj|Projection et système de coordonnées]] | ||
| - | * [[faq_divers|Divers]] | ||
| - | |||
| - | ===== Pourquoi gdalwarp ou gdal_merge n' | ||
| - | |||
| - | GDAL gère beaucoup de formats raster en lecture, mais beaucoup moins de formats en écriture. Parmi ceux gérés en écriture la plupart ne sont gérés seulement en mode //create copy//. Essentiellement cela signifie qu'ils doivent être écrits séquentiellement à partir d'une copie en entrée fournie de l' | ||
| - | |||
| - | Quand vous rencontrez ce problème il est généralement pas une bonne idée d' | ||
| - | |||
| - | Pour déterminer quels formats gèrent quelles possibilités, | ||
| - | |||
| - | ===== Comment améliorer les performances de gdalwarp ? ===== | ||
| - | |||
| - | Brièvement : utilisez la mémoire déformée et configurez le paramètre // | ||
| - | |||
| - | Pour plus de détails, lisez [[http:// | ||
| - | |||
| - | ===== Comment convertir un raster en une couche de polygones ? ===== | ||
| - | |||
| - | TBD | ||
| - | |||
| - | ===== Comment puis je créer un raster blanc basé sur l' | ||
| - | |||
| - | Aujourd' | ||
| - | |||
| - | Une approche est d' | ||
| - | |||
| - | Une autre approche est d' | ||
| - | |||
| - | < | ||
| - | <code python> | ||
| - | # | ||
| - | |||
| - | from osgeo import gdal | ||
| - | from osgeo import osr | ||
| - | from osgeo import ogr | ||
| - | import numpy | ||
| - | |||
| - | shp = ' | ||
| - | tiff = ' | ||
| - | px = .001 | ||
| - | tiff_width = 7850 | ||
| - | tiff_height = 3500 | ||
| - | |||
| - | # Import vector shapefile | ||
| - | vector = ogr.GetDriverByName(' | ||
| - | src_ds = vector.Open(shp) | ||
| - | src_lyr = src_ds.GetLayerByIndex(index=0) | ||
| - | src_extent = src_lyr.GetExtent() | ||
| - | |||
| - | # Create new raster layer with 4 bands | ||
| - | raster = gdal.GetDriverByName(' | ||
| - | dst_ds = raster.Create( tiff, tiff_width, tiff_height, | ||
| - | |||
| - | # Create raster GeoTransform based on upper left corner and pixel resolution | ||
| - | raster_transform = [src_extent[0], | ||
| - | dst_ds.SetGeoTransform( raster_transform ) | ||
| - | |||
| - | # Get projection of shapefile and assigned to raster | ||
| - | srs = osr.SpatialReference() | ||
| - | srs.ImportFromWkt(src_lyr.GetSpatialRef().__str__()) | ||
| - | dst_ds.SetProjection( srs.ExportToWkt() ) | ||
| - | |||
| - | # Create blank raster with fully opaque alpha band | ||
| - | zeros = numpy.zeros( (tiff_height, | ||
| - | dst_ds.GetRasterBand(1).WriteArray( zeros ) | ||
| - | dst_ds.GetRasterBand(2).WriteArray( zeros ) | ||
| - | dst_ds.GetRasterBand(3).WriteArray( zeros ) | ||
| - | opaque = numpy.ones((tiff_height, | ||
| - | dst_ds.GetRasterBand(4).WriteArray( opaque ) | ||
| - | </ | ||
| - | |||
| - | ===== Puis je utiliser gdal_rasterize pour générer des polygones "non solides " ? ===== | ||
| - | |||
| - | Lisez la page [[http:// | ||
| - | |||
| - | Comme Chris Barker le suggère, les possibilités de rastérisation deGDAL sont assez limitées d'un point de vue du style du rendu. D' | ||
| - | |||
| - | Exemples d' | ||
| - | |||
| - | Cependant, si votre raster gère la transparence dans la bande alpha (RGBA), alors vous pouvez utiliser '' | ||
| - | |||
| - | $ gdal_rasterize -b 4 -burn 0 -where your_field=some_value -l your_layer your_vector_file.shp your_raster | ||
| - | |||
| - | ===== Comment utiliser gdal_translate pour extraire une sous partie d'un raster ? ===== | ||
| - | |||
| - | '' | ||
| - | |||
| - | Si vous désirez extraire une sous partie d'un raster vous pouvez utiliser les options //-srcwin// ou // | ||
| - | |||
| - | Voici un exemple de l' | ||
| - | |||
| - | $ gdal_translate -projwin 510286 5385025 518708 5373405 ortho_1-1_1n_s_wa055_2006_1.sid naip_ortho_blakely_island.tif | ||
| - | |||
| - | Cet exemple utilise l' | ||
| - | |||
| - | < | ||
| - | </ | ||
| - | |||
| - | Disons que vous avez un shapefile nommé // | ||
| - | |||
| - | * notez que l' | ||
| - | | ||
| - | $ ogrinfo clipping_mask.shp -so -al | grep Extent | ||
| - | # which gives the extent as xMin,yMin, xMax, yMax: | ||
| - | Extent: (268596, 5362330) - (278396, 5376592) | ||
| - | # which is (xMin,yMin) - (xMax,yMax) | ||
| - | |||
| - | Puis copier et coller ce texte pour créer votre commande de découpe avec '' | ||
| - | |||
| - | # -projwin' | ||
| - | # For the above Extent that would turn into: | ||
| - | $ gdal_translate -projwin 268596 5376592 278396 5362330 src_dataset dst_dataset | ||
| - | |||
| - | |||
| - | ===== Comment retrouver la liste des formats supportés par ma version de GDAL ? ===== | ||
| - | Utilisez la commande : | ||
| - | gdalinfo --formats | ||
| - | |||
| - | Celle-ci vous renvoie : | ||
| - | $ gdalinfo --formats | ||
| - | Supported Formats: | ||
| - | GRASS (ro): GRASS Database Rasters (5.7+) | ||
| - | VRT (rw+): Virtual Raster | ||
| - | GTiff (rw+): GeoTIFF | ||
| - | NITF (rw+): National Imagery Transmission Format | ||
| - | HFA (rw+): Erdas Imagine Images (.img) | ||
| - | SAR_CEOS (ro): CEOS SAR Image | ||
| - | CEOS (ro): CEOS Image | ||
| - | ELAS (rw+): ELAS | ||
| - | AIG (ro): Arc/Info Binary Grid | ||
| - | AAIGrid (rw): Arc/Info ASCII Grid | ||
| - | SDTS (ro): SDTS Raster | ||
| - | OGDI (ro): OGDI Bridge | ||
| - | DTED (rw): DTED Elevation Raster | ||
| - | PNG (rw): Portable Network Graphics | ||
| - | JPEG (rw): JPEG JFIF | ||
| - | MEM (rw+): In Memory Raster | ||
| - | JDEM (ro): Japanese DEM (.mem) | ||
| - | GIF (rw): Graphics Interchange Format (.gif) | ||
| - | ESAT (ro): Envisat Image Format | ||
| - | FITS (rw+): Flexible Image Transport System | ||
| - | BSB (ro): Maptech BSB Nautical Charts | ||
| - | XPM (rw): X11 PixMap Format | ||
| - | BMP (rw+): MS Windows Device Independent Bitmap | ||
| - | AirSAR (ro): AirSAR Polarimetric Image | ||
| - | RS2 (ro): RadarSat 2 XML Product | ||
| - | PCIDSK (rw+): PCIDSK Database File | ||
| - | PCRaster (rw): PCRaster Raster File | ||
| - | ILWIS (rw+): ILWIS Raster Map | ||
| - | SGI (ro): SGI Image File Format 1.0 | ||
| - | Leveller (ro): Leveller heightfield | ||
| - | GMT (rw): GMT NetCDF Grid Format | ||
| - | netCDF (rw): Network Common Data Format | ||
| - | PNM (rw+): Portable Pixmap Format (netpbm) | ||
| - | DOQ1 (ro): USGS DOQ (Old Style) | ||
| - | DOQ2 (ro): USGS DOQ (New Style) | ||
| - | ENVI (rw+): ENVI .hdr Labelled | ||
| - | EHdr (rw+): ESRI .hdr Labelled | ||
| - | PAux (rw+): PCI .aux Labelled | ||
| - | MFF (rw+): Vexcel MFF Raster | ||
| - | MFF2 (rw+): Vexcel MFF2 (HKV) Raster | ||
| - | FujiBAS (ro): Fuji BAS Scanner Image | ||
| - | GSC (ro): GSC Geogrid | ||
| - | FAST (ro): EOSAT FAST Format | ||
| - | BT (rw+): VTP .bt (Binary Terrain) 1.3 Format | ||
| - | LAN (ro): Erdas .LAN/.GIS | ||
| - | CPG (ro): Convair PolGASP | ||
| - | IDA (rw+): Image Data and Analysis | ||
| - | NDF (ro): NLAPS Data Format | ||
| - | DIPEx (ro): DIPEx | ||
| - | ISIS2 (ro): USGS Astrogeology ISIS cube (Version 2) | ||
| - | PDS (ro): NASA Planetary Data System | ||
| - | JPEG2000 (rw): JPEG-2000 part 1 (ISO/IEC 15444-1) | ||
| - | ECW (rw): ERMapper Compressed Wavelets | ||
| - | JP2ECW (rw+): ERMapper JPEG2000 | ||
| - | L1B (ro): NOAA Polar Orbiter Level 1b Data Set | ||
| - | FIT (rw): FIT Image | ||
| - | RMF (rw+): Raster Matrix Format | ||
| - | WCS (ro): OGC Web Coverage Service | ||
| - | RST (rw+): Idrisi Raster A.1 | ||
| - | RIK (ro): Swedish Grid RIK (.rik) | ||
| - | USGSDEM (rw): USGS Optional ASCII DEM (and CDED) | ||
| - | GXF (ro): GeoSoft Grid Exchange Format | ||
| - | |||
| - | ---- | ||
| - | --- // | ||

