TransWikia.com

How can I plot WorldPopProject data (GeoTIFF) in R with an appropriate scale?

Geographic Information Systems Asked by Lexa on July 13, 2021

I am a complete beginner to using any GIS tools and struggling through some very basic concepts.

I am trying to load data from the WorldPopProject (https://www.worldpop.org/geodata/summary?id=6365) and though I’m successful in converting the file into a raster that I can plot, the scale is from 0 to 1. The site says "The units are number of people per pixel" and I have to imagine more than 1 person can live in a pixel when the resolution is 3 arc/100m at equator.

library(raster) #Required for raster files. Also loads 'sp' package
library(rgdal) #Required to manipulate GEOTIFF and advanced tools
library(tiff) #Required for reading in TIFF
library(ggplot2) #Plotting
#Seemingly all the GIS functions were built under 3.6.2 (?)

ghanaPopLocation = "filepath_inserted_here"

# Loading and conversion
ghanaPop = readTIFF(ghanaPopLocation) #Get initial GEOTIFF loaded
ghanaPopRaster = raster(ghanaPop) #Convert GEOTIFF to raster

# Plotting
plot(ghanaPopRaster)

A plot of Ghana's population density with a scale of 0 to 1

Am I misinterpreting this plot, the data itself, or have I done something wrong?

One Answer

Don't use readTIFF for reading GeoTIFF files. It will not read the spatial information and may mess up in other ways too:

 ghanaPop = readTIFF(ghanaPopLocation) #Get initial GEOTIFF loaded

use raster from the raster package:

> gpop = raster("./gha_ppp_2020.tif")

and you get something with coordinates:

> gpop
class       : RasterLayer 
dimensions  : 7721, 5337, 41206977  (nrow, ncol, ncell)
resolution  : 0.0008333333, 0.0008333333  (x, y)
extent      : -3.255417, 1.192083, 4.73875, 11.17292  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : /mmfs1/storage/users/rowlings/Weather/gha_ppp_2020.tif 
names       : gha_ppp_2020 
values      : 0.03166041, 240.6693  (min, max)

and you'll see its max value is 240.6 people per pixel.

Correct answer by Spacedman on July 13, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP