Find pixel indices in HDF-EOS files based on LatLon coordinates

Finds x-y direct indexes of one or more LatLon coordinate pairs in certain HDF-EOS files
873 download
Aggiornato 15 giu 2012

Visualizza la licenza

This function takes Latitude-Longitude pairs with name of an HDF-EOS file and finds the X-Y indexes of each LatLon pair in the HDF file. The function will work with HDF files which have:
1. Sinusoidal Projection (e.g., MODIS LST Level 3 product);
2. Global Cylindrical Equal-Area Projection or Cylindrical Equal-Area Scalable Earth Grid (EASE)
Important: LatLon pairs must be given in a matrix where first column contains Latitude and the SECOND COLUMN LONGITUDE, while the function will write X as first and Y as the second output. One or more pairs of LatLon coordinates can be given, where each line will contain coordinates of one point. The first two output variables will contain the X and Y indexes with the same order as LatLon inputs. The function is tested with the MODIS LST Level 3 (MOD11A1) and MODIS BRDF/Albedo (MCD43B3) products for proj=1 (Sinusoidal), and AMSR-E Soil Moisture (AMSR_E_L3_DailyLand_V07) product for proj=2 (EASE grid).
--Input variables:
LatLon: matrix with two columns: Latitudes and Longitudes
filename: HDF file name (including filepath if file is not in current
directory)
proj: Projection type of the HDF file (currently only 1 or 2)

--Output variables:
coordX_idx: x indexes of given LatLon coordinate(s) in the given HDF file
coordY_idx: y indexes of given LatLon coordinate(s) in the given HDF file (if
0 is returned by coordX_idx or coordY_idx means the LatLon pair could
not be found in the given image/HDF file).
projType: (string) full name of the given projection type
mdist2point: minimum distance to each point in meters that the function
could work out (should not be bigger than xRes or yRes).
xRes: resolution of the image along x or longitudes (it is always positive)
yRes: resolution of the image along y or latitudes (since Latitudes decrease from UppeLeft to LowerRight corner of an image, this will be a negative value--> note: this is now updated to be always positive).

--Example:
LatLon=[-43.5,172.5; -43.9,172.75]
%download the following file and put it in the current directory:
ftp://e4ftl01.cr.usgs.gov/MODIS_Dailies_E/MOLA/MYD11A1.005/2012.05.07/MYD11A1.A2012128.h30v13.005.2012129204401.hdf
filename='./MYD11A1.A2012128.h30v13.005.2012129204401.hdf';
proj=1;
[coordX_idx,coordY_idx,projType,mdist2point,xRes,yRes] = ...
findIndexes(LatLon,filename, proj)

The returned coordX_idx coordY_idx are indexes of the LST pixels covering 1km^2 in the above coordinates.

First Version: Feb 19 2012 (V01)
Added functionailty: Apr 25 2012 (V02)
Updated: Jun 15 2012

Cita come

M Sohrabinia (2024). Find pixel indices in HDF-EOS files based on LatLon coordinates (https://www.mathworks.com/matlabcentral/fileexchange/37033-find-pixel-indices-in-hdf-eos-files-based-on-latlon-coordinates), MATLAB Central File Exchange. Recuperato .

Compatibilità della release di MATLAB
Creato con R2008b
Compatibile con qualsiasi release
Compatibilità della piattaforma
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Versione Pubblicato Note della release
1.1.0.0

1. Coordinates of the pixels to find are now matched with the center of each pixel in contrast to the UpperLeft corner in the previous code.
2. yRes is changed to be always positive, description of the function is updated.

1.0.0.0