Need human census data for any of your analyses? Follow these simple steps

25 02 2022

As someone who regularly delves into human demography — often from a conservation perspective — I’m always on the lookout for quick and easy ways to get the latest and greatest datasets. Whether it’s for projection human populations, or just getting country-specific population densities, I’ve found a really nice way to interface great human data with R.

In this particular example, I’m using a api (application programming interface) key to access live data on the US Census Bureau server (don’t worry — they have global data, not just those specific to the US). What’s an ‘api key’? It’s just a code that gives you permission to access the server directly from an application via an internet link.

Step 1. Apply for an api key

This is a straightforward process and just needs to be done via this URL. The approval process doesn’t take long.

Step 2: Install the idbr package in R

This stands for the ‘(US Census Bureau) International Data Base (R)’, and grants access to and queries demographic data, including contemporary, historical, and future projections to 2100 for countries with ≥ 5000 people.

install.packages(“idbr”)

Step 3: Set api key

You need to set your user api using the following commands:

apikey <- “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”
idbr::idb_api_key(apikey)

Step 4. Get data

Using the get_idb() command, you can specify all sorts of queries to get various levels of data complexity. All the variable combinations for the international database are described well here.

Example 1. Life expectancy

Let’s say you wanted to plot a map of the world with the shading of a country related to its average life expectancy at birth. First we get the necessary data:

lex.dat <- idbr::get_idb(
country = “all”,
year = 2022,
variables = c(“name”, “e0”),
geometry = T)

The ensuing lex.dat object looks like this:

Simple feature collection with 6 features and 4 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -73.41544 ymin: -55.25 xmax: 75.15803 ymax: 42.68825
Geodetic CRS: SOURCECRS
code year name e0 geometry
1 AF 2022 Afghanistan 53.65 MULTIPOLYGON (((61.21082 35…
2 AO 2022 Angola 62.11 MULTIPOLYGON (((16.32653 -5…
3 AL 2022 Albania 79.47 MULTIPOLYGON (((20.59025 41…
4 AE 2022 United Arab Emirates 79.56 MULTIPOLYGON (((51.57952 24…
5 AR 2022 Argentina 78.31 MULTIPOLYGON (((-65.5 -55.2…
6 AM 2022 Armenia 76.13 MULTIPOLYGON (((43.58275 41

Read the rest of this entry »




Sex on the beach

2 10 2018
Female green turtles (Chelonia mydas) spawning (top) and diving (bottom) on Raine Island (Great Barrier Reef, Queensland, Australia) — photos courtesy of Ian Bell. This species is ‘Endangered’ globally since 1982, mainly from egg harvesting (poaching conflict in Mexico for olive ridley Lepidochelys olivacea featured by National Geographic’s video here), despite the success of conservation projects (39). Green turtles inhabit tropical and subtropical seas in all oceans. Adults can grow > 150 kg and live for up to ~ 75 years. Right after birth, juveniles venture into the open sea to recruit ultimately in coastal areas until sexual maturity. They then make their first reproductive migration, often over 1000s of km (see footage of a real dive of a camera-equipped green turtle), to reach their native sandy beaches where pregnant females will lay their eggs. Each female can deposit more than one hundred eggs in her nest, and in several clutches in the same season because they can store the sperm from multiple mating events.

When sex is determined by the thermal environment, males or females might predominate under sustained climatic conditions. A study about marine turtles from the Great Barrier Reef illustrates how feminisation of a population can be partitioned geographically when different reproductive colonies are exposed to contrasting temperatures.

Fortunately, most people in Western societies already perceive that we live in a complex blend of sexual identities, far beyond the kind of genitals we are born with. Those identities start to establish themselves in the embryo before the sixth week of pregnancy. In the commonest scenario, for a human foetus XY with one maternal chromosome (X) and one paternal (Y) chromosome, the activation of the Sry gen (unique to Y) will trigger the differentiation of testicles and, via hormonal pathways, the full set of male characteristics (1).

Absence of that gene in an XX embryo will normally lead to a woman. However, in just one of many exceptions to the rule, Sry-expression failure in XY individuals can result in sterile men or ambiguous genitals — along a full gradient of intermediate sexes and, potentially, gender identities. A 2015 Nature ‘News’ feature echoes two extraordinary cases: (i) a father of four children found to bear a womb during an hernia operation, and (ii) a pregnant mother found to host both XX and XY cells during a genetic test – with her clinical geneticist stating “… that’s the kind of science-fiction material for someone who just came in for an amniocentesis” (2). These real-life stories simply reflect that sex determination is a complex phenomenon.

Three ways of doing it

In nature, there are three main strategies of sex determination (3) — see scheme here: Read the rest of this entry »





Twenty landmark papers in biodiversity conservation

13 10 2011

While I can’t claim that this is the first time one of my peer-reviewed papers has been inspired by ConservationBytes.com, I can claim that this is the first time a peer-reviewed paper is derived from the blog.

After a bit of a sordid history of review (isn’t it more and more like that these days?), I have the pleasure of announcing that our paper ‘Twenty landmark papers in biodiversity conservation‘ has now been published as an open-access chapter in the new book ‘Research in Biodiversity – Models and Applications‘ (InTech).

Perhaps not the most conventional of venues (at least, not for me), but it is at the very least ‘out there’ now and freely available.

The paper itself was taken, modified, elaborated and over-hauled from text written in this very blog – the ‘Classics‘ section of ConservationBytes.com. Now, if you’re an avid follower of CB, then the chapter won’t probably represent anything terribly new; however, I encourage you to read it anyway given that it is a vetted overview of possibly some of the most important papers written in conservation biology.

If you are new to the field, an active student or merely need a ‘refresher’ regarding the big leaps forward in this discipline, then this chapter is for you.

The paper’s outline is as follows: Read the rest of this entry »








%d bloggers like this: