Loading the data into the dataset

To load the data into the new dataset, we will iterate through the features contained in the zip codes GeoJSON, writing them all to the dataset (instead of just one as demonstrated earlier). As this file is larger than 5MB, it must be loaded using the API, which is accessed using the mapbox module. The ID of the dataset (retrieved using the datasets.list method), the row ID, and the feature, are all required parameters for the update_feature method:

listing_resp = datasets.list()
dataset_id = [ds['id'] for ds in listing_resp.json()][0]
data = json.load(open(r'ztca_bayarea.geojson'))
for count,feature in enumerate(data['features']):
resp = datasets.update_feature(dataset_id, count, feature)

The completed dataset now looks like this in Mapbox Studio:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset