centreborelli / s2p

Satellite Stereo Pipeline
GNU Affero General Public License v3.0
207 stars 67 forks source link

There is a error in the line198 of s2p/s2p/geographiclib.py. The code can not find 'json'.load(f). Can I add the "import json"? #68

Closed yueluming closed 4 years ago

carlodef commented 4 years ago

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.

yueluming commented 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
yueluming commented 4 years ago

I run this code with pycharm, and it comes with the error. Can I use 'import json' or 'a=geojson.load(f)'

yueluming commented 4 years ago

And I want to the defination of the coordination of the Roi_x, Roi_y.

gfacciol commented 4 years ago

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.

carlodef commented 4 years ago

Fixed in commit 195d3ba6bfed