Hi everyone,
I'd like to describe the data I am working with and then ask the question further below:
I am working with geographical pixels. I have thousands of pixels, each representing a square of X by X kilometers on a map.
Each pixel is identified by a unique ID number, and it has several different pieces of data associated to it.
In my case each pixel can contain several land cover types, each identified by a specific name and with a value of area associated with it. For instance I have area of land cultivated under corn, rice, or wheat. I have area of forest, savanna, brush etc. So, basically each pixel has a combination of both agriculture and natural habitats.
For each pixel I have also calculated the total agricultural land (called totcrop) by simply summing up the area for each single crop.
In addition, for each pixel, the areas of these land covers are provided for the year 2005 and for the year 2050. It so happens that the year 2005 also corresponds to a specific climate (which we call "base") and the year 2050 correspond to a set of other climates (they are called "ipsl" as well as other names).
Below you see an excerpt of my data. The variables, from left to right are: IDpixel (the numeric code that identifies the pixel), year, climate, agfuture (this is a simulated agricultural future, not relevant to my question further below), database (again not specifically relevant to my question), landcover (as I was saying above: corn, wheat, barren land, tundra, broadleaf forest etc) and value of area.
I sorted the data by IDpixel, landcover and year to show you that inside each single pixel, I have two area values for each land cover (barren, broad, grass, irmaize, irwheat, totcrop etc) one for 2005 and one for 2050 (the year variable).
This is the problem I have not been able to solve.
Let's consider a single pixel. When the value of area for the entire agricultural area (called totcrop) is 0 both in 2005 and in 2050, I want all data for that pixel to be dropped from the dataset.
I will state it again in slightly different words in the hope of making myself clear: for each pixel I have data on area for different crops, as well as a value for total agricultural area, and different natural habitats - and I have these data for the year 2005 and for the year 2050.
If, for a specific pixel, the value of area for total agricultural area is 0 both in 2005 and in 2050, I want that pixel and all data associated with it to be erased from the dataset.
I have not been able to find a solution.
any help/ideas are welcome
Many thanks
Nicola
* Example generated by -dataex-. For more info, type help dataex
clear
input str6 IDpixel str4(year climate agfuture) str3 database str7 landcover float area
"72119" "2005" "base" "midd" "glc" "barren" 25896
"72119" "2050" "ipsl" "midd" "glc" "barren" 26794
"72119" "2005" "base" "midd" "glc" "broad" 19
"72119" "2050" "ipsl" "midd" "glc" "broad" 10
"72119" "2005" "base" "midd" "glc" "grass" 102705
"72119" "2050" "ipsl" "midd" "glc" "grass" 104611
"72119" "2005" "base" "midd" "glc" "irmaize" 0
"72119" "2050" "ipsl" "midd" "glc" "irmaize" 0
"72119" "2005" "base" "midd" "glc" "irother" 6517
"72119" "2050" "ipsl" "midd" "glc" "irother" 6517
"72119" "2005" "base" "midd" "glc" "irrice" 0
"72119" "2050" "ipsl" "midd" "glc" "irrice" 0
"72119" "2005" "base" "midd" "glc" "irsorg" 0
"72119" "2050" "ipsl" "midd" "glc" "irsorg" 0
"72119" "2005" "base" "midd" "glc" "irsoy" 0
"72119" "2050" "ipsl" "midd" "glc" "irsoy" 0
"72119" "2005" "base" "midd" "glc" "irwheat" 0
"72119" "2050" "ipsl" "midd" "glc" "irwheat" 0
"72119" "2005" "base" "midd" "glc" "mixed" 4493
"72119" "2050" "ipsl" "midd" "glc" "mixed" 1910
"72119" "2005" "ipsl" "midd" "glc" "totcrop" 4500
"72119" "2050" "ipsl" "midd" "glc" "totcrop" 6517
"72119" "2005" "base" "midd" "glc" "tundra" 117
"72119" "2050" "ipsl" "midd" "glc" "tundra" 9
"72119" "2005" "base" "midd" "glc" "woody" 888
"72119" "2050" "ipsl" "midd" "glc" "woody" 496
"72120" "2005" "base" "midd" "glc" "barren" 18813
"72120" "2050" "ipsl" "midd" "glc" "barren" 19757
"72120" "2005" "base" "midd" "glc" "broad" 17
"72120" "2050" "ipsl" "midd" "glc" "broad" 9
"72120" "2005" "base" "midd" "glc" "grass" 83772
"72120" "2050" "ipsl" "midd" "glc" "grass" 86198
"72120" "2005" "base" "midd" "glc" "irmaize" 0
"72120" "2050" "ipsl" "midd" "glc" "irmaize" 0
"72120" "2005" "base" "midd" "glc" "irother" 44677
"72120" "2050" "ipsl" "midd" "glc" "irother" 44677
"72120" "2005" "base" "midd" "glc" "irrice" 0
"72120" "2050" "ipsl" "midd" "glc" "irrice" 0
"72120" "2005" "base" "midd" "glc" "irsorg" 0
"72120" "2050" "ipsl" "midd" "glc" "irsorg" 0
"72120" "2005" "base" "midd" "glc" "irsoy" 0
"72120" "2050" "ipsl" "midd" "glc" "irsoy" 0
end
[/CODE]
I'd like to describe the data I am working with and then ask the question further below:
I am working with geographical pixels. I have thousands of pixels, each representing a square of X by X kilometers on a map.
Each pixel is identified by a unique ID number, and it has several different pieces of data associated to it.
In my case each pixel can contain several land cover types, each identified by a specific name and with a value of area associated with it. For instance I have area of land cultivated under corn, rice, or wheat. I have area of forest, savanna, brush etc. So, basically each pixel has a combination of both agriculture and natural habitats.
For each pixel I have also calculated the total agricultural land (called totcrop) by simply summing up the area for each single crop.
In addition, for each pixel, the areas of these land covers are provided for the year 2005 and for the year 2050. It so happens that the year 2005 also corresponds to a specific climate (which we call "base") and the year 2050 correspond to a set of other climates (they are called "ipsl" as well as other names).
Below you see an excerpt of my data. The variables, from left to right are: IDpixel (the numeric code that identifies the pixel), year, climate, agfuture (this is a simulated agricultural future, not relevant to my question further below), database (again not specifically relevant to my question), landcover (as I was saying above: corn, wheat, barren land, tundra, broadleaf forest etc) and value of area.
I sorted the data by IDpixel, landcover and year to show you that inside each single pixel, I have two area values for each land cover (barren, broad, grass, irmaize, irwheat, totcrop etc) one for 2005 and one for 2050 (the year variable).
This is the problem I have not been able to solve.
Let's consider a single pixel. When the value of area for the entire agricultural area (called totcrop) is 0 both in 2005 and in 2050, I want all data for that pixel to be dropped from the dataset.
I will state it again in slightly different words in the hope of making myself clear: for each pixel I have data on area for different crops, as well as a value for total agricultural area, and different natural habitats - and I have these data for the year 2005 and for the year 2050.
If, for a specific pixel, the value of area for total agricultural area is 0 both in 2005 and in 2050, I want that pixel and all data associated with it to be erased from the dataset.
I have not been able to find a solution.
any help/ideas are welcome
Many thanks
Nicola
* Example generated by -dataex-. For more info, type help dataex
clear
input str6 IDpixel str4(year climate agfuture) str3 database str7 landcover float area
"72119" "2005" "base" "midd" "glc" "barren" 25896
"72119" "2050" "ipsl" "midd" "glc" "barren" 26794
"72119" "2005" "base" "midd" "glc" "broad" 19
"72119" "2050" "ipsl" "midd" "glc" "broad" 10
"72119" "2005" "base" "midd" "glc" "grass" 102705
"72119" "2050" "ipsl" "midd" "glc" "grass" 104611
"72119" "2005" "base" "midd" "glc" "irmaize" 0
"72119" "2050" "ipsl" "midd" "glc" "irmaize" 0
"72119" "2005" "base" "midd" "glc" "irother" 6517
"72119" "2050" "ipsl" "midd" "glc" "irother" 6517
"72119" "2005" "base" "midd" "glc" "irrice" 0
"72119" "2050" "ipsl" "midd" "glc" "irrice" 0
"72119" "2005" "base" "midd" "glc" "irsorg" 0
"72119" "2050" "ipsl" "midd" "glc" "irsorg" 0
"72119" "2005" "base" "midd" "glc" "irsoy" 0
"72119" "2050" "ipsl" "midd" "glc" "irsoy" 0
"72119" "2005" "base" "midd" "glc" "irwheat" 0
"72119" "2050" "ipsl" "midd" "glc" "irwheat" 0
"72119" "2005" "base" "midd" "glc" "mixed" 4493
"72119" "2050" "ipsl" "midd" "glc" "mixed" 1910
"72119" "2005" "ipsl" "midd" "glc" "totcrop" 4500
"72119" "2050" "ipsl" "midd" "glc" "totcrop" 6517
"72119" "2005" "base" "midd" "glc" "tundra" 117
"72119" "2050" "ipsl" "midd" "glc" "tundra" 9
"72119" "2005" "base" "midd" "glc" "woody" 888
"72119" "2050" "ipsl" "midd" "glc" "woody" 496
"72120" "2005" "base" "midd" "glc" "barren" 18813
"72120" "2050" "ipsl" "midd" "glc" "barren" 19757
"72120" "2005" "base" "midd" "glc" "broad" 17
"72120" "2050" "ipsl" "midd" "glc" "broad" 9
"72120" "2005" "base" "midd" "glc" "grass" 83772
"72120" "2050" "ipsl" "midd" "glc" "grass" 86198
"72120" "2005" "base" "midd" "glc" "irmaize" 0
"72120" "2050" "ipsl" "midd" "glc" "irmaize" 0
"72120" "2005" "base" "midd" "glc" "irother" 44677
"72120" "2050" "ipsl" "midd" "glc" "irother" 44677
"72120" "2005" "base" "midd" "glc" "irrice" 0
"72120" "2050" "ipsl" "midd" "glc" "irrice" 0
"72120" "2005" "base" "midd" "glc" "irsorg" 0
"72120" "2050" "ipsl" "midd" "glc" "irsorg" 0
"72120" "2005" "base" "midd" "glc" "irsoy" 0
"72120" "2050" "ipsl" "midd" "glc" "irsoy" 0
end
[/CODE]
Comment