Tag Info

New answers tagged

0

I am using gdal_grid to generate rasters from point data using Python. Right now I am dealing with the same issue as you do, so I am testing as much as I can before taking my chance with another library. My advice would be to use the options for multiple cores and as much cache as you can give. --config 'NUM_THREADS=ALL_CPUS GDAL_CACHEMAX=2000' The gdal ...


0

I just ran into this same/similar problem. What fixed my problem was to make the image large enough for the gdal2tiler to make proper tiles. I made my image evenly divisible by 256px, so this may have be necessary as well. I initially had a 16,128px wide image and was trying to create zoom levels between 0-7. The gdal2tiler worked as expected when I tiled ...


2

You should read the whole thread of http://thread.gmane.org/gmane.comp.gis.gdal.devel/38725. Test image was an aerial photo (424 MB) and methods with best compression were: Lossless JPEG2000 (197 MB) DEFLATE compression with PREDICTOR=2 (280 MB) LZW compression with PREDICTOR=2 (307 MB) However, your images seem to suit very well for LZW compression and ...


1

You can see the source code for a gdalinfo java implementation here - https://svn.osgeo.org/gdal/trunk/gdal/swig/java/apps/gdalinfo.java The polygonize function should be available in the java bindings, you may look at the source of gdal_polygonize.py to see how it's used - http://svn.osgeo.org/gdal/trunk/gdal/swig/python/scripts/gdal_polygonize.py


1

I had a similar problem. PostGIS wanted libgdal1 and QGIS wanted libgdal1h. The problem was that I had my Repo for QGIS set to the main QGIS site, and Postgresql set to their main site. Postgresql kept wanting to upgrade past what QGIS wanted. Finally something gave and I ended up with circular conflicts between the two. I ended up backing up my ...


0

you can use gdalwarp for that, with the -tr parameter to set the output pixel size. For example, with input cell size of 10 m resampled to 50 m (so 25 times smaller in number of pixels) gdalwarp -tr 50 50 -r average raw_image.tif resampled_image.tif note that you can also use gdal_translate, but then with less control on the resampling method but the ...


0

You can get all the supported coordinate reference system (CRS) used by many GIS applications both on the the desktop environment (ArcGIS, QGIS, Python, GDAL command line, GRASS etc. ) and web, from Spatial Reference. A quick search for MODIS Sinusoidal from the website, will show you all the supported CRS example as shown below: Well Known Text as HTML ...


0

Thanks a million for the prompt reply SS_Rebelious! My late reply was from trying different approaches to try and make sure I am using the same compiler I thought I was building all the libs I used. Maybe you can help me? I have tried importing the below into my win32 application using 2010 express to try and make sure I'm using only 32bit logic & ...


0

Use affine to load the world file, translate it from center to corner reference, and reorder the coefficients for GDAL. import os import affine from osgeo import gdal gdal.UseExceptions() ds = gdal.Open(input, gdal.GA_Update) gt = ds.GetGeoTransform() if not gt: # guess the name of the world file, if it exists inputwf = os.path.splitext(input)[0] + ...


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 ...


0

Try the instructions here.Although the samples are for C#,you can make use them in VB.NET with relative ease.


1

I am an old school dgn user - to use a .dgn file in any other program other than microstation - it must first be exported as a .dxf http://www.gdal.org/drv_dxf.html


0

Forgot to answer this question: The GDAL geotransform matrix lacks the possibility to shift x/y directions (only scaling and rotation can be done). The solution was to create a custom geomtransform in ArcObjects, which adds additional transformation parameters to the aux.xml file. The grid then rotated/shifted/scaled as dersired. Unfortunately I don't ...


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: ...


1

gdal_translate is able to extract single bands: gdal_translate -b 1 in.tif out1.tif gdal_translate -b 2 in.tif out2.tif gdal_translate -b 3 in.tif out3.tif gdal_translate -b 4 in.tif out4.tif Raster -> Conversion -> Translate will create a gdal_translate command line, which you can edit to specify the band you want.


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, ...


3

Yes, using the SetGeoTransform method. The Geographic Transform defines the origin of the raster in the upper left hand corner, as well as the cell size and the rotation in the x and y direction for the cells in this format: geo_transform = (x top left, x cell size, x rotation, y top left, y rotation, negative y cell size) Or in the example you've ...


