This article describes the procedure for reading GeoJSON files into EarthAI Notebook.
The first method utilizes the GeoPandas library whose geopandas.read_file()
command can read most vector-based spatial data formats. If the GeoJSON file of interest is already in your EarthAI Notebook environment the code below will read it in from the local notebook directory.
import geopandas as gpd
df = gpd.read_file('<filename>.geojson')
You can confirm that df is indeed a GeoDataFrame by running:
type(df)
If the GeoJSON file resides external to the EarthAI Notebook environment, say at a particular URL, you simply run the following instead.
import geopandas as gpd
df = gpd.read_file('<url address to the .geojson file>')
Alternatively, a GeoJSON file can be read in as a Spark DataFrame.
from earthai.init import *
df = spark.read.geojson('<filename>.geojson')
You can confirm that a Spark DataFrame has been created by running:
type(df)
Comments
0 comments
Please sign in to leave a comment.