text: In this example, we will read a shapefile as a Spark DataFrame. First, download a shapefile and upload into your file browser in the EarthAI Notebook app. In this example, we will work with the Natural Earth tiny countries data .
  If the shapefile is zipped, unzip it. You can do this in a notebook cell with
  ! unzip ne_110m_admin_0_tiny_countries.zip.
  In [1]:
  from earthai.init import * import requests import zipfile import os # Download a shapefile, upload into your directory shapefile_url = '' shapefile_path = 'ne_110m_admin_0_tiny_countries.zip' # shapefile_path = os.path.join( # os.path.abspath(os.curdir), # shapefile_path) shapefile_path = os.path.abspath(shapefile_path) # download the shapefile to the shapefile path with requests.get(shapefile_url) as r: with open(shapefile_path, 'wb') as f: f.write(r.content) # unzip with zipfile.ZipFile(shapefile_path, 'r') as zip_ref: zip_ref.extractall(os.curdir)
  Importing EarthAI libraries. EarthAI version 1.4.0; RasterFrames version 0.9.0.dev+astraea.1ce1ff3; PySpark version 2.4.4 Creating SparkSession...
  SparkSession is available as `spark`.
  In the call to
  read.shapefile, pass the full path to either the .shp or .zip file.
  In [2]:
  df = spark.read.shapefile(os.path.abspath('ne_110m_admin_0_tiny_countries.zip')) df.select('__fid__', 'geometry', 'name')
  Out[2]:
  We can work with this DataFrame as shown in the RasterFrames documentation and in querying raster data with vectors.
  Article is closed for comments.