Last active
May 17, 2020 11:00
-
-
Save syedmisbah/a26c47c1f8aaff7ceb30d1ad197c0bd0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SetWD | |
setwd("C:/Users/misba/Desktop/PROCESS/") | |
#Load libraires | |
library(dplyr) | |
library(raster) | |
library(rgdal) | |
library(data.table) | |
#Read object | |
raster_object <- raster(tiff_file) | |
#Extract XY eastings and northing values and population values | |
population_df <- as.data.frame(raster_object, xy=TRUE) | |
names(population_df) <- c("X","Y","Population") | |
#Remove rows with 0 population to reduce size | |
population_df <- population_df %>% filter(Population!=0) | |
#Write to dataframe | |
fwrite(population_df, "XY_POP_DATA_FULL.csv", row.names=FALSE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment