Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
21 votes
1 answer
20k views

Scale 16 bit to 8 bit within range using GDAL

I am looking to scale a 16bit unsigned tiff image to an 8bit image using GDAL (OSGeo4W). However I want to constrain the pixel values so that they stay within the range of the 8bit imagery. What I ...
Ryan Garnett's user avatar
  • 9,549
21 votes
1 answer
21k views

Why close a dataset in GDAL Python?

I see quite often in Python GDAL code that people close datasets at the end of their script. Why does it makes sense to close a dataset in Python GDAL? Are there any consequences if I don't do it? ...
ustroetz's user avatar
  • 8,049
19 votes
3 answers
19k views

How do I change geotiff "no data" color to white/transparent rather than black?

I am preparing data for inclusion into a geonetwork node, where the maps are displayed via geoserver. The problem is that cells that have"no data" are displaying as black in the geotiff and I am ...
enmapping's user avatar
  • 522
19 votes
3 answers
7k views

Generating contours from DEM using GDAL?

We have just received a large set of DEMs at work and I would like to generate contours from them. The DEMs have a resolution of 1m and a size of 1kmx1km. Output from gdalinfo: Driver: AAIGrid/Arc/...
Nathan W's user avatar
  • 35k
18 votes
9 answers
12k views

how to overlay shapefile and raster?

I have a shapefile with polygons. And I have a global raster file. I want to overlay the shapefile's polygons onto the raster grid and calculate the mean raster value for each polygon. How can I do ...
andreash's user avatar
  • 741
18 votes
2 answers
16k views

ogr2ogr merge multiple shapefiles: What is the purpose of -nln tag?

The basic script in order to iterate recursively over sub-folders and merge all shapefiles into single one is: #!/bin/bash consolidated_file="./consolidated.shp" for i in $(find . -name '*.shp'); do ...
michael's user avatar
  • 1,809
18 votes
2 answers
7k views

Reprojecting WGS 1984 Web Mercator (EPSG:3857) in Python with GDAL

I am reprojecting rasters in python using GDAL. I need to project several tiffs from geographic WGS 84 coordinates to WGS 1984 Web Mercator (Auxiliary Sphere), in order to use them later in Openlayers ...
nadya's user avatar
  • 2,491
18 votes
3 answers
24k views

Calculate lat lon bounds for individual tile generated from gdal2tiles

I have multiple tile sources generated using gdal2tiles I'd like to present on the same map. So when presenting a tile I need to determine which source to serve it up from, checking against the bounds....
Gavin's user avatar
  • 525
17 votes
3 answers
18k views

What's the difference between gdalwarp and gdal_merge for mosaicing

I wanted to merge around 20 dem tiffs each around 100MB, and I used gdalwarp (I know about virtual file option): gdalwarp $(list_of_tiffs) merged.tiff However this command took very long time, and ...
zetah's user avatar
  • 843
17 votes
4 answers
19k views

Gdal: clipping a raster with another raster

I'm writing a simple utility to crop batches of multi-band geotiff raster files to the same (smaller) area. Using gdalwarp, I can easily crop a file using a single-polygon clipping shapefile: ...
Joe's user avatar
  • 435
15 votes
3 answers
3k views

OGR Info - Check for spatial index?

If we want to get information about a vector layer (shapefile for example) we could use ogrinfo: ogrinfo -so myshapefile.shp mylayer This returns a lot of pertinent information about the shapefile. ...
Jay Laura's user avatar
  • 4,493
15 votes
2 answers
5k views

Downloading raster data into python from postgis using psycopg2

