Skip to Content
Mastering Geospatial Analysis with Python
book

Mastering Geospatial Analysis with Python

by Silas Toms, Paul Crickard, Eric van Rees
April 2018
Beginner to intermediate content levelBeginner to intermediate
440 pages
11h 36m
English
Packt Publishing
Content preview from Mastering Geospatial Analysis with Python

Using GDAL to create rasters

In the previous section, you learned how to load a raster, perform basic queries, modify it, and save it out as a new file. In this section, you will learn how to create a raster.

A raster is an array of values. So to create one, you start by creating an array, as shown in the following code:

 a_raster=np.array([ [10,10,1,10,10,10,10], [1,1,1,50,10,10,50], [10,1,1,51,10,10,50], [1,1,1,1,50,10,50]])

The previous code creates a numpy array with four rows of seven columns. Now that you have the array of data, you will need to set some basic properties. The following code will assign the values to variables and then you will pass them to the raster in the following example:

coord=(-106.629773,35.105389)w=10h=10name="BigI.tif" ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Geospatial Analysis with Python

Learning Geospatial Analysis with Python

Joel Lawhead

Publisher Resources

ISBN: 9781788293334Supplemental Content