Hot answers tagged

13

Your attempt is designed to fail. If you look at the image, you see the data arranged as a circle, with black triangles in the corners of the square, where the satellite view goes right into orbit. In your test data, you see only NODATA -32768 for those parts of the image. The extent is between +/-75 and +/- 78, but these values are only reached in the ...


7

If you know R, you can use the package "gdalUtils" and run gdal_translate to do that. If you are on Linux make sure to install GDAL. If you are on Windows, you're good to go. These are the basic commands to handle the conversion to .tiff and the reprojection to WGS84. out.files <- list.files(getwd(), pattern="hdf$", full.names=FALSE) #create a list with ...


7

This is fairly straightforward if you think of the HDF dataset as a container, where each subdataset is a raster image with its own projection. Your error is in not opening the subdataset, as GetSubDatasets only returns the strings you need to access them. # open the HDF container hdf_ds = gdal.Open(hdfFile) # this is just a string of the name of the ...


6

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)'), ('HDF4_SDS:UNKNOWN:"3B43.20140501.7....


6

The ASTER L1B files contain several subdatasets with different resolutions. That's why you can not easily add them to QGIS. You have to run gdalinfo and gdalwarp on it to get a tif file that QGIS can import: gdalinfo AST_L1B.hdf >>info.txt gives you a long list of metadata. Look out for the subdatasets: Subdatasets: SUBDATASET_1_NAME=HDF4_EOS:...


6

Here is my code I use to convert all HDFs in a folder to GeoTIFF via GDAL (OSGEO4w) in Windows when working with SST data. Remember to use the OSGEO4W version to get hdf support. for %A in ("C:\temp\*.hdf") do gdal_translate -of GTiff -a_srs "+init=epsg:4326" -a_ullr -180 90 180 -90 -co "COMPRESS=PACKBITS" -sds "%A" "%A.tiff for %A in ("C:\temp\*.hdf") do ...


5

As a reference, I took the file linked here: http://oceancolor.gsfc.nasa.gov/forum/oceancolor/topic_show.pl?tid=5426 gdalinfo on the subdataset 37 returns: geospatial_lat_max=24.78230858 geospatial_lat_min=5.343300343 geospatial_lon_max=139.3295746 geospatial_lon_min=126.3987579 ... Lower Left Latitude=24.78230858 Lower Left Longitude=134.9941864 Lower ...


5

It's very easy to load these files in QGIS. I downloaded npp.2006.hdf from this page: http://orca.science.oregonstate.edu/2160.by.4320.yearly.hdf.land.ocean.merge.php At QGIS OSGeo Console, the result of: gdalinfo npp.2006.hdf it is: Driver: HDF4Image/HDF4 Dataset Files: npp.2006.hdf npp.2006.hdf.aux.xml Size is 4320, 2160 Coordinate System is `' ...


4

First, you are using R. R Studio is just an IDE for R so in the future please make this an R question. I will warn you that working with HDF files in R is a pain. In theory GDAL supports HDF5 so one could use readGDAL in the rgdal package. Depending on the source of the data readGDAL has a high fail rate making it less than reliable. Historically, there ...


4

The dataset is getting dereferenced when you return only the band from your function. The solution is to return the dataset from your function. From the GDAL Python Gotchas page: Python crashes if you use an object after deleting an object it has a relationship with Consider this example: from osgeo import gdal dataset = gdal.Open('C:\\...


4

Your QGIS version (precisely the GDAL version it uses) was probably built without HDF5 support. QGIS automatically lists all subdatasets in a HDF5 and lets you chose which one you want to open when you import/open a HDF5 container. You can view all supported formats of your specific install by importing a Raster dataset (add Raster Layer) and using the ...


4

If you are working with a GDAL version that supports HDF5 datasets this is how you can extract a single subdataset from it and convert it to Geotiff in Python. This example was used for MOD09 and MOD13 band extraction (hence the no_data value conversion). from osgeo import gdal import numpy as np def hdf_subdataset_extraction(hdf_file, dst_dir, subdataset):...


3

After some testing, I think that the geoloc is not working properly. So I used the alternative method using manually created vrt files: Create a file named lon.vrt: <VRTDataset rasterXSize="1354" rasterYSize="2030"> <SRS>GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],...


3

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


3

In most cases, HDF files come with georeferencing information. If QGIS does not read it automatically, you have to look that up on the download page, or ask the provider. Don't use Set CRS for Layer inside QGIS to change the CRS. This will corrupt your data. If the HDF has another CRS than your picture, use On-The-Fly-Reprojection, or Save As providing a ...