0

I think the question was whether you can read from postgis raster tables WITHOUT gdal drivers enabled. As all things Python, you can! Make sure you select your raster result as WKBinary: select St_AsBinary(rast)... Use the script below to decypher WKBinary into a python image format. I prefer opencv, because it handles arbitrary number of image bands, ...


4

It looks like GDAL is describing the outer edge of the 'origin pixel' and Arcmap is refering to the center of the origin pixel. If you add half the resolution of a pixel they'll match fine. This definition is often different with different software, it doesnt really matter, though you should know what you're looking at so you can take it into account. One ...


0

You could create a polygon geometry directly from the neatline polygon WKT using ogr.CreateGeometryFromWkt(), then rasterize using gdal.RasterizeLayer(). # http://gis.stackexchange.com/a/131250/2856 (cc by-sa 3.0 attribution required) import os from osgeo import gdal,ogr ogr.UseExceptions(True) outfn='PPA_1_neatline.tif' ds = gdal.Open('PAA_1.tif') cols = ...


0

Change your last line to: layer = QgsRasterLayer(file, baseName) file contains the full path to your raster file (e.g., /home/user/geodata/mypic.tif), while fileName, which you are passing as argument right now, only contains the name of the file (e.g., mypic.tif).


1

I believe that you have done everything right but the neatline is crappy. I checked the first coordinate of the neatline by using the formula for affine transformation from http://www.gdal.org/gdal_datamodel.html Xgeo = GT(0) + Xpixel*GT(1) + Yline*GT(2) Ygeo = GT(3) + Xpixel*GT(4) + Yline*GT(5) The GeoTransform parameters of your image are GT(0)= ...


1

Turns out in order to read the NEX climate data, I needed very specific versions of the HDF5 and netCDF libraries. I'm not sure which part of the combination was not working for me, since the hours I lost getting it to work was enough time debugging the problem. But I did codify the solution into ansible provisioning scripts. See the 'netcdf' role in the ...


1

Try using rasterio, which uses GDALFPolygonize on float arrays. import numpy as np import rasterio.features from affine import Affine from shapely.geometry import shape # triangular array ar = np.tri(5, dtype='f') print(ar) for shp, val in rasterio.features.shapes(ar, transform=Affine(1, 0, 0, 0, -1, 5)): print('%s: %s' % (val, shape(shp))) ...


0

Well, I did what user30184 suggested. And yes, it looks like the stripes are caused by cubic interpolation. Using the average resampling things look a lot better. But I still get a bit of stripes at some zoom levels. Not as strong as the ones obtained with cubic.


1

From section 10.13 of R for Mac OS X FAQ: When executing system commands (for example directly via system or indirectly via functions that call other programs such as install.packages) the locations in which the shell is looking for programs is governed by the PATH environment variable. That variable may be set differently for R started from an ...


1

It looks like there are some issues with the path variable, i.e. the shell opened by R doesn't know the path to the gdal binaries. There are two ways to fix this: Specifying the full path You can always use the whole path to gdalinfo in your system call to make it work: path <- "/path/to/gdal/bin/gdalinfo" system2(path, "--version") This may be the ...


1

I can't say why gdal picks the HDF5 driver with the NEX files on Ubuntu. It shouldn't as the NetCDF driver is tried before the HDF5 driver (the order that drivers are listed in gdalinfo --formats shows the order they are tried). You may not have HDF5 support on your Mac. If you did, you might come across the same issue. To workaround, you could try ...


0

You should add a CRS to the source data with gdal_translate or another way. The jpg raster has usually pixel coordinates from top left to the right and down, while GIS data like shapefiles have a coordinate system to the right and upwards. If your input data has a CRS, the output can have the same CRS, and both will align.


0

