Hot answers tagged

10

Honestly it's easier to do this by using gdalbuildvrt in a subprocess or os.system. Should you wish to do this through Python it can be done. Using the standard dataset creation methods within GDAL Python we can easily create the base dataset VRT. from osgeo import gdal drv = gdal.GetDriverByName("VRT") vrt = drv.Create("test.vrt", x_size, y_size, 0) ...


10

I love processing with vrt's. you can make lots of interim changes. Evaluate them quickly in QGIS and if you like any of them just translate back to a selfcontained raster format (tif, png etc). saves lots of time. U2ros,your uses of vrt's makes perfect sense, to me at least :) mosaicking and then clipping is what I originally started using vrts for: ...


7

You don't have to use a .vrt any more. ogr2ogr supports reading csv files with geometry directly since version 2.1. The ogr2ogr command: ogr2ogr -f "PostgreSQL" PG:"host=000.000.000.000 port=0000 dbname=myDB user=me password=youtellme" -s_srs EPSG:4326 -t_srs EPSG:3857 -progress -nln output -lco OVERWRITE=YES -lco GEOMETRY_NAME=shape -oo X_POSSIBLE_NAMES=...


6

It depends mostly on which is the minimun scale to show your image layer. Creating overviews for individual rasters is more flexible when you update your layer partially. Just delete old image and put a new image with overviews in place. If you have build overviews for the .vrt you must create it again after update. However, individual overviews do not work ...


6

First of all, I don't think that gdalbuildvrt will do exactly what you want with the "-separate" option : the stacked file will be a layer of N bands containing each individual image in one of those bands. Concerning your syntax, I would write : gdalbuildvrt -separate -input_file_list inputlist.txt stack.vrt In python, I usually call gdal directly ...


6

You can solve with two chained VRT files and a bit of OGR SQL. The first VRT (e.g. remapped_csv.vrt) is: <OGRVRTDataSource> <OGRVRTLayer name="remapped_csv"> <SrcDataSource>test.csv</SrcDataSource> <SrcSQL>SELECT *, SUBSTR(latlon,2,5) AS lat, SUBSTR(latlon,9,12) AS lon FROM test</SrcSQL> </...


5

Depending on where you create the VRT, it will either become a relative path, or an absolute path. You can manually set this, by modifying the relativeToVRT="1"to a 0, and then write a complete path in the instead of just the image filename. See the example below of a full path VRT. <VRTRasterBand dataType="Byte" band="1"> <ColorInterp>...


4

Have you tried it sucessfully with a handfull of files? For me, it worked with 300 files. At first, I had to build individual vrts for each image to expand the colour information to rgba: for %%N in (D:\Karten\gdal\gdal2tiles\NL25\*.tif) DO gdal_translate -of vrt -expand rgba %%N D:\Karten\gdal\gdal2tiles\NL25\%%~nN.vrt Second run, I merged all those vrts ...


4

Not sure if it helps you, but this was my workflow to tile 2GB of 300 Dutch Topo maps to OSM compatible zoomlevel 15 and 16: Create vrts for each tif and expand indexed colours to RGBA: for %%N in (D:\Karten\gdal\gdal2tiles\NL25*.tif) DO gdal_translate -of vrt -expand rgba %%N D:\Karten\gdal\gdal2tiles\NL25\%%~nN.vrt Create an index vrt for all files: ...


4

I'm afraid it is a typo in the first line. Try: <OGRVRTDataSource> <OGRVRTLayer name="grid"> <SrcDataSource>grid.csv</SrcDataSource> <GeometryType>wkbPoint25D</GeometryType> <LayerSRS>WGS84</LayerSRS> <GeometryField encoding="PointFromColumns" x="x" y="y" z="z"/> &...


4

More info about gdal.Grid() and gdal.GridOptions() are available in the GDAL/OGR Python API. Instead, here's the available options of the interpolation algorithms. About the linear approach, this line (and more in detail the algorithm options 'linear:radius=0'): output = gdal.Grid('outcome.tif','newpoints.vrt', algorithm = 'linear:radius=0') returns always ...


4

The best solution for you would be the VSIMEM filesystem which lets you save outputs of gdal utilities into a filesystem stored in memory. gdal.Warp('/vsimem/reprojected.tif', ds, srsSRS=in_proj, dstSRS=out_proj) You could also make a vrt: gdal.Warp('/vsimem/reprojected.vrt', ds, srsSRS=in_proj, dstSRS=out_proj) Once stored in the vsimem filesystem, the ...


4

No, this does not make sense. VRT is Virtual Raster Type, not a real raster. There is no data in a VRT, the data is just referenced in an XML file. You have to keep the original data. <SourceFilename relativeToVRT="1">utm.tif</SourceFilename> See here for documentation. VRT's make sense for e.g. mosaicing, merging, cutting, converting files ...


4

You are probably looking at estimated values. Check under layer properties, Symbology tab if Actual Accuracy is selected: Virtual raster is basically just list of rasters, when creating it original data does not get altered, just referenced.


3

