** 	THIS FILE ANALYSES THE LAND USE

** 	CHANGE THE DIRECTORY
	cd $DIR

** 	OPEN SOLUTION.DTA
	use CRE_Solution, clear

 	

*************************************************************************************
**	CHANGE PERIODS INTO YEARS
	g year = $YEAR -1 + period		/* From periods to years */

	drop if period==1			/*Drop first 2 simulation years*/
	drop if period==2
	

**************************************************************************************

** 	GROUP THE CROPS

**	RICE AREA
	egen c_irice = rowtotal(grow_irice_*)
	egen c_rfrice = rowtotal(grow_rfrice_*)
	egen c_sprice = rowtotal(grow_sprice_*)

**	RAINFED CROPS
	egen c_rfmaize = rowtotal(grow_rfmaize)
	egen c_millet = rowtotal( grow_cp_mil_1 grow_cp_mil_2 grow_cp_mil_gc_1 grow_cp_mil_gc_2 grow_cp_gc_mil_1 grow_cp_gc_mil_2 grow_millet_wocash) /*Millet and guinea corn*/
	egen c_mil_bean = rowtotal(grow_b_mb_* grow_cp_mil_b_* grow_cp_gmil_b_* grow_cp_gmil2_b_* grow_b_mb_wocash)
	egen c_gnut_bean = rowtotal(grow_b_gb grow_b_gb_m grow_b_gb_fm grow_cp_gnut_b grow_cp_gnut_b_m grow_cp_gnut_b_fm grow_cp_gnut_bb)
	egen c_groundnut = rowtotal(grow_b_gnut_* grow_cp_gnut) /*Groundnut sole crop*/

**	IRRIGATED CROP AREA
	egen c_tomato = rowtotal(grow_tom_*)
	egen c_onion = rowtotal(grow_onion_*)
	egen c_irmaize = rowtotal(grow_feb_irrimaize_* grow_mar_irrimaize_* grow_aprl_irrimaize_*)

*******************************************************************************************************
** 	BUSH AND COMPOUND FARM CROP AREA
**	egen c_bush = rowtotal(grow_b_mb_* grow_b_gnut_m grow_b_gnut_fm grow_b_gb grow_b_gb_m grow_b_gb_fm)
**	egen c_cp = rowtotal(grow_cp_mil_* grow_cp_mil_gc_* grow_cp_gc_mil_* grow_cp_mil_b_* grow_cp_gmil_b_* grow_cp_gmil2_b_* grow_cp_gnut grow_cp_gnut_b grow_cp_gnut_b_m grow_cp_gnut_b_fm)

*********************************************************************************************************************

**	PERCENTAGE OF TOTAL CROP AREA 

*************************************************************************************
**	TOTAL AREA UNDER CROPS
	egen carea = rowtotal(c_irice c_rfrice c_sprice c_rfmaize c_millet c_mil_bean c_gnut_bean c_groundnut c_tomato c_onion c_irmaize)

	g pa_rice = (c_irice + c_rfrice + c_sprice)/carea *100
	g pa_rfmaize = c_rfmaize/carea*100
	g pa_millet= c_millet/carea*100
	g pa_mil_bean=c_mil_bean/carea*100
	g pa_gnut_bean=c_gnut_bean/carea*100
	g pa_groundnut=c_groundnut/carea*100
	g pa_tomato=c_tomato/carea*100
	g pa_onion=c_onion/carea*100
	g pa_irmaize =c_irmaize/carea*100


**	COLLAPSE BY PERIOD

	collapse (mean) pa_* (sum)dry_mig c_*, by( run year) fast

	graph bar  pa_rice  pa_rfmaize pa_millet pa_mil_bean pa_gnut_bean pa_groundnut  pa_tomato pa_onion, over(year, gap(*0.5)) stack nofill ylabel(#5,angle(horizontal))  title("Share in total crop area, in %") legend(col(4) label(1 "Rice") label(2 "Rainfed maize") label(3 "Millet") label(4 "Millet+beans") label(5 "Gnut+beans") label(6 "Groundnut") label(7 "Tomato") label(8 "onion") size(small) width(200) nobox) plotregion(margin(zero) lc(black)) graphregion(margin(b+0 l+3) fc(white)) ysize(8) xsize(12) 	 
	
	graph export "D:\MPMAS\\TONO110\Stata\results\Pecentage to total crop area_BSL_DRY.tif", as(tif) replace
*********************************************************************************************

	gg

** TABLES

	table period, c(sum c_irice sum c_rfrice sum c_sprice sum c_rfmaize sum c_mil_bean ) format(%9.2f)


	graph bar  c_irice c_rfrice c_sprice c_rfmaize c_millet c_mil_bean c_gnut_bean c_groundnut  c_tomato c_onion, over(period, gap(*0.5)) stack nofill ylabel(#5,angle(horizontal))  title("Land use per period, total in ha") legend(col(4) label(1 "Irri rice") label(2 "Rainfed rice") label(3 "Spl rice") label(4 "Rainfed maize") label(5 "Millet") label(6 "Millet+beans") label(7 "Gnut+beans") label(8 "Groundnut") label(9 "Tomato") label(10 "onion") size(small) width(200) nobox) plotregion(margin(zero) lc(black)) graphregion(margin(b+0 l+3) fc(white)) ysize(8) xsize(12) 		
	graph export "D:\MPMAS\Ghana_casestudy\TONO_10\Stata\results\Landuse_crops_BSL_DRY.tif", as(tif) replace

*********************************************************************************************


	
