Tag Info

New answers tagged

0

To answer the virtualenv specific aspect of the question: pip3 search gdal GDAL - GDAL: Geospatial Data Abstraction Library pygdal - Virtualenv and setuptools friendly version of standard GDAL python bindings Beware that pygdal may require a different version of GDAL, compared to what ...


3

Although it would require another library (which currently is only available on OS X and Linux) you could use RSGISLib (http://rsgislib.org), which is built on top of GDAL to do this. There is a function to stack bands, as an example: #!/usr/bin/env python import rsgislib from rsgislib import imageutils # Create list of images imageList = ...


0

After looking right and left for a solution, here is something that works for me on Ubuntu 14.04, even from within a virtualenv with no access to the system packages : Install dependencies : sudo apt-get install libgdal-dev libgdal1h libgdal1-dev Set the compiler flags : export CFLAGS=$(gdal-config --cflags) Install the version corresponding to the ...


2

Turns out it is as easy as this: MIMETYPE "application/json; subtype=geojson; charset=utf-8" Without the setting, no content encoding is returned by the server.


0

I am not able to find some general solutions which would be CRS independent but for my case - axis in left bottom corner - the following changes works: Start from max_y and use minus value for y cell size: geotransform=(min_x,min_cell_size,0,max_y,0,-min_cell_size) Revert the array lines from bottom to top: zi = zi[::-1,:] Will be glad if somebody ...


2

I like Mike Ts response (+1!). However, if you want to stick with what you have and not use sql, here's another way: feature = layer.GetNextFeature() field_vals = [] while feature: field_vals.append(feature.GetFieldAsString('FIELD_NAME')) feature = layer.GetNextFeature() #use set to get distinct field_vals print set(field_vals) note that ...


4

You can use ExecuteSQL on an OGR data source to return a new layer. E.g. from osgeo import ogr ogr_ds = ogr.Open('table.shp') sql = 'SELECT DISTINCT field FROM table' layer = ogr_ds.ExecuteSQL(sql) for i, feature in enumerate(layer): print('%d: %s' % (i, feature.GetField(0))) Note that there is no geometry in the layer, since it wasn't part of the SQL ...


2

With the SQLite dialect GDAL/OGR supports everything that is supported by SQLite http://www.sqlite.org/lang.html and Spatialite http://www.gaia-gis.it/gaia-sins/spatialite-sql-latest.html. You can demonstrate how to get an ordered list of distinct attribute values with ogrinfo. For sure the same functionality is available also from python. ogrinfo test.shp ...


0

If you have at least GDAL 1.11, you can open CSV files with the XYZ driver. The file must conform to the rules described, such as increasing X values, or the names used for the columns. In lieu of what your file looks like, here's a working example: $ cat > my.csv lon, lat, Z 0,0,3 1,0,6 0,1,9 1,1,2 $ gdalinfo my.csv Driver: XYZ/ASCII Gridded XYZ Files: ...


0

I had a similar problem, but would describe the symptom as not about where you pan, but what zoomo level. Zooms near the native resolution are fine, its the smaller levels that fail, regardless of whether you are entirely within extents.


0

OSGeo4W GDAL Python Fix Step 1. Begin with a fresh install of OSGeo4w, preferably the newest version. This can be downloaded from the following link: http://trac.osgeo.org/osgeo4w/ Step 2. Download and install the version of Python that corresponds to the version of Python used by your installation of OSGeo4W (In this case it is Python 2.7.5). Python ...


2

pardon any syntax errors...hope this helps. [edit: adding some more stuff to make clearer, as per suggestion] #import the numpy and gdal libraries import numpy as np from osgeo import gdal #an empty array/vector in which to store the different bands layers = [] #open raster ds = gdal.Open('raster.tif') #loop thru bands of raster and append each band of ...


-1

The problem happened to be caused by my geospatial data.


2

If the min value is consistent - like a no data value, you might be able to use the snodata option and specify the value you want ignore. As listed in the doc for gdal_contour


2

gdal_Calc.py can do that, a reclass Something like.. gdal_calc.py -A filename.tiff --outfile=filename.tiff --calc="A*(A>3)" --NoDataValue=0 --calc="1*(A<3) See this one gdal_calc.py raster reclass equivalent of ArcGIS reclass or r.reclass in grass


1

TL;DR The short version is to use a command like the following one which will make you as happy as it is possible with GDAL. gdalwarp -of gtiff -t_srs epsg:26912 -srcnodata 0 -dstnodata none -dstalpha -co compress=jpeg -co tiled=yes test.tif final.tif Longer story Your problem is not really in the compression artifacts but how to handle transparency ...


0

Lets have a close look at statistics about scene enclosed by you: C:\Program Files\QGIS Chugiak\bin>gdalinfo C:\Users\Janek\Desktop\LC819402420142 48LGN00_B5.TIF -stats [...] Metadata: STATISTICS_MAXIMUM=65535 - this especially! STATISTICS_MEAN=10396.365071613 STATISTICS_MINIMUM=0 - and this one STATISTICS_STDDEV=7547.8323562457 ...


0

As you probably know, jpg is a lossy compression, so you cannot completely avoid artefacts. I suggest that you export in TIFF with COMPRES=LZW instead, which will preserve your data.


0

Well, after several days, and some use of QGIS for basic vector actions, the georeferencing window returned. I've tried reproducing the error again but have failed (which is a good thing I presume).


1

value range of the input scene is 0 - 25480.812476 value range of the wrong created 8 bit is 0 - 255 enclosed u will find a link which contais the 16 bit single-band (free content): http://www.file-upload.net/download-9541350/LC81940242014248LGN00_B5.TIF.html


0

You have two questions: Reading pixel data from the Geotiff: Here you find a C# GDAL Read Raster Code Sample. The final reading method is called Band.ReadRaster! Reading Geotiff-Tags: Depends which Tags you mean... If you want to read the GeoTransform-Parameters (Georeference-Info), you would do that with the method Dataset.GetGeoTransform. If you want ...


0

Thanks to Michael Miles-Stimson for pointing me in the general vicinity in the comment above. I used QGIS for this. The solution was to do the following: Load the polygon data into QGIS as a shapefile layer Load the lat/long points into QGIS as a delimited text layer In QGIS perform a layer query to select only the polygon I want (doing polygons one at a ...


0

May be documented in http://www.gdal.org/drv_pg.html. Perhaps ogr2ogr do not undestand to append either. SCHEMA: Set name of schema for new table. Using the same layer name in different schemas is supported, but not in the public schema and others. Note that using the -overwrite option of ogr2ogr and -lco SCHEMA= option at the same time will not ...


0

Obviously listgeo and gdalinfo implement the same task in a bit different way. You can see that listgeo can read the datum even it does not write it into Proj4 string: listgeo -proj4 econic.tif Geotiff_Information: Version: 1 Key_Revision: 1.0 Tagged_Information: ModelTiepointTag (2,3): 0 0 0 ...


0

This is an other format, that can handle very large Raster Files: PCI Geomatics. It can be the direct output of gdalwarp, which is not the case for many Formats. A further alternative is the usage of the WarpEcwTool. This tool was specially written to warp huge ECW files. The tool cuts the input file into smaller tiles, warps them one by one an merges the ...


0

So, I have partially solved my question: Turns out there are two versions of the EASE-Grid projection. For the MODIS Ice Surface Temperature data produced after the 1st of January 2011, the 2nd version is used, while the first version is used (I think) for any data acquired before. My solution only covers the second version of the EASE-Grid: # Clip data, ...


0

You can use the gdal.Band ReadAsArray method. See also the GDAL API tutorial and the example below: from osgeo import gdal,ogr import numpy def map2pixel(mx,my,gt): """ Convert from map to pixel coordinates. Only works for geotransforms with no rotation. """ px = int((mx - gt[0]) / gt[1]) #x pixel py = int((my - gt[3]) / gt[5]) #y ...


1

The .prj file is used only with a shapefile. When you are working with a raster, you also need a distinct file which contains the projection information but it doesn't have the .prj extension. It has a .jgw, .pgw, .gfw extension and so on. If you are working with JPG, PNG or GIF, you will always need a distinct file. It is not true for the GeoTIFF ...


0

If it's in docked mode it might just be hidden


1

Bit of a cr@ppy answer - but it works. Unfortunately, it doesn't really solve the route cause. I resolved my issue by changing the build to use static libraries instead. ./configure --with-fgdb=/data/HOMEDIRS/SAI/dev/src/FileGDB_API --with-pg=/usr/bin/pg_config --prefix=/usr --without-ld-shared --disable-shared --enable-static


2

To have a better idea we would need you to send over the output of the gdalinfo on those images. I suspect that these are 16 bits images hence geoserver is applying contrast stretch on the fly to them depending on the local histogram to equalize them on bring them on 8 bits. You need to play with the rastersymbolizer parameters to improve the situation or ...


0

Totally black output was a result from the extents which were used in the gdalwarp command. They were outside the image area and therefore the output was nothing else than nodata. I recommend to use QGIS for debugging this kind of troubles. The VRT can be opened directly with QGIS as a raster layer and it can be reprojected on-the-fly to target projection ...


1

The Norwegian Met office has a THREDDS server at http://thredds.met.no/thredds/ so if you see the forecast you are trying to access there, you can extract just the subset you want from the OPeNDAP URL, which NetCDF4-Python treats like a local netcdf file. For example: import netCDF4 url = ...


1

There were two problems. One noticed by @kyle, that the VRTDataset depends on the original, the other that the datasets needed to be closed in a specific order. Since all the datasets in this example are created in a program I was not able to use GDALOpenShared() as the documentation suggests, so instead the proper datasets need to be closed and removed at ...


0

netCDF4-python will let you subset (using numpy slicing syntax) the data variables without reading the full data from the disk.


3

As indicated in the error message you have to install 'python-gdal' bindings. Also you may check out similar questions: Missing QGIS raster menu tools - '“osgeo python-gdal” module is missing', QGIS says “osgeo python-gdal” isn't installed on Mac


2

@user30184 came with the solution. the (quite common GIS) problem was that non-ASCII characters (like æ ø å) in the path name gets deleted. only use ASCII characters in file paths.


0

i tried this code it showing error, can you spot where i went wrong. This's the code i tried import os from subprocess import call call(["ls", "-l"]) path= 'C:/Users/admin/Desktop/input' os.chdir(path) cmd= 'gdalwarp -dstnodata 0 -q -cutline \ HP_grid_10km.shp -crop_to_cutline -of GTiff wc_30s_HADCM3_A2a_2020_prec_1.bil out.tif' call (cmd) ...


0

I experienced a similar problem. I use Windows 7. I compiled the binaries for MinGW using the steps found on this page http://trac.osgeo.org/gdal/wiki/BuildingWithMinGW (I could not find prebuilt binaries for MinGW, the links in the documentation were a dead end). The produced DLL and LIB files were linked correctly but my program still crashed. I also had ...


3

It is the obscurity of Pseudo Mercator that leads to the offset. Both projections (3857 and 54004) share the same WKT definition, but it is treated differently. Google (Pseudo) Mercator takes lat/lon coordinates of the ellipsoid, and uses them as they were on a sphere. Hence the different definitions a=b= 6378137 in the proj string vs SPHEROID["WGS ...


2

This is odd, but by following exactly your workflow I get this as a result: Gdalinfo with statistics for my version of resized-mercator.tif is here: Corner Coordinates: Upper Left ( -556597.454, 6621293.723) ( 5d 0' 0.00"W, 51d 0' 0.00"N) Lower Left ( -556597.454, 5011872.466) ( 5d 0' 0.00"W, 40d59'48.55"N) Upper Right ( 1113920.713, 6621293.723) ( ...


0

Are you sure you set the environment variables? Are the GDAL DLLs of the right bitness on your path? SysWOW64 indicates to me that you're trying to run 32-bit on a 64-bit OS. -reilly.



Top 50 recent answers are included