Skip to content
Related Articles

Related Articles

How to Install Rasterio on MacOS?

View Discussion
Improve Article
Save Article
  • Last Updated : 30 Sep, 2021
View Discussion
Improve Article
Save Article

In this article, we will learn how to install Rasterio in Python on MacOS. Rasterio is used to access geospatial raster data.

Geographic information systems use GeoTIFF and other formats to organize and store gridded raster datasets such as satellite imagery and terrain models. Rasterio reads and writes these formats and provides a Python API based on Numpy N-dimensional arrays and GeoJSON

Installation:

Method 1: Using pip to install Rasterio Package

Follow the below steps to install the Rasterio package on macOS using pip:

Step 1: Install the latest Python3 in MacOS

Step 2: Check if pip3 and python3 are correctly installed.

python3 --version
pip3 --version

checking python and pip version in macos

Step 3: Upgrade your pip to avoid errors during installation.

pip3 install --upgrade pip

upgrading pip in macos

Step 4: Enter the following command to install Rasterio using pip3.

pip3 install rasterio

installing Rasterio package on macOS using pip

Method 2: Using setup.py to install Rasterio 

Follow the below steps to install the Rasterio package on macOS using the setup.py file:

Step 1: Download the latest source package of Rasterio for python3 from here.

curl https://files.pythonhosted.org/packages/5a/64/91fcf8482d5c380b68b4f69d5b0c75785db038b6923481b8e53234cf826f/rasterio-1.2.8.tar.gz > rasterio.tar.gz

downloading the source package for Rasterio in macos

Step 2: Extract the downloaded package using the following command.

tar -xzvf rasterio.tar.gz

extracting the rasterio.tar.gz file in macos

Step 3: Go inside the folder and Enter the following command to install the package.

Note: Run the following two commands in terminal before installing via setup.py

Install homebrew before running the below command.
brew install gdal

install gdal via brew

pip3 install GDAL

install gdal via pip3

Note: You must have developer tools for XCode MacOS installed in your system

cd rasterio-1.2.8
python3 setup.py install

installing Rasterio on macOS using the setup.py file

Verifying Rasterio installation on macOS:

Make the following import in your python terminal to verify if the installation has been done properly:

import rasterio

Verifying Rasterio installation on macOS

If there is any error while importing the module then is not installed properly.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!