Hot answers tagged

5

I have solved the problem. When generating VRT with GDAL I did not use full path for Sentinel2 xml file. This is fine for using gdal_translate etc but causes an error inside PostGIS as full path is required both to the VRT and inside it. Wrong way to generate VRT that will be used as out-of-db raster in PostGIS: gdal_translate -of VRT SENTINEL2_L2A:...


5

It is possible if you convert your raster to a vector layer. Quick example, starting from this classification raster: Use Raster > Conversion > Polygonize to convert it to a vector layer: If you want to create points over a whole class (and not over each separate "patch"), use the Vector > Geometry Tools > Singleparts to Multiparts tool. ...


3

To cut an image (tif file) by using GDAL python library, and without gdalwarp utility, you need to find row and column raster indexes of top point [p1=(minX, maxY)] and bottom point [p2=(maxX, minY)]. The formulas, based in your code, are: i1 = int((p1[0] - xOrigin) / pixelWidth) j1 = int((yOrigin - p1[1] ) / pixelHeight) i2 = int((p2[0] - xOrigin) / ...


3

I would check this one which we have helped creating.


2

I think I may have figured it out. If one resets the Nodata value in the original files to -9999 with: gdalwarp -dstnodata -9999 tmean1_16.tif tmean1_16_error999.tif and then uses gdalmerge specifying both the input nodata value and the output nodatavalue: gdal_merge.py -v -n -9999 -a_nodata -9999 -o tmean1_06_16.tif tmean1_06_error999.tif ...


2

This is one of the most common GDAL/OGR Python Gotchas: A dataset is only written to disk after it is closed. Closing a dataset happens when it goes out of scope. This can be done in a number of ways and one of the following needs to be appended to the end of your script. data_out = None data_out = "some new value" del(data_out) There are libraries ...


2

Thats because you are running it from the processing toolbox. Don't know why it happens, but it happens for me too. Try going: Raster (menu at top of the screen) > Projections > Warp You should see the pencil button and be able to edit the GDAL code


2

You need to use the -dstalpha option to gdalwarp e.g.: gdalwarp -cutline INPUT.shp -crop_to_cutline -dstalpha INPUT.tif OUTPUT.tif This will add an alpha band to the output tiff which masks out the area falling outside the cutline. P.S. duplicate question


2

I think all you need to do is reproject it using: gdalwarp -co TILED=YES -co COMPRESS=DEFLATE -t_srs EPSG:3857 newImage.tif image.tif and then tile it: gdal2tiles.py newImage.tif If your file is very large it make take a while.


2

There is no fault in the data or python script. QGIS's default for opening a raster dataset looks for a minimum and maximum value to provide band rendering. However, this dataset contains a single value. Within QGIS's layer properties style menu by setting both the Min and Max values of the dataset to the single dataset value and selecting "No enhancement"...


2

Your ArcGIS python is the system default. So when you run a python script without specifying which python to use, the ArcGIS one is used. Don't upgrade the ArcGIS numpy, you can break arcpy. You can run gdal_calc.py using the Anaconda python using something like path\to\anaconda\python path\to\gdal_calc.py etc... If you don't want to do this every ...


2

This can be achieved with the help of GDAL's Virtual Raster Format. With this you can essentially skip the step of creating one giant DEM. The VRT will be handled by GDAL like a giant, merged DEM but is just a small XML file containing the file paths for each tile as well as some metadata. This can then be fed to gdalwarp together with a bounding box or a ...


1

I suppose that your image is some of the the 4-band products by Airbus DS: http://www.intelligence-airbusds.com/en/4951-which-spectral-mode-do-i-choose Gdal2tiles is made for splitting common, visual images into png tiles. Such images use 8 bits per band and they have one band (greyscale), 3 bands (red-green-blue) of 4 bands (reg-green-blue + alpha). I ...


1

1) I just don't know how to convert .geojson file to .shp. This is a one of the bases of ogr Python. If you have a geometry, it is very easy to convert it to a shapefile # geojson is GeoJson Polygon from osgeo import ogr output = "geojson.shp" driver = ogr.GetDriverByName('ESRI Shapefile') if os.path.exists(output): driver.DeleteDataSource(output) ...


1

WKT is only a text markup language for representing vector geometry, therefore you cannot convert 3D WKT to 2D (= text to text), you need to change the geometry The problem with ogr is that it seems that all the geometries are 3D by defaut 1) Creation of a 2D point with ogr point = ogr.Geometry(ogr.wkbPoint) # 2D point point.AddPoint(1198054.34, 648493.09)...


