Tag Info

Hot answers tagged

3

Using rasterio: import rasterio with rasterio.open('sample.tif') as r: ar = r.read() The ar array has 3-dimensions [band, row, col]


3

You can create a local CRS with an oblique mercator projection, and transform the data with gdalwarp and gdal_translate into it. See my advice here: Using customized Coordinate System for Archaeological site data This should work with 16-bit or grayscale data the same way. Paletted colours shoud be expanded to RGBA in advance. UPDATE Using QGIS, ...


2

would add as comment, but a bit long - in case you wanted to use gdal/ogr within python - something like this might work (hacked together from some other code i had - not tested!) This also assumes that rather than finding the nearest raster pixel to a polygon centroid, you simply query the raster at the xy of the centroid. i have no idea what the speed ...


2

This should get you going. The raster values are read using rasterio, and pixel centre coordinates are converted to Eastings/Northings using affine, which are then converted to Latitude/Longitude using pyproj. Most arrays have the same shape as the input raster. import rasterio import numpy as np from affine import Affine from pyproj import Proj, transform ...


2

By reading this GDAL ticket http://trac.osgeo.org/gdal/ticket/4977 it should be possible to flip a GeoTIFF by using a negative pixel size in ModelPixelScaleTag. On Y-axis this would mean positive pixel size for GDAL. However, as you can read from the ticket, this trick does not work for you and even if it works you should still place the origin to lower ...


2

Rather simple method is to write a new world file (.tfw) which contains rotation parameters. You can make such with OpenOffice Calc, for example. If you have a GeoTIFF file which contains reoreferencing info as stored into the image tag you must clear the geotiff tags and create a baseline tiff to start with. It can be done with gdal_translate: ...


2

The fourth value is alpha (i.e. RGBA), which you can ignore. The four value structure is expected. You can read the colour tables into native lists/dicts with GDAL. from osgeo import gdal gdal.UseExceptions() ds = gdal.Open(fname) band = ds.GetRasterBand(1) arr = band.ReadAsArray() ct = band.GetColorTable() # index value to RGB (ignore A) i2rgb = ...


1

The gdal.Dataset class also has a ReadAsArray method which will read multiband rasters into an ndarray. For example: >>> ds=gdal.Open('multiband.tif') >>> print ds.RasterCount, ds.RasterYSize, ds.RasterXSize 4 256 256 >>> nda=ds.ReadAsArray() >>> print nda.shape (4, 256, 256) Note: the code in your question is not ...


1

Tiff doesn't support 'transparent' like GIF. You need to set NoData value, open the raster properties dialog in ArcCatalog (right click on image): In the highlighted line click on the Edit.. button: And enter the value for the background. Then press OK and OK to dismiss both dialogs. Now GeoServer (and ArcMap and QGIS and GRASS...) should know that the ...


1

Mark's answer is great! It really helped me out. Here's a slightly modified version of Mark's code. The major difference is that this code does not rely on the java.awt.image package to compute the image size, number of bands, or pixel values. Instead, it uses the GeoTools Coverage API. import org.geotools.coverage.grid.io.GridCoverage2DReader; import ...


1

This example may help you http://bl.ocks.org/jorgeas80/4c7169c9b6356858f3cc. Using Maps API


1

Not terribly different from the first answer - but I thought I would post this to, if nothing else, spread knowledge about the conversion scripts that were made available. As part of their NED data delivery changes in 2013, the National Map provided a set of file conversion scripts. See this script: GDAL_IMG_2_GeoTIFF.bat c:\temp\input.img The result is ...



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