From the CSV driver documentation: Starting with GDAL 1.8.0, for files structured as CSV, but not ending with .CSV extension, the 'CSV:' prefix can be added before the filename to force loading by the CSV driver. Either rename DGM5_BE.txt to DGM5_BE.csv or change the <SrcDataSource> element to: <SrcDataSource>CSV:DGM5_BE.txt</...


3

If you want to work with GDAL on command line, you have to change your input file to comma delimiters: X,Y -5.48,42.81 -4.78,42.52 -5.06,42.02 The appropriate vrt file for it is: <OGRVRTDataSource> <OGRVRTLayer name="test"> <SrcDataSource>test.csv</SrcDataSource> <GeometryType>wkbPoint</GeometryType> ...


3

Convert the file to WGS84 gdalwarp in_test.vrt out_test.vrt -t_srs "+proj=longlat +ellps=WGS84" Calcualte the bbox with GDAL in Python import gdal ds = gdal.Open('out_test.vrt') cols = ds.RasterXSize rows = ds.RasterYSize geotransform = ds.GetGeoTransform() bb1 = originX = geotransform[0] bb4 = originY = geotransform[3] pixelWidth = geotransform[1] ...


3

VRT can be used cross platform (if you are using relative paths and you place in the same directory as the images, otherwise the path names are not the same) and read it with ArcGIS. It is also easy to read what you have in it. It is great for processing large collections of coherent non overlapping images (lazy computation at its best) RMD has a set of ...


3

No, you can't use VRT as an output format for gdal_calc.py. gdal_calc.py reads raster data into numpy arrays, performs the requested calculation and writes the resulting numpy array out to a raster file on disk. In future, you should be be able to create a VRT with the calculation required to derive it using python code embedded in the VRT. See this GDAL-...


3

Sounds like you'd want to use the image mosaic plugin: http://docs.geoserver.org/stable/en/user/data/raster/imagemosaic/index.html The configuration of the mosaic can be scary, but if all you want is to merge all the images together visually, then put them in a directory and just point the GeoServer image mosaic at it with no other setups, it should self-...


2

The answer of @rcoup only worked for me, if modify it as follows: from osgeo import gdal vrt_options = gdal.BuildVRTOptions(resampleAlg='cubic', addAlpha=True) my_vrt = gdal.BuildVRT('my.vrt', ['one.tif', 'two.tif'], options=vrt_options) my_vrt = None Otherwise, the file is not written to disk.


2

Since GDAL 2.1 the CLI tools are available as library functions, and in fact that's what the CLI tools now call internally. For example: gdalbuildvrt -r cubic -addalpha my.vrt one.tif two.tif Is the equivalent of: from osgeo import gdal vrt_options = gdal.BuildVRTOptions(resampleAlg='cubic', addAlpha=True) gdal.BuildVRT('my.vrt', ['one.tif', 'two.tif'], ...


2

I believe you can specify a compound coordinate system (vertical + horizontal) as "EPSG:X+Y" where X and Y are the EPSG codes for your horizontal and vertical coordinate systems. The following reports correctly in ogrinfo and converts with ogr2ogr: <OGRVRTDataSource> <OGRVRTLayer name="data"> <SrcDataSource>data.csv</...


2

I suggest that you build you vrt at the first stage, so that you only process what you need. See this post about lazy computation. You could also get some inspiration from this post aboutPython function for pixels. But my last recommendation is to use Orfeo Toolbox (an open source software). You can do both steps with the Band math filter application (a ...


2

Andre Joost had the correct answer in his last statement. Its a character limit. If you use the wildcard it runs fine. I just tried on 28000 tiffs and it ran no problem.


2

<OGRVRTDataSource> <OGRVRTLayer name="test"> <SrcDataSource>test.csv</SrcDataSource> <GeometryType>wkbPolygon</GeometryType> <LayerSRS>WGS84</LayerSRS> <Field name="id" src="id" /> <GeometryField encoding="WKT" field="geo" /> </OGRVRTLayer> </...


2

There were two problems. One noticed by @kyle, that the VRTDataset depends on the original, the other that the datasets needed to be closed in a specific order. Since all the datasets in this example are created in a program I was not able to use GDALOpenShared() as the documentation suggests, so instead the proper datasets need to be closed and removed at ...


2

It does not seem to be blank. Probably your viewer just can not show that Float64 type file in a reasonable way. gdalinfo p.tiff -stats Driver: GTiff/GeoTIFF Files: p.tiff Size is 256, 256 Coordinate System is `' Origin = (313825.000000000000000,318725.000000000000000) Pixel Size = (20.510507812500009,19.759648437499891) Image Structure Metadata: ...


2

In your LUT, create a range where everything less than -100 (i.e. -32768 to -101) is given a single value to set as NoData (i.e. -32768). All values in between will get assigned that single value. Then set valid min and max values equal to themselves and all values in between will get assigned the same value as each originally was. And if that makes no ...


2

It appears that you are missing the '-l dgm-10-epsg-32633' before your vrt-file. In essence, it doesn't know which layer of the vrt-file to use (even if there only is one layer). See the example in the man-page of gdal_grid: gdal.org/gdal_grid.html


Only top voted, non community-wiki answers of a minimum length are eligible