Skip to main content
Tweeted twitter.com/StackGIS/status/1369800285376372743
Removed caps
Source Link
Aaron
  • 51.8k
  • 29
  • 157
  • 321

I have a UN-Adjusted Population Count dataset, for the year 2015, stored in a TIFF file format (~450MB) downloaded from http://sedac.ciesin.columbia.edu/data/collection/gpw-v4/sets/browse

In R I am able to read the data using raster package. I am also able to plot it as follows,

#read your TIFF file

worldpopcount <- raster("gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals_2015.tif")

worldpopcount

plot(worldpopcount)

Now I want to crop the West African region (covering the three countries Guinea, Liberia and Sierra Leone). My coordinates for West Africa are,

# extent format (xmin,xmax,ymin,ymax)

# WestBound     -16
# EastBound      -7.25
# SouthBound      4
# NorthBound     12.75

HOW DOHow do I CROP THE DATA USING EXTENTcrop the data using extent/CROPcrop? Once the region of interest has been cropped I would like to export it to an asc (ESRI ASCII) using the code

#writeRaster(r, filename="westAfrica.asc", format = "ascii", datatype='INT4S', overwrite=TRUE)

I have a UN-Adjusted Population Count dataset, for the year 2015, stored in a TIFF file format (~450MB) downloaded from http://sedac.ciesin.columbia.edu/data/collection/gpw-v4/sets/browse

In R I am able to read the data using raster package. I am also able to plot it as follows,

#read your TIFF file

worldpopcount <- raster("gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals_2015.tif")

worldpopcount

plot(worldpopcount)

Now I want to crop the West African region (covering the three countries Guinea, Liberia and Sierra Leone). My coordinates for West Africa are,

# extent format (xmin,xmax,ymin,ymax)

# WestBound     -16
# EastBound      -7.25
# SouthBound      4
# NorthBound     12.75

HOW DO I CROP THE DATA USING EXTENT/CROP? Once the region of interest has been cropped I would like to export it to an asc (ESRI ASCII) using the code

#writeRaster(r, filename="westAfrica.asc", format = "ascii", datatype='INT4S', overwrite=TRUE)

I have a UN-Adjusted Population Count dataset, for the year 2015, stored in a TIFF file format (~450MB) downloaded from http://sedac.ciesin.columbia.edu/data/collection/gpw-v4/sets/browse

In R I am able to read the data using raster package. I am also able to plot it as follows,

#read your TIFF file

worldpopcount <- raster("gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals_2015.tif")

worldpopcount

plot(worldpopcount)

Now I want to crop the West African region (covering the three countries Guinea, Liberia and Sierra Leone). My coordinates for West Africa are,

# extent format (xmin,xmax,ymin,ymax)

# WestBound     -16
# EastBound      -7.25
# SouthBound      4
# NorthBound     12.75

How do I crop the data using extent/crop? Once the region of interest has been cropped I would like to export it to an asc (ESRI ASCII) using the code

#writeRaster(r, filename="westAfrica.asc", format = "ascii", datatype='INT4S', overwrite=TRUE)

I have a UN-Adjusted Population Count dataset, for the year 2015, stored in a TIFF file format (~450MB) downloaded from http://sedac.ciesin.columbia.edu/data/collection/gpw-v4/sets/browse

In R I am able to read the data using raster package. I am also able to plot it as follows,

#read your TIFF file

worldpopcount <- raster("gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals_2015.tif")

worldpopcount

plot(worldpopcount)

#read your TIFF file

worldpopcount <- raster("gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals_2015.tif")

worldpopcount

plot(worldpopcount)

Now I want to crop the West African region (covering the three countries Guinea, Liberia and Sierra Leone). My coordinates for West Africa are,

extent format (xmin,xmax,ymin,ymax)

WestBound -16

EastBound -7.25

SouthBound 4

NorthBound 12.75

# extent format (xmin,xmax,ymin,ymax)

# WestBound     -16
# EastBound      -7.25
# SouthBound      4
# NorthBound     12.75

HOW DO I CROP THE DATA USING EXTENT/CROP? Once the region of interest has been cropped I would like to export it to an asc (ESRI ASCII) using the code

#writeRaster(r, filename="westAfrica.asc", format = "ascii", datatype='INT4S', overwrite=TRUE)

#writeRaster(r, filename="westAfrica.asc", format = "ascii", datatype='INT4S', overwrite=TRUE)

I have a UN-Adjusted Population Count dataset, for the year 2015, stored in a TIFF file format (~450MB) downloaded from http://sedac.ciesin.columbia.edu/data/collection/gpw-v4/sets/browse

In R I am able to read the data using raster package. I am also able to plot it as follows,

#read your TIFF file

worldpopcount <- raster("gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals_2015.tif")

worldpopcount

plot(worldpopcount)

Now I want to crop the West African region (covering the three countries Guinea, Liberia and Sierra Leone). My coordinates for West Africa are,

extent format (xmin,xmax,ymin,ymax)

WestBound -16

EastBound -7.25

SouthBound 4

NorthBound 12.75

HOW DO I CROP THE DATA USING EXTENT/CROP? Once the region of interest has been cropped I would like to export it to an asc (ESRI ASCII) using the code

#writeRaster(r, filename="westAfrica.asc", format = "ascii", datatype='INT4S', overwrite=TRUE)

I have a UN-Adjusted Population Count dataset, for the year 2015, stored in a TIFF file format (~450MB) downloaded from http://sedac.ciesin.columbia.edu/data/collection/gpw-v4/sets/browse

In R I am able to read the data using raster package. I am also able to plot it as follows,

#read your TIFF file

worldpopcount <- raster("gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals_2015.tif")

worldpopcount

plot(worldpopcount)

Now I want to crop the West African region (covering the three countries Guinea, Liberia and Sierra Leone). My coordinates for West Africa are,

# extent format (xmin,xmax,ymin,ymax)

# WestBound     -16
# EastBound      -7.25
# SouthBound      4
# NorthBound     12.75

HOW DO I CROP THE DATA USING EXTENT/CROP? Once the region of interest has been cropped I would like to export it to an asc (ESRI ASCII) using the code

#writeRaster(r, filename="westAfrica.asc", format = "ascii", datatype='INT4S', overwrite=TRUE)
Source Link
Ash
  • 115
  • 1
  • 1
  • 5

Crop a raster file in R

I have a UN-Adjusted Population Count dataset, for the year 2015, stored in a TIFF file format (~450MB) downloaded from http://sedac.ciesin.columbia.edu/data/collection/gpw-v4/sets/browse

In R I am able to read the data using raster package. I am also able to plot it as follows,

#read your TIFF file

worldpopcount <- raster("gpw-v4-population-count-adjusted-to-2015-unwpp-country-totals_2015.tif")

worldpopcount

plot(worldpopcount)

Now I want to crop the West African region (covering the three countries Guinea, Liberia and Sierra Leone). My coordinates for West Africa are,

extent format (xmin,xmax,ymin,ymax)

WestBound -16

EastBound -7.25

SouthBound 4

NorthBound 12.75

HOW DO I CROP THE DATA USING EXTENT/CROP? Once the region of interest has been cropped I would like to export it to an asc (ESRI ASCII) using the code

#writeRaster(r, filename="westAfrica.asc", format = "ascii", datatype='INT4S', overwrite=TRUE)