【问题标题】:What is the json file I need to read?我需要阅读的 json 文件是什么?
【发布时间】:2019-09-01 12:47:49
【问题描述】:

enter image description here我需要使用python下载卫星图像。我在 GitHub 中找到了一个代码,但我不明白这一行是什么。请帮我看看它到底是什么。 访问https://github.com/kscottz/PythonFromSpace/blob/master/TheBasics.ipynb

import sys
import os
import json
import scipy
import urllib
import datetime 
import urllib3
import rasterio
import subprocess
import numpy as np
import pandas as pd
import seaborn as sns
from osgeo import gdal
from planet import api
from planet.api import filters
from traitlets import link
import rasterio.tools.mask as rio_mask
from shapely.geometry import mapping, shape
from IPython.display import display, Image, HTML
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
urllib3.disable_warnings()
from ipyleaflet import (
    Map,
    Marker,
    TileLayer, ImageOverlay,
    Polyline, Polygon, Rectangle, Circle, CircleMarker,
    GeoJSON,
    DrawControl
)

%matplotlib inline
# will pick up api_key via environment variable PL_API_KEY
# but can be specified using `api_key` named argument
api_keys = json.load(open("apikeys.json",'r'))
client = api.ClientV1(api_key=api_keys["PLANET_API_KEY"])
# Make a slippy map to get GeoJSON
api_keys = json.load(open("apikeys.json",'r')) 
client = api.ClientV1(api_key=api_keys["PLANET_API_KEY"])

这两行是什么意思。我应该为 apikeys.json 上传什么文件

【问题讨论】:

    标签: python python-3.x python-2.7 list python-requests


    【解决方案1】:

    您应该点击此链接获取 API 密钥。 https://support.planet.com/hc/en-us/articles/212318178-What-is-my-API-key-

    apikeys.json 是 json 中以下格式/内容的 JSON 文件:

    {"PLANET_API_KEY":"<Some API Key here>"}
    

    json.load(...) API 将此 json 文件加载为字典

    【讨论】:

    • 我有我的 api 密钥,但是当我放置 api 密钥时,它说没有为行 api_keys = json.load(open("apikeys.json",'r')) 找到这样的火灾或目录
    • 请在文件名中给出从根目录开始的完整路径。例如,如果 /Users/abc/Downloads/apikeys.json 是完整路径,则 api_keys = json.load(open("/Users/abc/Downloads/apikeys.json",'r'))
    • 但是我应该上传哪个文件。我没有这样的文件。
    • 如果您的 API 密钥是“abcdxyz”,那么您将创建一个包含以下内容的 apikeys.json 文件:{"PLANET_API_KEY":"abcdxyz"}
    • 非常感谢对我的帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-24
    • 2023-03-04
    相关资源
    最近更新 更多