|
| 1 | +# Remote Virtual Layers |
| 2 | + |
| 3 | +A remote virtual layer can be supported via various GDAL drivers. The most common is the [GDAL WMS Driver](https://gdal.org/drivers/raster/wms.html). This allows MMGIS to treat remote datasets as if they were local. |
| 4 | + |
| 5 | +## GDAL XML Desciption File Template |
| 6 | + |
| 7 | +Here is a template of a GDAL XML Description file that may be used to access a remote DEM for the [Measure Tool](?page=Measure). |
| 8 | + |
| 9 | +```xml |
| 10 | +<GDAL_WMS> |
| 11 | + <Service name="WMS"> |
| 12 | + <!-- recommend Version 1.1.1; Version 1.3 uses different bounding box definition --> |
| 13 | + <Version>1.1.1</Version> |
| 14 | + <!-- root URL of WMS service --> |
| 15 | + <ServerUrl>http://localhost/map/?</ServerUrl> |
| 16 | + <!-- projection of the source dataset --> |
| 17 | + <SRS>IAU2000%3A30166%2C31.1492746341015%2C-85.391176037601</SRS> |
| 18 | + <ImageFormat>image/tiff</ImageFormat> |
| 19 | + <!-- name of one or more WMS layers--> |
| 20 | + <Layers>some_dem_layer</Layers> |
| 21 | + </Service> |
| 22 | + <DataWindow> |
| 23 | + <!-- the values below should match the full bounds of the dataset --> |
| 24 | + <UpperLeftX>-2091.701</UpperLeftX> |
| 25 | + <UpperLeftY>3505.141</UpperLeftY> |
| 26 | + <LowerRightX>6119.299</LowerRightX> |
| 27 | + <LowerRightY>-3638.859</LowerRightY> |
| 28 | + <!-- recommend native sizes of the dataset, but may be reduced if full resolution is not needed (results in faster queries, but lower data precision) --> |
| 29 | + <SizeX>8211</SizeX> |
| 30 | + <SizeY>7144</SizeY> |
| 31 | + </DataWindow> |
| 32 | + <!-- the desired output project, which should match the MMGIS map --> |
| 33 | + <Projection>+proj=stere +lat_0=-85.391176037601 +lon_0=31.1492746341015 +k=1 +x_0=0 +y_0=0 +a=1737400 +b=1737400 +units=m +no_defs</Projection> |
| 34 | + <BandsCount>1</BandsCount> |
| 35 | + <!-- *Important* to ensure that DataType matches the source data --> |
| 36 | + <DataType>Float32</DataType> |
| 37 | + <!-- GDAL creates a local cache for faster access; highly recommend to include --> |
| 38 | + <Cache> |
| 39 | + <!-- set an expiration value to prevent the cached data from filling up local storage --> |
| 40 | + <Expires>604800</Expires> |
| 41 | + <!-- a directory with write permissions to store cached data; defaults to ./gdalwmscache if not provided --> |
| 42 | + <Path>./gdalwmscache</Path> |
| 43 | + </Cache> |
| 44 | +</GDAL_WMS> |
| 45 | +``` |
| 46 | + |
| 47 | +## GDAL Local Caching |
| 48 | + |
| 49 | +If the `<Cache>` tag is included in the XML description file, GDAL will by default create a directory named `gdalwmscache` at the root location of MMGIS (directory must have write permissions for this to work). It is highly recommended to include this capability to significantly improve performance. Initial queries to a remote dataset may take several seconds, but subsequent queries that hit the cache are just as fast as accessing a local file. |
| 50 | + |
| 51 | +## Remote XML Description File |
| 52 | + |
| 53 | +Typically, an XML description file is generated locally for any dataset that is to be accessed remotely. This file can be place in the mission's Data/ directly for easy access by MMGIS. |
| 54 | + |
| 55 | +However, it is also possible to access a remote XML description file on another server. This can enable more control for dynamic access. This is accomplished via GDAL's `/vsicurl/` prefix to access network locations. For example, instead of specifying a local XML description file for a DEM like so: |
| 56 | + |
| 57 | +```javascript |
| 58 | +{ |
| 59 | + "dem": "data/description.xml" |
| 60 | +} |
| 61 | +``` |
| 62 | + |
| 63 | +A remote XML description file can be specified like this: |
| 64 | + |
| 65 | +```javascript |
| 66 | +{ |
| 67 | + "dem": "/vsicurl/http://localhost/description.xml" |
| 68 | +} |
| 69 | +``` |
| 70 | + |
| 71 | +Other `vsi*` options exist for commercial cloud storage such as S3: `/vsis3/` |
| 72 | + |
| 73 | +Note: for directly accessing cloud-optimized GeoTIFFs, the XML description file is unnecessary and can be bypassed altogether by using the `/vsis3/` prefix and referencing the remote file path. |
| 74 | + |
| 75 | +See GDAL documentation for more information about virtual file systems: https://gdal.org/user/virtual_file_systems.html#network-based-file-systems |
| 76 | + |
| 77 | +## More Information |
| 78 | + |
| 79 | +For more details about the XML description file, see the official GDAL documentation here: https://gdal.org/drivers/raster/wms.html#xml-description-file |
0 commit comments