Skip to content

NPNPhenor

The NPNPhenor module contains functionality to download and load data from NPN, using phenor as client.

Requires phenor R package. Install with

devtools::install_github("bluegreen-labs/phenor@v1.3.1")

It can be tricky to figure out which combinations of species/phenophases are available. This link may serve as a starting point: https://data.usanpn.org/observations/get-started.

Example: List IDs and names for available species
>>> from springtime.datasets.insitu.npn.NPNPhenor import npn_species
>>> df = npn_species()
>>> df.head()
   species_id         common_name  ...  family_name  family_common_name
1         120        'ohi'a lehua  ...    Myrtaceae       Myrtle Family
2        1436          absinthium  ...   Asteraceae        Aster Family
3        1227  Acadian flycatcher  ...   Tyrannidae  Tyrant Flycatchers
4        1229    acorn woodpecker  ...      Picidae         Woodpeckers
5        2110        Adam and Eve  ...  Orchidaceae       Orchid Family
<BLANKLINE>
[5 rows x 18 columns]
Example: List IDs and names for available phenophases
>>> from springtime.datasets.insitu.npn.NPNPhenor import npn_phenophases
>>> npn_phenophases()  # prints a long list
    phenophase_id                  phenophase_name phenophase_category  color
1              56                      First leaf               Leaves   <NA>
2              57             75% leaf elongation               Leaves   <NA>
3              58                    First flower              Flowers   <NA>
4              59                      Last flower             Flowers   <NA>
...
Example: Load dataset
>>> from springtime.datasets.insitu.npn.NPNPhenor import NPNPhenor
>>> dataset = NPNPhenor(species=36, phenophase=483, years=[2010, 2011])
>>> dataset.download()
>>> gdf = dataset.load()
>>> gdf.head()
   site_id  ...                    geometry
1    17967  ...  POINT (-91.37602 38.38862)
2    17994  ...  POINT (-79.97169 39.53892)
3    17999  ...  POINT (-85.60993 39.79147)
4    18032  ...  POINT (-76.62881 40.94780)
5    18051  ...  POINT (-91.69318 41.29201)
<BLANKLINE>
[5 rows x 24 columns]
Example: Or with area bounds:
>>> from springtime.datasets.insitu.npn.NPNPhenor import NPNPhenor
>>> dataset = NPNPhenor(
...     species = 3,
...     phenophase = 371,
...     years = [2010, 2011],
...     area = {'name':'some', 'bbox':(4, 45, 8, 50)}
... )
>>> dataset.download()
>>> gdf = dataset.load()
>>> gdf.head()
   site_id  ...                    geometry
1        2  ...  POINT (-70.69133 43.08535)
2      459  ...  POINT (-92.75200 36.52450)
3      374  ...  POINT (-87.64120 38.05990)
4      950  ...  POINT (-81.75751 30.17840)
5     1068  ...  POINT (-75.15203 38.77611)
<BLANKLINE>
[5 rows x 24 columns]

NPNPhenor

Bases: Dataset

Download and load data from NPN.

Attributes:

Name Type Description
years

timerange. For example years=[2000, 2002] downloads data for three years.

resample

Resample the dataset to a different time resolution. If None, no resampling.

species int

npn species id

phenophase int

npn phenophase id

area Optional[NamedArea]

A dictionary of the form {"name": "yourname", "bbox": [xmin, ymin, xmax, ymax]}.

directory property

Return the directory where data is stored.

download()

Download the data.

load()

Load the dataset into memory.

npn_species(species=ro.NULL, list=True)

List the available species.

npn_phenophases(phenophase=ro.NULL, list=True)

List the available phenophases.