How to Install Rasterio on MacOS?
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
Method 1: Using pip to install Rasterio Package
Follow the below steps to install the Rasterio package on macOS using pip:
Step 2: Check if pip3 and python3 are correctly installed.
python3 --version pip3 --version
Step 3: Upgrade your pip to avoid errors during installation.
pip3 install --upgrade pip
Step 4: Enter the following command to install Rasterio using pip3.
pip3 install rasterio
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
Step 2: Extract the downloaded package using the following command.
tar -xzvf rasterio.tar.gz
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
pip3 install GDAL
Note: You must have developer tools for XCode MacOS installed in your system
cd rasterio-1.2.8 python3 setup.py install
Verifying Rasterio installation on macOS:
Make the following import in your python terminal to verify if the installation has been done properly:
If there is any error while importing the module then is not installed properly.