New answers tagged

0 votes

How to get the Minimun and Maximum zoom level by coordinates

The maximum zoom level is computed by the pixel size of the original data. It happens around line 172 in the Python script https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/...
  • 53.9k
0 votes
Accepted

Alter cell size of gdal_grid command

See the documentation: -tr <xres> <yres> Set output file resolution (i.e. the pixel size). Note you need to specify -txe and -tye as well. Or specify a larger -outsize: -outsize <...
  • 54.1k
3 votes
Accepted

Using GDAL/OGR to remove a specific layer from a geopackage

You can do it with ogrinfo by using the -sql option. The usage is documented in https://gdal.org/drivers/vector/gpkg.html Starting with GDAL 2.2, the “DROP TABLE layer_name” and “ALTER TABLE ...
  • 53.9k
2 votes

GDAL warp in C++

(This should be a comment, but too long and too formatted.) NB: This is using a Swift wrapper for GDAL, so not actual C++, but hopefully it will give you some idea of how I use GDALWarp(). In ...
0 votes

ogr2ogr conversion error - Can't create fields of type Binary on shapefile layers

Just as the error says, you cannot save Binary type on shapefiles. You need to find the data and select "Use Binary (Blob)" or deselect the field from the options
  • 101
0 votes

Using ogr2ogr to convert GML to shapefile in Python?

I found it simpler to use OGR CopyLayer which I found here. ds = ogr.GetDriverByName("GPKG").CreateDataSource(self.output_path) sf1 = ogr.Open(src_ds) sf_lyr1 = sf1.GetLayerByIndex(0) ds....
  • 645
0 votes

How to use gdal to generate overview tiles from existing zoom level 21 tiles?

I ended up using tiletool to achieve this
  • 31
0 votes
Accepted

Expressing raster rotation with GDAL geotransform (python)

To my understanding this is actually an issue with QGIS, and there is an open issue related to providing better support for rotated rasters. See also: https://github.com/qgis/QGIS/issues/22012 GDAL ...
  • 506
1 vote
Accepted

Equivalent of gdal_translate's "-a_scale"-option in pythons gdal.Translate?

Maybe a workaround could be to read the source code of gdal_edit.py https://gdal.org/programs/gdal_edit.html from https://github.com/OSGeo/gdal/blob/master/swig/python/gdal-utils/osgeo_utils/gdal_edit....
  • 53.9k
1 vote
Accepted

Detecting empty TIFFs

so using the flag -stats with gdalinfo I can get STATISTICS_VALID_PERCENT which is more than enough.
  • 21
0 votes
Accepted

How to extract the elevation from GeoTIFF at an arbitrary point in latitude/longitude?

I recommend first resampling the raster to 10 meters, then extract the points. Step 1: Resample raster to 10 meters https://corteva.github.io/rioxarray/stable/examples/reproject.html https://rasterio....
  • 6,151
2 votes
Accepted

Use WFS feed in online notebook with ogr2ogr

TL;DR in Deepnote: !apt update !apt install -y gdal-bin I have prepared an example notebook in Deepnote, showing GDAL installation in default Deepnote environment. Feel free to duplicate and use in ...
2 votes

Convert huge TIFF to JPEG using GDAL

gdal_translate -if GTiff -of JPEG input_file.tif output_file.jpg
0 votes

GDAL Script Failing since GDA2020 Shift - unable to find EPSG 7855

I figured out the environment path variables were pointing to the Miniconda GDAL folder, not the Intramaps one. I updated it and it works. Not sure when or how this changed but it works now thanks.
  • 103
0 votes
Accepted

NITF File, Pixel size calculate

That image is georeferenced by ground control points and it is not possible to tell the pixel size directly because the image is slightly rotated in EPSG:4326. I would warp the image into normal north-...
  • 53.9k
0 votes

Reduce file size when merging gpx files to GeoJSON file with GDAL ogr2ogr

I have now done it with simplify: OGR2OGR_PATH=/Library/Frameworks/GDAL.framework/Versions/3.2/Programs/ogr2ogr # Merge gpx files to geojson file and simplify for file in $SCRIPT_DIR/input/*.gpx; do ...
0 votes

Export vector layer in DXF with systematically metrical system unit?

I finally figured out what meant "edit the $MEASUREMENT and $INSUNITS variables in the header template". The header template is located here: C:\OSGeo4W\apps\gdal\share\gdal\header.dxf This ...
0 votes

