[![PyPI version](https://badge.fury.io/py/forest-puller.svg)](https://badge.fury.io/py/forest-puller)
[![GitHub last commit](https://img.shields.io/github/last-commit/xapple/forest_puller.svg)](https://github.com/xapple/forest_puller/commits/master)
[![GitHub](https://img.shields.io/github/license/xapple/forest_puller.svg)](https://github.com/xapple/forest_puller/blob/master/LICENSE)
# `forest_puller` version 1.2.0
`forest_puller` is a python package for retrieving data concerning forests of European countries. This includes the amount of forested areas, the forest inventory (standing stock), the forest growth rates as well as the forest loss dynamics (disturbances).
There are several public data sources accessible online that provide these types of information in various forms and granularity. This package automates the process of scrapping these websites and parsing the resulting csv tables or excel files.
Once `forest_puller` is installed you can easily access forest data through standard python pandas data frames.
## Scope and sources
Currently `forest_puller` provides data for the following 27 EU member states (past and present):
* Austria, Belgium, Bulgaria, Croatia, Cyprus, Czech Republic, Denmark, Estonia, Finland, France, Germany, Greece, Hungary, Ireland, Italy, Latvia, Lithuania, Luxembourg, Netherlands, Poland, Portugal, Romania, Slovakia, Slovenia, Spain, Sweden, United Kingdom
Currently `forest_puller` caches and provides programmatic access to the forest-relevant data from these data sources:
* IPCC (https://tinyurl.com/y474yu9e)
* SOEF (https://dbsoef.foresteurope.org/)
* FAOSTAT (http://www.fao.org/faostat/en/)
* HPFFRE (https://doi.org/10.5061/dryad.4t880qh)
What other data source you would like to see added here? Contact the authors by opening an issue in the issue tracker.
## Installing
`forest_puller` is a python package and hence is compatible with all operating systems: Linux, macOS and Windows. The only prerequisite is python3 which is often installed by default. Simply type the following on your terminal:
$ pip3 install --user forest_puller
Or if you want to install it for all users of the system:
$ sudo pip3 install forest_puller
If you do not have `pip` on your system you can usually get it with these commands (fresh Ubuntu 18LTS):
sudo apt-get update
sudo apt-get install python3-distutils
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py --user
## Usage
For instance to retrieve the net carbon dioxide emission of Austria in 2017 that were due to *coniferous* forest land from the IPCC official data source, you can do the following:
```python
# Import #
from forest_puller.ipcc.country import countries
# Get the country #
austria = countries['AT']
# Get the 2017 indexed dataframe #
at_2017 = austria.years[2017].indexed
# Print some data #
print(at_2017.loc['remaining_forest', 'Coniferous']['net_co2'])
```
904282.4970403439
To see what information is available you can of course display the column titles and row indexes of that data frame:
```python
print(at_2017.columns)
# Index(['area', 'area_mineral', 'area_organic', 'biomass_gains_ratio',
# 'biomass_losses_ratio', 'biomass_net_change_ratio', 'net_dead_ratio',
# 'net_litter_ratio', 'net_mineral_soil_ratio', 'net_organic_soil_ratio',
# 'biomass_gains', 'biomass_losses', 'biomass_net_change', 'net_dead',
# 'net_litter', 'net_mineral_soils', 'net_organic_soils', 'net_co2'],
# dtype='object', name='category')
print(at_2017.index)
# MultiIndex(levels=[['cropland_to_forest', 'grassland_to_forest',
# 'land_to_forest', 'other_land_to_forest', 'remaining_forest',
# 'settlements_to_forest', 'total_forest', 'wetlands_to_forest'],
# ['', 'Coniferous', 'Deciduous', 'Forest not in yield', 'Total']])
```
To examine what countries and what years are available:
```python
print(list(c.iso2_code for c in countries.values()))
# ['AT', 'BE', 'BG', 'HR', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR',
# 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI',
# 'ES', 'SE', 'GB', 'ZZ']
print(list(y for y in austria.years))
# [1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
# 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
# 2013, 2014, 2015, 2016, 2017]
```
To get a large data frame with all years and all countries inside:
```python
from forest_puller.ipcc.concat import df
print(df)
```
## Cache
When you import `forest_puller`, we will check the `$FOREST_PULLER_CACHE` environment variable to see where to download and store the cached data. If this variable is not set, we will default to the platform's temporary directory and clone a repository there. This could result in re-downloading the cache after every reboot.
## Data sources
### IPCC
To access the same forest data directly from the IPCC website without the use of `forest_puller`, you would have to first select your country of interest from the CRF country table in a browser at [this address](https://tinyurl.com/y474yu9e).
![IPCC demo screenshot 1](documentation/ipcc/ipcc_demo_1.png?raw=true "IPCC demo screenshot 1")
Then you would have to manually download the zip file for that specific country through another page.
![IPCC demo screenshot 2](documentation/ipcc/ipcc_demo_2.png?raw=true "IPCC demo screenshot 2")
Next, you would have to uncompress the zip file and locate the xls file that concerns the year you are interested in.
![IPCC demo screenshot 4](documentation/ipcc/ipcc_demo_4.png?raw=true "IPCC demo screenshot 4")
Finally you would have to scroll to the right sheet in your spreadsheet software and find the pertinent cell.
![IPCC demo screenshot 5](documentation/ipcc/ipcc_demo_5.png?raw=true "IPCC demo screenshot 5")
This operation would have to be repeated for every country, and every year you are interested in.
With `forest_puller` you can easily display any information you want for all countries at the same time:
```python
from forest_puller.ipcc.country import countries
category, key = ['total_forest', 'biomass_net_change']
biomass_net_change = {
k: c.last_year.indexed.loc[category, ''][key]
for k,c in countries.items()
}
import pprint
pprint.pprint(biomass_net_change)
```
{'AT': 1367857.0940855271,
'BE': 374245.08695361385,
'BG': 2192942.031982918,
'CZ': 387870.89395249996,
'DE': 12317598.87352293,
'DK': -216454.31026543948,
'EE': 320710.2459538891,
'ES': 8917649.261547482,
'FI': 6603815.0,
'FR': 15051831.9827214,
'GB': 2892518.0859005335,
'GR': 583205.0978272819,
'HR': 1477791.7578513895,
'HU': 1259385.5890665338,
'IE': 1069648.7636722159,
'IT': 5752883.095908434,
'LT': 2146933.309581986,
'LU': 101929.37461705346,
'LV': 1244965.2120000012,
'NL': 499021.93968,
'PL': 9353198.2907701,
'PT': 1536917.4736652463,
'RO': 5561343.4405591395,
'SE': 10185839.738999998,
'SI': 35391.09710503432,
'SK': 1184611.3471376207}
### Forest Europe (SOEF)
This data is provided by the "Ministerial Conference on the Protection of Forests in Europe" and is accessible at: https://dbsoef.foresteurope.org/
Three tables are provided for every country:
* Table 1.1a: Forest area
* Table 1.3a1: Age class distribution (area of even-aged stands)
* Table 3.1: Increment and fellings
It is accessed in a similar way to other data sources:
```python
from forest_puller.soef.country import countries
country = countries['AT']
print(country.forest_area.indexed)
print(country.age_dist.indexed)
print(country.fellings.indexed)
```
There is also a large data frame containing all countries concatenated together:
```python
from forest_puller.soef.concat import tables
print(tables['forest_area'])
print(tables['age_dist'])
print(tables['fellings'])
```
### Faostat (forestry)
This data is acquired by picking the "All Data Normalized" option from the "Bulk do
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
共88个文件
py:70个
csv:8个
txt:5个
资源分类:Python库 所属语言:Python 资源全名:forest_puller-1.2.0.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
资源推荐
资源详情
资源评论
收起资源包目录
forest_puller-1.2.0.tar.gz (88个子文件)
forest_puller-1.2.0
MANIFEST.in 117B
PKG-INFO 14KB
forest_puller.egg-info
PKG-INFO 14KB
requires.txt 95B
SOURCES.txt 3KB
top_level.txt 14B
dependency_links.txt 1B
setup.cfg 38B
forest_puller
common.py 2KB
extra_data
ipcc_columns.csv 907B
ipcc_rows.csv 458B
soef_rows.csv 574B
hpffre_columns.csv 436B
ipcc_subdivisions.csv 1KB
country_codes.csv 701B
soef_columns.csv 826B
tree_species_info.csv 1KB
cbm
concat.py 779B
agg.py 3KB
__init__.py 0B
country.py 11KB
tables
available_for_supply.py 4KB
average_growth.py 3KB
density_table.py 2KB
__init__.py 4KB
area_ipcc_vs_soef.py 2KB
max_area_over_time.py 3KB
hpffre
concat.py 495B
__init__.py 0B
zip_file.py 3KB
country.py 3KB
__init__.py 2KB
soef
links.py 2KB
composition.py 12KB
growing_stock.py 5KB
table_parser.py 9KB
concat.py 655B
agg.py 3KB
__init__.py 0B
xls_files.py 3KB
country.py 2KB
faostat
forestry
concat.py 505B
__init__.py 0B
zip_file.py 3KB
country.py 3KB
__init__.py 2KB
land
concat.py 501B
agg.py 3KB
__init__.py 0B
zip_file.py 4KB
country.py 3KB
ipcc
links.py 6KB
year.py 6KB
concat.py 638B
agg.py 3KB
headers.py 2KB
__init__.py 0B
zip_files.py 3KB
country.py 6KB
viz
increments_ipcc.py 2KB
genus_aggregate.py 3KB
increments.py 16KB
__init__.py 237B
genus_soef_vs_cbm.py 11KB
inc_aggregate.py 11KB
converted_to_tons.py 7KB
area_aggregate.py 5KB
genus_barstack.py 10KB
helper
color_rgb_code.py 2KB
multiplot.py 4KB
__init__.py 0B
solo_legend.py 2KB
gridspec_plot.py 2KB
facet.py 4KB
area.py 7KB
reports
base_template.py 1KB
__init__.py 0B
comparison
__init__.py 10KB
template
__init__.py 435B
setup.py 811B
README.md 12KB
scripts
ipcc
uncompress.py 895B
display_start_end_years.py 773B
viz
export_increments_svg.py 1KB
show_highest_area.py 1023B
export_df.py 695B
reports
comparison.py 2KB
LICENSE.txt 1KB
共 88 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功