Introduction to gdal virtual files

Source: Internet
Author: User
Tags gz file gtx

Before starting the blog, I wish you all the best in the New Year. New Year's new weather, hope to have more exchanges with you in the new year, and learn and make progress together.

The gdal virtual file starts from version 1.6.0 and is mainly used to access data in archive files such as ZIP or GZ. For details about the distance, visit http://trac.osgeo.org/gdal/wiki/userdocs/readinzip. At first, only two virtual file systems are supported:/vsigzip and/viszip. Only the. ZIP file can be read, while/visgzip supports reading and sequential writing. However, the write speed is somewhat slow.

Starting from 1.8.0, gdalcan read uncompressed .tar.gz/. tgz compressed data.

The following is a simple example (gdalinfo and ogrinfo are used.

Read the GZ file:

gdalinfo /vsigzip/path/to/the/file.gzgdalinfo /vsigzip//home/path/to/the/file.gz

The first line above,/path/to/The/file.gz, is the relative path of the file. The second line is the absolute path, which is the path in the Linux system, and the absolute path in the Linux system starts with/. According to gdal, for the absolute path in the Linux system, add one more /. Windows generally starts with a drive letter, for example, C:/path/to/The/file.zip in the fourth line.

Read ZIP files:

gdalinfo /vsizip/path/to/the/file.zip/path/inside/the/zip/file.tifgdalinfo /vsizipC:/path/to/the/file.zip/path/inside/the/zip/file.tif

First, let's look at the above two sentences. The first sentence is basically the same as the second sentence, except that the first sentence is relative path and the second sentence is absolute path. The second sentence is used as an example. The file path in the second sentence is/vsizipc:/path/to/The/file.zip/path/inside/The/zip/file. tif. This path can be divided into three parts, which are represented by different colors. The red part is used to mark the type of the Virtual File System, which is a ZIP format; the second part is the path of the ZIP file, and the third part is the green part, the path of TIF data in the zip package.
Here is a small description. The zip file contains only one data, so you do not need to write the third part, but directly write it to the second part.

Read the .tar.gz and. tgz files:

Read the .tar.gz and. tgz files. Gdalcan read data from archive files in the tar.gz and tgz formats. The read syntax is very similar to the preceding one, as shown below:

gdalinfo /vsitar/path/to/the/file.tar/path/inside/the/tar/filegdalinfo /vsitar/path/to/the/file.tar.gz/path/inside/the/targz/file

The two sentences are not too many. One is reading the data from the tar.gz, and the other is reading the data from the tar.gz. Take the second one as an example. The file path is/vsitar/path/to/The/file.tar.gz/path/inside/The/targz/file. the first step is to describe the format of the virtual file. The second step is the format of tar.gz, and the third step is the path of the data in.

Reading data in the tar.gz format is much slower than reading zip data. The main reason is that tar.gz compresses all the files in the entire package, while zip compresses each file separately. When reading the last file in tar.gz, You need to extract all the preceding files.
Read network files:

Next is another Virtual File System/vsicurl, which is mainly used to read network data. This is also newly added in version 1.8.0. For example, you can directly access SHP data on a network. For example:

ogrinfo -ro -al -so /vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.shp

Ogrinfo is a tool that is similar to gdalinfo. It is mainly used to view vector data information. It mainly looks at the following path. /Vsicurl/route.

The output is as follows:


Figure 1 result of access network SHP

With the above several virtual file systems in mind, you can combine the above to access, for example, to read a SHP data of a zip compressed package in a network, you need to read the zip data in the network before reading the SHP data in the ZIP file. Example:

ogrinfo -ro -al -so /vsizip/vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.zip.shpogrinfo -ro -al -so /vsizip/vsicurl/http://svn.osgeo.org/gdal/trunk/autotest/ogr/data/poly.zip

The above path is complicated. Two virtual file systems are used in the middle,/vsizip/vsicurl/URLs.

The output content of the above two rows is the same, as shown below:


Figure 2 output results of access network zip


Figure 3 output results of access network zip

In addition, it is more complex to assume that a data is stored on an FTP server and requires a user name and password for access. Such data can still be accessed through gdal, provided that you know the user name and password. Example:

ogrinfo -ro -al -so /vsizip/vsicurl/ftp://user:password@example.com/foldername/file.zip/example.shp

PATH is/vsizip/vsicurl/ftp: // User: password@example.com/Foldername/file.zip/example. SHP, we still use color for splitting. The first part and the second part are the same as the fourth part. The difference is that the third part, the green part, contains a user: password @ in the middle, which is literally clear, namely the user name and password, and @ is followed by the data address.

Finally, not all formats support virtual file systems. To determine whether a file supports Virtual File Systems, a simple method is to use the -- formats command in the gdal tool, then, in the output format, if v is added to the backend arc, It is supported. If V is not added, it is not supported. For example, the output is:


Too many images can't be cut down. paste them to the back:

C:\warmerda\bld\bin>gdalinfo.exe --formatsSupported Formats:  VRT (rw+v): Virtual Raster  GTiff (rw+v): GeoTIFF  NITF (rw+v): National Imagery Transmission Format  RPFTOC (rov): Raster Product Format TOC format  ECRGTOC (rov): ECRG TOC format  HFA (rw+v): Erdas Imagine Images (.img)  SAR_CEOS (rov): CEOS SAR Image  CEOS (rov): CEOS Image  JAXAPALSAR (rov): JAXA PALSAR Product Reader (Level 1.1/1.5)  GFF (rov): Ground-based SAR Applications Testbed File Format (.gff)  ELAS (rw+v): ELAS  AIG (rov): Arc/Info Binary Grid  AAIGrid (rwv): Arc/Info ASCII Grid  GRASSASCIIGrid (rov): GRASS ASCII Grid  SDTS (rov): SDTS Raster  DTED (rwv): DTED Elevation Raster  PNG (rwv): Portable Network Graphics  JPEG (rwv): JPEG JFIF  MEM (rw+): In Memory Raster  JDEM (rov): Japanese DEM (.mem)  GIF (rwv): Graphics Interchange Format (.gif)  BIGGIF (rov): Graphics Interchange Format (.gif)  ESAT (ro): Envisat Image Format  FITS (rw+): Flexible Image Transport System  BSB (rov): Maptech BSB Nautical Charts  XPM (rwv): X11 PixMap Format  BMP (rw+v): MS Windows Device Independent Bitmap  DIMAP (rov): SPOT DIMAP  AirSAR (ro): AirSAR Polarimetric Image  RS2 (ro): RadarSat 2 XML Product  PCIDSK (rw+v): PCIDSK Database File  PCRaster (rw): PCRaster Raster File  ILWIS (rw+v): ILWIS Raster Map  SGI (rw+): SGI Image File Format 1.0  SRTMHGT (rwv): SRTMHGT File Format  Leveller (rw+): Leveller heightfield  Terragen (rw+): Terragen heightfield  HDF4 (ro): Hierarchical Data Format Release 4  HDF4Image (rw+): HDF4 Dataset  ISIS3 (rov): USGS Astrogeology ISIS cube (Version 3)  ISIS2 (rw+v): USGS Astrogeology ISIS cube (Version 2)  PDS (rov): NASA Planetary Data System  TIL (rov): EarthWatch .TIL  ERS (rw+v): ERMapper .ers Labelled  ECW (rov): ERDAS Compressed Wavelets (SDK 4.2)  JP2ECW (rov): ERDAS JPEG2000 (SDK 4.2)  JPEG2000 (rwv): JPEG-2000 part 1 (ISO/IEC 15444-1)  L1B (rov): NOAA Polar Orbiter Level 1b Data Set  FIT (rwv): FIT Image  GRIB (rov): GRIdded Binary (.grb)  MrSID (rov): Multi-resolution Seamless Image Database (MrSID)  JP2MrSID (rov): MrSID JPEG2000  MG4Lidar (ro): MrSID Generation 4 / Lidar (.sid)  RMF (rw+v): Raster Matrix Format  WCS (rov): OGC Web Coverage Service  WMS (rwv): OGC Web Map Service  MSGN (ro): EUMETSAT Archive native (.nat)  RST (rw+v): Idrisi Raster A.1  INGR (rw+v): Intergraph Raster  GSAG (rwv): Golden Software ASCII Grid (.grd)  GSBG (rw+v): Golden Software Binary Grid (.grd)  GS7BG (rov): Golden Software 7 Binary Grid (.grd)  COSAR (ro): COSAR Annotated Binary Matrix (TerraSAR-X)  TSX (rov): TerraSAR-X Product  COASP (ro): DRDC COASP SAR Processor Raster  R (rwv): R Object Data Store  PNM (rw+v): Portable Pixmap Format (netpbm)  DOQ1 (rov): USGS DOQ (Old Style)  DOQ2 (rov): USGS DOQ (New Style)  ENVI (rw+v): ENVI .hdr Labelled  EHdr (rw+v): ESRI .hdr Labelled  GenBin (rov): Generic Binary (.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 (rov): GSC Geogrid  FAST (rov): EOSAT FAST Format  BT (rw+v): VTP .bt (Binary Terrain) 1.3 Format  LAN (rw+v): Erdas .LAN/.GIS  CPG (ro): Convair PolGASP  IDA (rw+): Image Data and Analysis  NDF (rov): NLAPS Data Format  EIR (rov): Erdas Imagine Raw  DIPEx (rov): DIPEx  LCP (rov): FARSITE v.4 Landscape File (.lcp)  GTX (rw+v): NOAA Vertical Datum .GTX  LOSLAS (rov): NADCON .los/.las Datum Grid Shift  NTv2 (rw+v): NTv2 Datum Grid Shift  ACE2 (rov): ACE2  SNODAS (rov): Snow Data Assimilation System  RIK (ro): Swedish Grid RIK (.rik)  USGSDEM (rwv): USGS Optional ASCII DEM (and CDED)  GXF (ro): GeoSoft Grid Exchange Format  HTTP (ro): HTTP Fetching Wrapper  BAG (ro): Bathymetry Attributed Grid  HDF5 (ro): Hierarchical Data Format Release 5  HDF5Image (ro): HDF5 Dataset  NWT_GRD (rov): Northwood Numeric Grid Format .grd/.tab  NWT_GRC (rov): Northwood Classified Grid Format .grc/.tab  ADRG (rw+v): ARC Digitized Raster Graphics  SRP (rov): Standard Raster Product (ASRP/USRP)  BLX (rw): Magellan topo (.blx)  Rasterlite (rw): Rasterlite  SAGA (rw+v): SAGA GIS Binary Grid (.sdat)  KMLSUPEROVERLAY (rwv): Kml Super Overlay  XYZ (rwv): ASCII Gridded XYZ  HF2 (rwv): HF2/HFZ heightfield raster  OZI (rov): OziExplorer Image File  CTG (rov): USGS LULC Composite Theme Grid  E00GRID (rov): Arc/Info Export E00 GRID  ZMap (rwv): ZMap Plus Grid  NGSGEOID (rov): NOAA NGS Geoid Height Grids

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.