1

There are now Python modules easier to use for that, as rasterio Rasterio employs GDAL to read and writes files using GeoTIFF and many other formats. Its API uses familiar Python and SciPy interfaces and idioms like context managers, iterators, and ndarrays. Therefore from Masking raster with a polygon feature in Rasterio Cookbook import rasterio ...


1

GDALinfo is a function in rgdal, and unless you compiled rgdal yourself against that installation of GDAL it won't have HDF4 - presumably you have the CRAN Windows binary, which isn't built with HDF (and some others). gdal_translate is not a function in rgdal, but you don't say what package/s you are using, so I don't know what that is (gdalUtils?). ...


1

You might run into a problem with the antipodal point of the projection. If you clip your raster to the area of validity (that is Europe), it works: gdal_translate -projwin -26 75 44 28 -of GTiff bluemarble.tif bluemarble-Europe.tif gdalwarp -overwrite -s_srs EPSG:4326 -t_srs EPSG:3035 -of GTiff bluemarble-Europe.tif bluemarble-3035.tif You might take ...


1

I just had this same problem. Including the full path to gdal_calc.py was only part of the solution for me. Using Spyder (Anaconda) with Python 2.7, I had to include the statement: os.system('python path\to\anaconda\python path\to\gdal_calc.py -A filename -B filename --outfile=out.tif --calc=(A+B)') Also note that if using a numpy function in the --calc ...


1

I seem to have resolved one issue, but another still persists so I will ask in another question. I think there were conflicts with 32-bit and 64-bit installs. Since ArcGIS runs python in 32-bit and I am on a 64-bit machine, initially, I assumed I would install the 64-bit builds for GDAL. When I installed the 32-bit versions and their python binaries, ...


1

It's actually much simpler than what you've got going on there. ogr2ogr outputShapefile.shp input.kml Of course you can also use other option to specify srs etc. for example I work alot with a non standard crs, Lowrance Mercator Meter, so I use: ogr2ogr -t_srs "+proj=merc +a=6356752.3142 +b=6356752.3142 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=...


1

It's been a few months since I posted this. @michael-miles-stimson suggested that the correct way to do this would be to sample points along each edge of the bounding box, project them, then build an encompassing bounding box on those points. The drop-in Python/GDAL code below does this and allows you to select the number of interpolating points you'd like ...


1

I struggled with this too! I managed to solve the problem ogr2ogr -f MSSQLSpatial "MSSQL:server=Servername\SQL2012;database=DatabaseName;UID= username;PWD=password" C:\Pathto\shape.shp All you need to do is get rid of the [] and it should work...Hope this is still applicable to you.Just to show you I had the same issue here is a screensht of multiple ...


1

Gdal_calc.py manual http://www.gdal.org/gdal_calc.html has an example that might work for you: set values of zero and below to null gdal_calc.py -A input.tif --outfile=result.tif --calc="A*(A>0)" --NoDataValue=0


1

You have installed QGIS with ubuntugis support. https://launchpad.net/~ubuntugis/+archive/ubuntu/ubuntugis-unstable/+packages?field.name_filter=&field.status_filter=published&field.series_filter=trusty reveals that they only have GDAL 1.11.2 for trusty. The ubuntugis stable ppa does not offer a newer version for trusty either. They offer however ...


1

From memory, the RAT/colour table for a tif is either stored in a .dbf or .aux.xml file. You could try deleting those if they exist.


1

My solution was to run a /usr/bin/gdal_calc.py -A input.tif --outfile=output.tif --calc="A*1" --NoDataValue=0 --co="compress=lzw"


1

In document https://trac.osgeo.org/gdal/wiki/UserDocs/GdalWarp the difference is explained in section "Will increasing RAM increase the speed of gdalwarp?" -wm sets the memory reserved for working buffers of gdalwarp, gdal_cachemax is used for setting the size of i/o buffers. There are more technical details in the section "Warp and Cache Memory: Technical ...


1

It looks like GDAL currently does not support georeferencing information in that format: Long Format Name Code Creation Georeferencing Maximum file size Compiled by default ... TerraSAR-X Complex SAR Data Product COSAR No No -- Yes ... The documentation on that format is pretty scarce ...


1

Fixed by downgrading gdal to 1.10.1. Would be nice to know why /vsicurl/ isnt working in more recent versions of gdal, or perhaps I'm doing something wrong.



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