Tag Info

Hot answers tagged

3

For merely converting a raster from one format to another, many of the GDAL tools will do that along with their specialized functions so either GDALWARP or GDAL_TRANSALTE will do fine for your purposes (which also explains why they give you the same error). The information you mention in the documentation in your links is applicable to using GDAL. Most of ...


2

To run gdal2tiles.py on a multiple images, use gdalbuildvrt to build a virual raster from those images first. Then you can run gdal2tiles on the .vrt file. gdalbuildvrt -o merged.vrt file1.jp2 file2.jp2 .... gdal2tiles.py merged.vrt output_folder/ If you are running it on large files, check out the enhanced version of the script that uses parallel ...


2

The reason you are not getting the exact shape you want is because when you vectorize a raster it usually outputs as a rectangular shape because rasters are rectangular grids. You have a few options here. You can apply a mask to the raster and vectorize only the area you want, but I think you don't know which area you want yet? In this case I would ...


2

It is necessary to clarify that "l10g" is a DEM tile from the GLOBE website (Python Geospatial Development, p.120) and is a valid raster (raw elevation data). You must also download the hdr (l10g.hdr, book p.120 and explanations of Gabor Farkas) The l10g, l10g.hdr and histogram.py files should be in the same folder D:\Python\Progies\Geospatial\l10g\ To ...


2

Think hdf file as a folder. You want to open the file INSIDE the folder. import gdal hdf_file = gdal.Open("3B43.20140501.7.HDF") # 3b43 rainfall dataset subDatasets = hdf_file.GetSubDatasets() subDatasets >>> [('HDF4_SDS:UNKNOWN:"3B43.20140501.7.HDF":0', '[1440x400] precipitation (32-bit floating-point)'), ...


2

If you specify a driver, OGR will only try to open your file with the specified driver. If you don't specify it, OGR will try to open your file with all the drivers. It will loop over all the drivers until it finds a driver with that it can open your file. The order it tries to open them is the same order as listed in ogrinfo --formats. See also this ...


2

Your data are stored as tables rather than gridded (raster) data which could be interpreted by GDAL. It might be easier in the end to work in HDF5 rather than HDF4. Given you're on a Windows box it's easy to download and install the h4toh5 tools from the HDF group which can be used from the command line with (using your example file): h4toh5convert ...


2

