geotiff

Python 3: How to change image data in GDAL?

不想你离开。 提交于 2019-12-06 00:34:57
I have a GeoTIFF image that contains a color table and a single raster band with 8-bit table keys, and that uses LZW compression, that I load with gdal.Open . I also have a numpy array containing 24-bit RGB-values (for a blurred version of the image), corresponding to three 8-bit raster bands. I need to substitute these three raster bands for the raster band that is currently in the image, and then save the image (preferably as a new file if possible). How do I do that? I would like to keep the data in the numpy array in RGB form, so I would like to end up with three raster band instead of one

How do I open geotiff images with gdal in python?

ぐ巨炮叔叔 提交于 2019-12-04 23:08:44
I am trying to run the following code: from osgeo import gdal import sys # this allows GDAL to throw Python Exceptions src_ds = gdal.Open( "fused.tif" ) src_ds.show() But I receive the following error: Traceback (most recent call last): File ".../gdalopen1.py", line 5, in module src_ds.show() AttributeError: 'Dataset' object has no attribute 'show' Why does this happen? You have already opened the dataset, as Spacedman answered. GDAL is not a visualization library (at its core). You can read the data with: data = src_ds.ReadAsArray() And then pass it on the your favourite plotting library.

TIFFReadDirectory Warnings when reading GeoTiff with QPixmap::load( )

我怕爱的太早我们不能终老 提交于 2019-12-04 11:05:32
I have a geotiff file which I am loading into a QPixmap with QPixmap::load( ). I get the following warnings printed to the console a bunch of times. However, direct use of libtiff opens it without warnings. Any ideas on how to alleviate these unsightly warnings in QT? TIFFReadDirectory: Warning, foo: unknown field with tag 33550 (0x830e) encountered. TIFFReadDirectory: Warning, foo: unknown field with tag 33922 (0x8482) encountered. TIFFReadDirectory: Warning, foo: unknown field with tag 34735 (0x87af) encountered. TIFFReadDirectory: Warning, foo: unknown field with tag 34736 (0x87b0)

Exception while using GDAL in C#

痞子三分冷 提交于 2019-12-04 00:17:15
问题 I started to use gdal_csharp dll in my application and read a geotiff file. but it says: The type initializer for 'OSGeo.GDAL.GdalPINVOKE' threw an exception. it's my code string fileName = @"/path to geotiff file"; OSGeo.GDAL.Dataset DS = OSGeo.GDAL.Gdal.Open(fileName, OSGeo.GDAL.Access.GA_ReadOnly); can anyone help? Edit: I have these dlls This is the full error message: It says that cannot load gdal_wrap . But when I'm going to add that dll to my application the below message is shown: 回答1

GTiff mask with shapefile in python with gdal, ogr, etc

僤鯓⒐⒋嵵緔 提交于 2019-12-03 13:40:36
问题 OK, After a bit of fiddling, I've tweaked a script from the site hyperlink in the second comment line. The purpose of the script is to clip/mask a LARGE raster (i.e. that cannot fit into a 32-bit Python 2.7.5 application) in GTiff format with a shapefile with multiple polygons (each with a "Name" record) and save the clipped rasters into a "clip" sub-directory, where each masked grid is named after each polygon's "Name". Like the original script, it assumes that the GTiff and shapefile are in

R: Write RasterStack and preserve layer names

不羁岁月 提交于 2019-12-03 08:52:12
问题 I have a raster stack, stk , consisting of three raster images in R. Here is a simple example # set up a raster stack with three layers > library(raster) > r <- raster(nrows=10,ncols=10) > r[] <- rnorm(100) > stk <- stack(r,r,r) # layer names are set by default > names(stk) [1] "layer.1" "layer.2" "layer.3" I assign names to the raster layers: # set layer names to "one", "two" and "three" > names(stk) <- c('one','two','three') > names(stk) [1] "one" "two" "three" When I write the RasterStack

Read elevation using gdal python from geotiff

此生再无相见时 提交于 2019-12-03 07:54:43
问题 I am loading a geotiff file using GDAL. I have managed to read the coordinates X,Y but not the elevation. Has anyone worked on a similar case before ? Regards, 回答1: If you'd like the read all of the elevation values into a numpy array, you'd typically do something like this: from osgeo import gdal gdal.UseExceptions() ds = gdal.Open('test_data.tif') band = ds.GetRasterBand(1) elevation = band.ReadAsArray() print elevation.shape print elevation elevation will be a 2D numpy array. If you'd like

How to use GDAL to create geotiff from tiff and 4 corners latitude and longitude [closed]

这一生的挚爱 提交于 2019-12-03 07:46:01
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I have an image (map) without geo data in TIFF format. I need to get GeoTIFF file from my image. I have latitude and longitude for each corner of my map. How can I add my geo data to my image in Google spatial refence to get geotiff? I know that GDAL can help me with that. Can anyone help me build a command 回答1:

GTiff mask with shapefile in python with gdal, ogr, etc

久未见 提交于 2019-12-03 03:40:36
OK, After a bit of fiddling, I've tweaked a script from the site hyperlink in the second comment line. The purpose of the script is to clip/mask a LARGE raster (i.e. that cannot fit into a 32-bit Python 2.7.5 application) in GTiff format with a shapefile with multiple polygons (each with a "Name" record) and save the clipped rasters into a "clip" sub-directory, where each masked grid is named after each polygon's "Name". Like the original script, it assumes that the GTiff and shapefile are in the same projection and overlap correctly, and it processes ~100 masks/sec. However, I have modified

R: Write RasterStack and preserve layer names

谁都会走 提交于 2019-12-02 22:55:45
I have a raster stack, stk , consisting of three raster images in R. Here is a simple example # set up a raster stack with three layers > library(raster) > r <- raster(nrows=10,ncols=10) > r[] <- rnorm(100) > stk <- stack(r,r,r) # layer names are set by default > names(stk) [1] "layer.1" "layer.2" "layer.3" I assign names to the raster layers: # set layer names to "one", "two" and "three" > names(stk) <- c('one','two','three') > names(stk) [1] "one" "two" "three" When I write the RasterStack to a GeoTiff (multilayered) using: writeRaster(stk,"myStack.tif", format="GTiff") The layers are