User Tools

Site Tools


Reprojection and extraction of MODIS VCF data

Nandin-Erdene Tsendbazar


General framework of the analysis

  1. Background: When using a reference data of a land cover map to validate another land cover map, we need to improve the reference data in a way it fits the legend system of the target map. MODIS VCF data provide tree cover percentage information and this is useful in determining closed and open forests with a given thresholds.
  2. keywords: MODIS VCF, reprojection, data extraction on a polygon area

Project objectives

Global data of MODIS VCF are reprojected from sinusoidal projection to WGS84 which are compatible with the reference data and a target land cover map (use the wget command to download the file ) . The average of three years VCF data is calculated and the average VCF within the reference locations is extracted. The extracted VCF info within the reference locations will be grouped into different categorical classes which are compatible to the target map.


Vector data

A polygon file of 1.5×1.5 km rectangles at random locations of the world land mass.

Raster data

Vegetation Continuous Fields data of MODIS ( at 250 m resolution for the year 2004, 2005 and 2006. This data has been downloaded and mosaiced for the extent of the world. Data has original MODIS sinusoidal projection.


Global MODIS VCF data of 2004, 2005 and 2006 are reprojected into WGS84 projection using gdalwarp. Mean VCF value for each rectangle of the vector data is extracted for each year using GRASS and the final 3-year average VCF value for each location is calculated in R.

Computational implementation

- mycode
#VCF data for the 2004, 2005 and 2006 are re-projected. 
cd /media/DATA1/tsend001/vcf_modis_global 
time (ls mod44b_world_200?_250.tif | xargs -n 1 -P 12 bash ) contains :

# save following code as
gdalwarp -r bilinear -t_srs EPSG:4326 $file  proj_$file -overwrite

VCF values for the sample locations are extracted using GRASS

# Using the reprojected images, GRASS working environment is created; and
#images vector files are imported to GRASS.
#create new grass database folder
mkdir /media/DATA1/tsend001/vcf_modis_global/grassdb
#copy projected VCF file into that folder so that creation of
#new grass environment can make use of the informations on the 
#projection and extent. 
cp /media/DATA1/tsend001/vcf_modis_global/proj_mod44b_world_2005_250.tif /media/DATA1/tsend001/vcf_modis_global/grassdb/proj_mod44b_world_2005_250.tif
#change directory to grassdb
cd /media/DATA1/tsend001/vcf_modis_global/grassdb
# Download the and save it in your directory
#Rename by mv
#Run the script which creates the newlocation with inside the imported proj_*.tif.  
bash /media/DATA1/tsend001/vcf_modis_global/scripts/ proj_mod44b_world_2005_250.tif new_grass_loc /media/DATA1/tsend001/vcf_modis_global/grassdb 
#open grass environement
grass70 -text /media/DATA1/tsend001/vcf_modis_global;/grassdb/new_grass_loc/PERMANENT
###### start perform script tasks 
#import raster files into grass environment input=/media/DATA1/tsend001/vcf_modis_global/proj_mod44b_world_2004_250.tif output=2004_VCF  --overwrite input=/media/DATA1/tsend001/vcf_modis_global/proj_mod44b_world_2005_250.tif output=2005_VCF  --overwrite input=/media/DATA1/tsend001/vcf_modis_global/proj_mod44b_world_2006_250.tif output=2006_VCF  --overwrite 
# import the vector polygons -c dsn=/media/DATA1/tsend001/vcf_modis_global/points_combined_translated_5x5_rec.shp output=glob_samples1 --overwrite
#extract the values of VCF over the sample locations and #extracted values will be added to the attribute table of the #vector data
v.rast.stats glob_samples raster=2004_VCF colprefix=v_4 -c --verbose
v.rast.stats glob_samples raster=2005_VCF colprefix=v_5 -c --verbose
v.rast.stats glob_samples raster=2006_VCF colprefix=v_6 -c --verbose
#check the results -c glob_samples glob_samples
v.univar glob_samples column=v_4_mean #calculate summary stats per field
#export the glob_samples to shp
v.out.ogr input=glob_samples type=area dsn=/media/DATA1/tsend001/vcf_modis_global/globsample_vcf.shp
#Start R and import the shape file to calculate mean VCF values for three years
R --vanilla -q <<EOF
globsample_vcf<-readOGR("/media/DATA1/tsend001/vcf_modis_global/globsample_vcf.shp" , "globsample_vcf")
globsample_vcf_mean<-globsample_vcf[, c(1:49, 55,64,73)]
writeOGR(globsample_vcf_mean, dsn="/media/DATA1/tsend001/vcf_modis_global/globsample_vcf_mean1.shp", "globsample_vcf_mean1" , "ESRI Shapefile")


The output of the exercise is described below.

  • Reprojected VCF 2005
    Sample points overlaid on MODIS VCF image of 2005

  • Extracted VCF values at sample location
    3-year average VCF values at sample location
wikistudholland/utwente_nadin.txt · Last modified: 2021/01/20 20:36 (external edit)