3

You can either leave the -s_srs empty or use +proj=sinu +R=6371007.181 +nadgrids=@null +wktext gdalwarp -of GTIFF -s_srs '+proj=sinu +R=6371007.181 +nadgrids=@null +wktext' -r cubic -t_srs '+proj=longlat +datum=WGS84 +no_defs' {inputfile} {outputfile} Note that inputfile must be the full subdataset (SDS) name, which you can get from gdalinfo. For example, ...


3

You might get unexpected results because your dataset crosses the 180° meridian. As a consequence, the tile is squeezed around the globe when reprojected to WGS84. To avoid that, you have to cut the raster data at the +/- 179.99° meridian. The following batch works with pure GDAL: gdal_translate HDF4_EOS:EOS_GRID:"MOD11A1.A2004091.h34v10.005.2007261231833....


3

That particular file, or at least that particular dataset within that file, is not a regular grid, and so can't be converted (easily) to a GeoTIFF file or read in as a raster data source. > long <- file["Soil_Moisture_Retrieval_Data"]["longitude"] > str(long) Formal class 'DataSet' [package "h5"] with 7 slots ..@ name : chr "longitude" ..@...


3

Both the HDF-EOS To GeoTIFF Conversion Tool (HEG) and the MODIS Reprojection Tool (MRT) can do that. You can download them from the USGS website: https://lpdaac.usgs.gov/tools/data_manipulation


3

Raster files don't need a geometry column. You just need the projection (sinu for this MODIS product) and the bounding box coordinates, that are stored in the metadata tags of the file. The rest is simple interpolation of coordinates.


3

Setting your mode to binary in your download.file() call would have worked as well. You should always specify this with download.file([...] , mode='wb') if you're downloading binary files. Otherwise the download itself is not in hdf format even if the file extension makes it look like it is. This leads to the error you received above. This also will help ...


3

The raster can be loaded into QGIS with the HDF5 driver, but it gets displayed as X: 3 Y: 18570 cells. Gdalinfo reports just 2 subdatasets, but no longitudes or latitudes. The information on the website notes that latitudes and longitudes should be stored in separate subdatasets, along with several other datasets. Using H5dump from HDF Tools and HDF ...


3

I did it in python, with MOD04 however. Still, what have you tried in Matlab so far? I could get to info=hdfinfo('MOD35_L2.A2017090.0340.005.2017090132804.hdf'); dsets = info.Vgroup.SDS; but in the second line I received an empty raster.


2

I developed gdalUtils specifically for this issue. On a Mac, install the GDAL frameworks which include HDF4/5 and NetCDF drivers, and then use gdalUtils to interface with it.


2

QGIS, free software, has support for HDF4 and HDF5 images. You can open them perfectly with this software. These images have the sinusoidal projection (+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs) and they can be later exported with another format and projection using the Raster -> Projections -> Warp (Reproject) option ...


2

I had the same issue and I would like to share my solution to the problem : First make sure that you have the necessary hdf4 drivers installed: apt-get install libhdf4-dev apt-get install proj-bin apt-get install libproj-dev apt-get install libgdal-dev apt-get install gdal-bin # Thanks to user @mdsumner for this Then there seems to be a issue with ...


2

On Debian, you'll have to install libhdf4-alt-dev (not libhd4-dev) and then re-compile gdal. But there's a conflict with NETCDF if those drivers are enabled, so it's important to disable netcdf during the compile: ./configure --disable-netcdf --disable-fortran And it should find the hdf4 libs automatically. UPDATE There was a recent post on the GDAL ...


2

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


2

Your problem comes from adressing the subdatasets wrong. If you run gdalinfo on the complete file it will display the names of the subdatasets: SUBDATASET_1_NAME=HDF5:"A2015069000500.L2_LAC_OC.nc"://geophysical_data/Kd_490 To get the information of the first subdataset you need to feed the complete name into gdalinfo gdalinfo HDF5:"A2015069000500....


2

The Netcdf browser plugin you are using does not seem to work with the data, although the file ending suggests a netcdf file. See http://www.hdfgroup.org/projects/netCDF-4/ on the differences between Netcdf4 and HDF5. Possible duplicate of Getting warning when opening NetCDF file using gdal?. You need to run gdalinfo on the file to access the subdatasets ...


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