Replacing nodata values by a constant using GDAL CLI tools

I was looking for an answer to this question, and went back to the documentation of gdal_calc.py here: https://gdal.org/programs/gdal_calc.html If you are using version 3.3 or newer, you can combine ...
0 votes

Converting lon/lat coordinates to pixel coordinates

You should modify your question because it sounds like you do not want individual image pixel coordinates, you want to extract out pieces of your image to make deep learning chips. ArcGIS Spatial ...
  • 7,492
0 votes

undefined reference to `TIFFDefaultStripSize@LIBTIFF_4.0'

In my case libtiff version not updated, I had to reinstall by sudo pacman -S libtiff
1 vote

Reduce file size when merging gpx files to GeoJSON file with GDAL ogr2ogr

Once you've done your appending, just convert the final file as ogr2ogr -f "GeoJSON" -lco COORDINATE_PRECISION=3 squashed.json \ mergedgpxfiles.geojson (change the value of ...
  • 2,997
0 votes

GDAL Script Failing since GDA2020 Shift - unable to find EPSG 7855

I had a try with GDAL 3.6.0dev from gisinternals.com and with GDAL 3.4.1 from OSGeo4W. Both can deal with EPSG:7855. What is your GDAL version? What do you get with this gdalsrsinfo command? ...
  • 53.9k
1 vote

GDAL: Reprojecting geotiff from LATLONG to UTM

If your desired UTM Zone is: north of the equator, use EPSG:32637 (WGS 84 / UTM zone 37N): gdalwarp -t_srs epsg:32637 test.tif test_utm.tif south of the equator, use EPSG:32737 (WGS 84 / UTM zone ...
  • 54.1k
1 vote
Accepted

Reading and storing 1st pixels from multiple rasters

List all rasters, convert them to arrays, stack them into one array, slice it: import os import numpy as np from osgeo import gdal_array rasterfolder = r'/home/bera/GIS/Diverse_GIS/random_rasters/' #...
  • 55.3k
2 votes
Accepted

WSG84 to WebMercator: missing raster data along ±180°

I worked out that my antimeridian problem was to do with the pixel size that I had specified: that resolution didn't quite give me the right extent. The solution was to define the extent and the ...
  • 41
0 votes

How do I load a Segp1 file into QGIS?

So as a follow-up to this question, according to this website (https://gdal.org/drivers/vector/index.html?highlight=segy) "The following drivers have been retired and moved to the https://github....
  • 1
1 vote

Reading multiple rasters in folder

Looks like a python problem. You can sort the list by the date like this, but it will only work if the files are named exactly like your example. So the date can be found by splitting at _ and T ...
  • 55.3k
0 votes

Any way to merge tifs with overviewsm or overvies alone

Depending on the target format that should be possible. See https://gdal.org/drivers/raster/gtiff.html. COPY_SRC_OVERVIEWS=[YES/NO]: (CreateCopy() only) By setting this to YES (default is NO), the ...
  • 53.9k
1 vote

NetCDF 500 metres shifted and unknown PCS

The geotransform of you GTiff describes the outer bounds of the dataset (and the pixels), while the coordinates in a netCDF refer to the pixel centers. So when you do this it should work. xOrigin = ...
  • 1,532
0 votes
Accepted

Using GDAL to extract Oracle raster

The Ordimage type has been deprecated for several releases and was finally removed from release 19c onwards. Ordimage is very different from Georaster. Georaster is designed to store and process geo-...
1 vote
Accepted

Atributes disapear when converting from tif to netCDF with gdal translate

gdal_translate (or gdal.Translate() in python) was not working because the tiff file was still "open" after I created and edited it with gdal. It works after adding file_tiff = None before ...
0 votes

How to read and plot multiple TIFF files in Colaboratory?

You can try automizing your method by creating two functions: one to open the image and obtain necessary info, and a second to plot. For example, from google.colab import drive drive = "/content/...
0 votes

"Exception: std::bad_alloc" when importing rasterio in QGIS

I had the same error and it didn't really come from rasterio but pyproj. Check this link: https://pyproj4.github.io/pyproj/stable/gotchas.html#internal-proj-error-sqlite-error-on-select In my case, ...
  • 21

Top 50 recent answers are included