One suggestion is to use a VRT(Virtual Raster). There are a number of ways to do this. Use the VRT driver to create a copy of the original JP2 in memory (as a VRT XML string) using the /vsimem virtual memory filesystem, edit the in-memory VRT XML and change the SourceFilename element to point to the new processed raster (using VSFIOpen, VSIFRead and ...


2

If you are in doubt, apply a zoom level option of --zoom 8-12 and check all resulting output folders. It always worked for me with this option.


2

If you convert from one CRS to another, you will change the cell borders automatically. gdalwarp tries to keep the cell value, but it will also try to interpolate if the new cell size will cover different unreprojected cells. Reducing the cell size with -tr or -ts might solve your problem (but increase the raster file size too).


1

Firstly, welcome to the site! Numpy arrays don't have a concept of coordinate systems inbuilt into the array. For a 2D raster they are indexed by column and row. Note I'm making the assumption that you're reading a raster format that is supported by GDAL. In Python the best way to import spatial raster data is with the rasterio package. The raw data ...


1

No error if you put only gdal_retile. See image below: If you want to run gdal in the IDLE Python GUI or in the MS-DOS Console you can try this: gdal ImportError in python on Windows


1

You may still have 10dp numbers reported, but count the number of nodes in the modified file, and it should be far fewer that the original. The tolerance unit is whatever the unit of your map data uses. 0.000001° would keep destination paths no more than 0.000001° (a metre 10 cm or so) from their original location. It would be far too small if your data ...


1

the most easy way to do this in a script is to use the subprocess module and gdal_translate import subprocess image_in = "path_input_image" image_out = "path_output_image.tif" subprocess.call(["gdal_translate.exe","-co", "TILED=YES", "-co", "COMPRESS=LZW" "-ot", "Byte", "-scale", image_in, image_out ] if you are in Linux, you don't need the ".exe" after ...


1

You can do that directly in QGIS with Raster -> Conversion -> Translate (Convert Format). To test it, I used a Float64 (Sixty four bit floating point) raster (named test) loaded in the Map View of QGIS. To convert it to Byte (8 bit type), I named it first at the "output file space" as test_byte.tif and afterward, I click in the icon pencil of "Translate ...


1

I do not know why you get an error but compare your results with mine. Download first this file https://hub.qgis.org/attachments/8536/Trecks.gdb.zip Unzip (it will create a directory) and run ogrinfo ogrinfo Trecks.gdb Had to open data source read-only. INFO: Open of `trecks.gdb' using driver `OpenFileGDB' successful. 1: Venedigertreck_3D (3D Multi ...


1

I have added a few intermediate steps to change longitudes from 0/360 to -180/180: gdal_translate HDF5:"GW1AM2_20141231_01D_EQOD_L3SGTPWLA1100100.nc"://Time_Information ti.tif gdal_translate -a_ullr 0 90 360 -90 -a_srs epsg:4326 ti.tif deg.tif gdalwarp -t_srs epsg:4326 -wo SOURCE_EXTRA=1000 --config CENTER_LONG 0 deg.tif degree.tif gdalwarp -of "ENVI" ...


1

To proof the projection string, you can load the WKT of the neatline directly into QGIS, on a tiles background: The green line uses the CRS from your PDF, and the red one uses SRID 102024. Project CRS is the first one, that's why it looks like a rectangle. By the way, I had put your PDF WKT definition into a .prj file, and ran gdalsrsinfo on it to get ...


1

Your best bet to get a weighted choice is to use numpy.random.choice which allows you to specify the sample set, and a weight for each sample. Note the probability must sum to exactly 1. raster = numpy.random.choice([0, 1], size=(rows, cols), p=[0.65, 0.35]) Also, a quick note: your comment says the probability that the landuse should be allocated to 1 or ...


1

Found it thanks to iant's comment... http://localhost:8080/geoserver/rest/about/manifest.xml?manifest=gs-gdal-.*


1

As @user30184 says, gdal is just reading the values of your raster band, but you should be able to know the wavenlenght of each band based on the metadata (information you should get about the data). the two values returned by "ComputeBandStats()" will be the mean and standard deviation of the values in your bands. If the mean value is between zero and ...


1

See this example Create raster from array Replace the array with your own randomly created array. numpy.random as many random functions that you can use to construct the array as per your requirement


1

In the past, I have used a script to unzip the kmz and extract the bounding box coordinates from the KML and used gdal_translate to georeference the image The LatLonBox coordinates will map to the following values when using gdal_translate ulx = west uly = north lrx = east lry = south gdal_translate -a_ullr ulx uly lrx lry -a_srs EPSG:4326 input.jpg ...


1

You probably want to write a script, but starting point could be to take a list of the layers with ogrinfo: ogrinfo kml_samples.kml INFO: Open of `kml_samples.kml' using driver `LIBKML' successful. 1: Placemarks 2: Styles and Markup 3: Highlighted Icon 4: Ground Overlays 5: Screen Overlays 6: Paths 7: Polygons 8: Google Campus 9: Extruded Polygon 10: ...


1

You can do the complete procedure perfectly in QGIS (GDAL has HDF4/HDF5 support) without previous reprojection. You have to load all corresponding sub sets at the Map Canvas (sinusuoidal projection by default) and, by using the raster calculator, each image must be multiplied by the scale factor of 0.0001 (Table 2 of ...


1

My script uses a NDVI (no corrected by scale factor) sub dataset of modis product, for getting the coordinates (sinusoidal projection) for a value of 256 (equivalent to Number_Fire_Pixels = 256): from osgeo import gdal import struct nameraster = "MOD13Q1.A2005193.h10v08.005.2008215173619.hdf" hdf_file = gdal.Open(nameraster) subDatasets = ...


1

i don't recall all the steps i used, but with the anaconda distro, i placed a text file (something like qgislibs.pth) within my anaconda directory (or you default python install) - within the text file, include the path to your osgeo4w site packages - probably like C:\OSGeo4W64\apps\Python27\Lib\site-packages\ i think i also had to include a path in the ...


1

This code (modified to include any datatype) uses the raster loaded directly as active Layer in QGIS (see next image): import sys, struct from osgeo import gdal from osgeo import gdalconst import os minLat = -48 maxLat = -33 minLong = 165 maxLong = 179 layer = iface.activeLayer() provider = layer.dataProvider() fmttypes = {'Byte':'B', 'UInt16':'H', ...


1

There are three problems with your code/approach, which I would like to help to resolve in a quick and explicit manner: The raster data cannot be processed by the algorithm on its own. It needs a header file to access georeference information. Header files can be downloaded from here for the example dataset, as stated on page 120. You have to declare ...


1

You can do that in Python Console of QGIS by using a QgsRasterPipe object (pipe) for setting a renderer clone of the image employed as active layer before to use the 'writeRaster' method of QgsRasterFileWriter class (you don't need gdal_translate). I used the following code: layer = iface.activeLayer() extent = layer.extent() width, height = ...



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