Closed yueluming closed 4 years ago
s2p/geographiclib.py
import os import subprocess from distutils.version import LooseVersion
import pyproj import numpy as np import rasterio from rasterio.crs import CRS as RioCRS from pyproj.enums import WktVersion
def read_lon_lat_poly_from_geojson(geojson): """ Read a (lon, lat) polygon from a geojson file or dict.
Args:
geojson: file path to a geojson file containing a single polygon,
or content of the file as a dict.
The geojson's top-level type should be either FeatureCollection,
Feature, or Polygon.
Returns:
ll_poly: list of polygon vertices (lon, lat) coordinates
"""
# extract lon lat from geojson file or dict
if isinstance(geojson, str):
with open(geojson, 'r') as f:
a = json.load(f) #####################################Unresolved reference 'json'
else:
a = geojson
if a["type"] == "FeatureCollection":
a = a["features"][0]
if a["type"] == "Feature":
a = a["geometry"]
ll_poly = np.array(a["coordinates"][0])
return ll_poly
I run this code with pycharm, and it comes with the error. Can I use 'import json' or 'a=geojson.load(f)'
And I want to the defination of the coordination of the Roi_x, Roi_y.
This is an actual issue, you can use
import json
the coordinates roi_x, roi_y correspond to the upper left corner of the region of interest defined in pixel coordinates on the reference image.
Fixed in commit 195d3ba6bfed
Could you post the full error traceback and tell us which command you ran to get this error?
And please stop typing everything in issue titles, there is a larger text field just below where you can put more text.