I have raster data in a postgres table that I want to get into python as a numpy array. I am using psycopg2 to connect to the db. I am able to download the data but it comes back as a string (probably ...
Mayank Agarwal's user avatar
14 votes
3 answers
2k views

Why does simply opening a geopackage (gpkg) "modify" the file?

I'm really excited about transitioning to using geopackages instead of shapefiles, but I have one annoying problem. My datasets are synced with Box, and I'm working with a really large .gpkg file (3.2 ...
Casey's user avatar
  • 243
13 votes
3 answers
20k views

Convert an ASCII grid file to GeoTIFF using Python?

I have a ASCII grid raster format file. For example: ncols 480 nrows 450 xllcorner 378923 yllcorner 4072345 cellsize 30 nodata_value -32768 43 2 45 7 3 56 2 5 23 65 34 6 32 54 57 34 2 2 54 6 35 45 ...
voimak's user avatar
  • 273
13 votes
5 answers
16k views

Gdal: how to get the max and min altitudes of my topographic raster?

Given a .tiff topographic raster image. How to get the altitudes of the highest and lowest point/pixel ?
Hugolpz's user avatar
  • 2,673
13 votes
6 answers
47k views

Ogr2ogr: ERROR 1: PROJ: pj_obj_create: Cannot find proj.db

I start using GDAL 3.0.0 using conda build. I successfully installed GDAL on my laptop (Windows 10) and I am trying to ingest MapInfo tab file into Elasticsearch index. I understood that I have to ...
Praveen Kumar's user avatar
13 votes
2 answers
3k views

Piping data to ogr2ogr

Is it possible to directly pipe data to ogr2ogr? I'm trying to curl a GeoJSON file and pipe it to ogr2ogr to covert it to another format. Without using a pipe, I was able to achieve this by first ...
jczaplew's user avatar
  • 1,208
13 votes
2 answers
2k views

Can I preserve a fading alpha layer when mosaicing images with gdal?

I am mosaicing some images with gdal and would like to improve the final result by using a fading / gradual alpha layer towards the edge of each image to remove the sharp edges in the middle of the ...
jeremyeastwood's user avatar
13 votes
4 answers
27k views

Generating random coordinates in multipolygon in Python?

How to generate random points in multi-polygon using geojson in python ? thus far I found a class in JavaScript named : randomPointsOnPolygon(numberOfPoints, polygon) but I need to use something ...
Sadeq Sepehrnoush's user avatar
12 votes
2 answers
11k views

Determining if shapefile and raster overlap in Python using OGR/GDAL? [closed]

I am building a script in python using OGR/GDAL. I have a set of shapefiles and a set of GeoTiff raster files. I would like to have my script ignore shapefiles if they do not intersect with the ...
JFerg's user avatar
  • 347
12 votes
3 answers
4k views

Why is GDALPolygonize so much slower than ArcGIS Raster to Polygon?

I am attempting to polygonize a raster using GDALPolygonize() in a Python script. The script began polygonizing yesterday at 5pm and is still polygonizing now at 9:30 am. I have no clue how far ...
Brian's user avatar
  • 4,229
12 votes
2 answers
10k views

How to install GDAL and QGIS on a Raspberry Pi?

I would like to run GDAL QGIS on Raspberry Pi to act as an affordable GIS processing engine. The plan is to buy about 50 Pis. Does anybody have any links or information on installing and running GDAL ...
If you do not know- just GIS's user avatar
11 votes
1 answer
4k views

Differences between OSGEO GDAL and GDAL python bindings?

Question I'm trying to figure what are the differences, and of course, what is the best solution to use, between two python3 bindings: GDAL, imported as import gdal OSGEO.GDAL, imported as ...
swiss_knight's user avatar
  • 10.9k
11 votes
1 answer
33k views

Using gdal.Warp() and gdal.warpOptions() of GDAL Python API

According to http://gdal.org/python/ the gdal.Warp() and gdal.WarpOptions() can be used to warp image from HDF to GeoTIFF format by geolocation arrays, but there is no any example. It would not run, ...
user7177639's user avatar
11 votes
1 answer
4k views

How to edit the metadata for individual bands of a multiband raster, preferably with GDAL?

I created a multiband raster using the gdal_merge.py utility where each band represents a measurement from a different year: gdal_merge.py -o stack.tif -ot float32 -separate -a_nodata -9999 DEM_2012....
Charlie Parr's user avatar
  • 1,986
11 votes
2 answers
4k views

How to get FGDB support in GDAL 1.9 without compiling?

I was hoping that I could use the 'master' (nightly-build) version of QGIS to get fgdb support without compiliing (I'm not a developer and frankly have wasted days of productive time trying to get ...
afwatl's user avatar
  • 553
10 votes
2 answers
13k views

Optimizing Python GDAL ReadAsArray

I am using the GDAL ReadAsArray method to work with raster data using numpy (specifically reclassification). As my rasters are large, I process the arrays in blocks, iterating though each block and ...
ssast's user avatar
  • 327
10 votes
1 answer
3k views

Importing GDAL from Python window of ArcGIS for Desktop?

I am trying to run some Python code using the Python window in ArcGIS 10.1 that uses both the arcpy and gdal modules. However, when I try and import the gdal module I get an error: ImportError: No ...
robintw's user avatar
  • 4,014
10 votes
3 answers
5k views

getting dxf files out of PostgreSQL

I've successfully loaded a bunch of shapefiles into a PostGIS database. I would like to be able to retrieve specific geometry and layers as dxf files based on SQL queries. I'm using PostGIS, GDAL, ...
BenjaminGolder's user avatar
9 votes
1 answer
5k views

Rasterize shapefile using another raster's size and resolution

Rasterizing a vector (shp) I face the following problem: I want my output file (the rasterized vector) to have the same resolution and dimensions as an existing raster. If I understand the interface ...
Flo's user avatar
  • 644
9 votes
2 answers
15k views

Inserting nodata value using GDAL?

I'd like to edit the nodata values in several raster files, but big number of these file doesn't have any nodata value defined, there is nothing to edit. I'v tried the gdal_translate -a_nodata ...
STO's user avatar
  • 337
9 votes
1 answer
4k views

Relative path not working in QGIS with Google Drive?

I have a qgis file, referring to a few shp files, saved on a google drive folder which is synced across two computers using different OS, one is Mac OS X, the other Windows 8. So, the absolute path of ...
oat's user avatar
  • 407
9 votes
1 answer
32k views

Python GDAL: Save array as raster with projection from other file

I have an array of data, and for each datapoint I know the latitude and longitude. I'd like to save it as a GTiff with the same projection as other rasters I have. This is what I've tried so far, but ...
EddyTheB's user avatar
  • 1,935
9 votes
3 answers
7k views

Per-pixel (statistical) calculations on a raster stack using GDAL

In R, it's relatively trivial to perform per pixel calculations based on a raster stack (e.g., get std.dev for each pixel on a 12 layer GeoTIFF). Unfortunately, the speed is less than desirable when ...
Prophet60091's user avatar
9 votes
1 answer
6k views

Creating geopackage from multiple raster files?

I've got a bunch of geotiffs' that I would like to combine into a single geopackage. Using QGIS, I've only managed to export one layer as a geopackage. I've tried merging the layers and created a ...
Gustav's user avatar
  • 91
9 votes
2 answers
29k views

Installing GDAL on CentOS?

I'm having issues with installing GDAL on a fresh install of Centos7 using the ELGIS repo. Here's my commands and output: sudo rpm -Uvh http://elgis.argeo.org/repos/6/elgis-release-6-6_0.noarch.rpm ...
Alexander Rolek's user avatar
9 votes
3 answers
13k views

Turning shapefile into mask and calculating mean

I have been using Python to process huge arrays stored as NetCDF files. I would like to calculate the mean of an area defined by a shapefile. I have just installed GDAL but if there are other tools I ...
questions's user avatar
  • 107
9 votes
1 answer
6k views

Reading raster files by block with rasterio?

I find rasterio much easier to use that plain ogr/gdal, so I'd prefer using it. However, I need to process large rasters, so reading rasters by block as explained in the Python GDAL course is ...
Pavel V.'s user avatar
  • 1,517
9 votes
2 answers
2k views

How can I crawl directory tree and change Mxd relativePaths to true?

I have a large number of project folders where each project folder can have many subfolders. These subfolders can contain mxds, shapefiles, personal gdb's and fgdb's. In many cases the user forgot ...
Kirk Kuykendall's user avatar
9 votes
1 answer
3k views

Should i use jp2 or cloud optimized geotiffs to efficiently access small windows from Rasters on S3

I am building a system where we have a lot of large rasters (Sentinel-2 bands) stored in S3. A lot of this data is stored in our own buckets so we can store whatever format we find most usable. I ...
the_cheff's user avatar
  • 241
9 votes
2 answers
13k views

GDAL and Python - Don't print GDAL Error messages

According to the GDAL Python Documentation, GDAL functions do not raise exceptions or errors but do print errors to the console via stdout and stderr. I have some code in my script that calls ...
Brian's user avatar
  • 4,229
9 votes
3 answers
11k views

Displaying netCDF data with correct CRS?

I successfully extracted some data from a netCDF file with a single variable E. (the original file was taking ages to load). I used the following code to extract the data: ncks -d lon,24.,36. -d lat,...
mmfl's user avatar
  • 91
9 votes
2 answers
7k views

Creating image with specific latitude/longitude positions using GDAL?

I have an ASCII file with latitude, longitude, and data_val in the following format. 35-13.643782N, 080-57.190157W, 118.6 ... I have a GeoTiff image file, and I can easily view it. I want to place ...
Brad Walker's user avatar
8 votes
3 answers
6k views

Viewshed Analysis With GDAL

I am looking to perform a simple (one observer location) viewshed analysis on a standard DEM using GDAL (either python or .NET bindings). I have searched, but haven't found any readily available ...
user890's user avatar
  • 5,733
8 votes
4 answers
3k views

Proj.4/GDAL/QGIS Transformation between CRSs that are defined the same

I'm helping to ensure that open source software can handle Australia's new datum appropriately, see ICSM's website for details on the GDA2020 project. Now, QGIS has already got the definitions of ...
Alex Leith's user avatar
  • 13.5k
8 votes
1 answer
8k views

Re-project raster image from Mercator to Equirectangular

I have a raster image of the world map in Mercator projection, square 1:1 format. I want transform the image into an Equirectangular projection accurately. I assumed from my research that GDAL would ...
kinkersnick's user avatar
8 votes
2 answers
7k views

Issue Trying to create Zonal Statistics using Gdal and Python.

I am trying to create zonal statistics using Python and Gdal. I have a polygon shapefile and a raster file, and in order to do so, I am using a piece of code I found in StackExchange. The raster and ...
Doon_Bogan's user avatar
8 votes
1 answer
3k views

Write projected array to NetCDF file, best practice

I'm trying to write projected rasters to NetCDF files including projection information in a way that GDAL can understand it. I found two ways to achieve that: By adding the geotransform as an ...
Loïc Dutrieux's user avatar
8 votes
4 answers
13k views

Replacing NaN pixel values in GeoTIFF using GDAL?

I was wondering if there is a easy way (GDAL) to replace GeoTIFF pixels that are -nan with a different value (e.g. 100)? I tried gdal_calc.py -A my.tif --outfile=result.tif --calc="A-(A==-nan)*(-...
tinlyx's user avatar
  • 11.2k
8 votes
2 answers
10k views

Reading Esri File Geodatabase (FileGDB) with OGR?

I have a file ending with *.gdb. I don't know what it actually is. I also don't know what to expect inside the file. I am trying to access it with ogr. I tried with ogrinfo: ogrinfo test.gdb ERROR ...
ustroetz's user avatar
  • 8,049

1
3 4
5
6 7
22