Beispiel #1
0
def read_shape(path):
    sp = com._check_package('shapely.geometry')
    fiona = com._check_package('fiona')

    results = []
    with fiona.open(path) as f:
        for shape in f:
            shape = sp.shape(shape['geometry'])
            result = to_entity(shape)
            if isinstance(result, list):
                results.extend(result)
            else:
                results.append(result)
    return results
Beispiel #2
0
    def contour(self, x, y, z):
        """
        Plot contours using cesiumpy.Polyline

        Parameters
        ----------

        X : np.ndarray
        Y : np.ndarray
        Y : np.ndarray

        *X* and *Y* must both be 2-D with the same shape as *Z*, or they
        must both be 1-D such that ``len(X)`` is the number of columns in
        *Z* and ``len(Y)`` is the number of rows in *Z*.
        """

        plt = com._check_package('matplotlib.pyplot')
        contours = plt.contour(x, y, z)

        for segs, c in zip(contours.allsegs, contours.tcolors):
            c = cesiumpy.color.Color(*c[0])
            for seg in segs:
                pos = seg.flatten().tolist()
                p = cesiumpy.Polyline(positions=pos, material=c)
                self.widget.entities.add(p)
        plt.close()
        return self.widget
Beispiel #3
0
def read_geojson(path):

    sp = com._check_package('shapely.geometry')

    with open(path) as f:
        geos = json.load(f)

    # shapely can't parse featurecollection directly
    results = []
    for feature in geos['features']:
        shape = sp.shape(feature['geometry'])
        result = to_entity(shape)
        if isinstance(result, list):
            results.extend(result)
        else:
            results.append(result)
    return results
Beispiel #4
0
 def _geometry(self):
     return com._check_package('shapely.geometry')
Beispiel #5
0
 def _spatial(self):
     return com._check_package('scipy.spatial')
Beispiel #6
0
 def _np(self):
     return com._check_package('numpy')
Beispiel #7
0
 def __init__(self, name):
     plt = com._check_package('matplotlib.pyplot')
     self.name = name
     self.cm = plt.get_cmap(name)