ELGIS requires EPEL (see https://fedoraproject.org/wiki/EPEL/FAQ#howtouse for EPEL). However I'm not sure that you really want to use ELGIS 6 on CentOS 7. Its intended for RHEL 6 / CentOS 6 / Scientific Linux 6. Instead, you probably just want to use EPEL for CentOS 7 for something like GDAL. EPEL 7 has GDAL 1.11.0, which isn't quite the latest, but is ...


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 = ...


3

rt_raster_to_gdal: Could not load the output GDAL driver As for the first error with ST_AsTIFF, you need to enable your GDAL drivers, which by default are not enabled for PostGIS 2.1. See the manual on ways to do this. For instance, I have an environment variable set up on a Windows computer with: POSTGIS_GDAL_ENABLED_DRIVERS=GTiff PNG JPEG GIF XYZ DTED ...


2

The basic syntax is similar to gdal_calc.py i.e. gdal_calculate -a a.tif -b b.tif --calc="a - b" --outfile c.tif If your input rasters are unsigned (i.e Byte or UInt16 etc) and the result may contain negative values, you need to specifically cast to a signed type : gdal_calculate -a a.tif -b b.tif --calc="Int16(a) - b" --outfile c.tif If your rasters ...


0

I checked the a.toc file with gdalinfo and I saw that it said the tiles did not exist. My directory structure was: RPF CHARTS CHTSERIES a.toc Turns out I needed the CHARTS folder to be in the parent folder with the a.toc file, not in the RPF folder. I did this, and I was able to create the store.


3

You can improve the result with this command line: gdal_translate -of GTiff PARAmap1.pdf out1File.tif --config GDAL_PDF_DPI 300 According to http://www.gdal.org/frmt_pdf.html, the default is 150dpi. For higher quality than 300dpi, you have to be very patient ;-) I was able to extract vector data from USGS topo PDFswith ogr2ogr in Convert GeoPDF with ...


0

You can use np.max(axis=0) to find the maximum along the z-axis of your array and get a 2d-array as a result. Then it is just a question of defining the monthly indices to loop through the original array. import numpy as np from osgeo import gdal img = gdal.Open("/path/to/file") input = img.ReadAsArray() dayspermonth = np.array([0, 31, 28, 31, 30, 31, 30, ...


3

You should probably start from http://trac.osgeo.org/gdal/browser/trunk/gdal/alg/polygonize.cpp and follow it and included source files. License is MIT/X license and you can read what it means from the headers.


0

You can create or import routes on bikemap.net. After that, export them as GPX, load the GPX file in geojson.io, and save it as GeoJSON. You can add as many GPX files as you want to a single GeoJSON.


0

You can use rasterio to read/write NumPy arrays. For example, read, edit a pixel, then save it back. import rasterio with rasterio.open('/path/to/raster.tif', 'r+') as r: arr = r.read() # read all raster values print(arr.shape) # this is a numpy array, with dimensions [band, row, col] arr[0, 10, 20] = 3 # change a pixel value on band 1, row ...


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 ...


1

You can combine the two functions I suppose that the projection of the two shapefiles are the same. 1) spatialRef = inputlyr.GetSpatialRef() gives you the projection of the original shapefile 2) prj = os.path.splitext(outputBufferfn)[0] + ".prj" gives you the name of the prj file of the buffer shapefile outputBufferfn = "a_shapefile.shp" ...


1

On the help page an example is given: gdal_calc.py -A input1.tif -B input2.tif --outfile=result.tif --calc="A+B" This is addition, but subtraction is just as easy: gdal_calc.py -A input1.tif -B input2.tif --outfile=result.tif --calc="A-B"


1

Usually I use the raster calculator manually, in my case for give more weight to one value in a shp or a raster, also for calculate the IRNV in some raster. if you want to automatice some task (in the case of the IRNV) you must use the map algebra toolset instead. Sorry, thats all i know about it [and also sorry for my english :( ]


2

You can't use GDALFPolygonize with the GDAL python bindings without modifying the source code and recompiling as it isn't exposed in the GDAL swig interface. To polygonize your raster, you will need to convert from float to integer. If you want to retain some decimal places multiply your raster by 10^N where N is the number of decimal places you want to ...


1

The GDAL osm driver makes use of an osmconf.ini file: http://www.gdal.org/drv_osm.html Within that file, you can uncomment the line #other_tags=no to avoid saving all possible names of Sweden in that database column. By the way, GDAL can read the osm.pbf file directly, no need to extract it first.



Top 50 recent answers are included