Esempio n. 1
0
    def test_ogr_add_feature(self):
        ds = gdal_create_dataset('Memory', 'test',
                                 gdal_type=gdal.OF_VECTOR)
        georef.ogr_create_layer(ds, 'test', geom_type=ogr.wkbPoint,
                                fields=[('index', ogr.OFTReal)])

        point = np.array([1198054.34, 648493.09])
        parr = np.array([point, point, point])
        georef.ogr_add_feature(ds, parr)
        georef.ogr_add_feature(ds, parr, name='test')
Esempio n. 2
0
    def test_ogr_add_feature(self):
        ds = wradlib.io.gdal_create_dataset("Memory", "test", gdal_type=gdal.OF_VECTOR)
        georef.ogr_create_layer(
            ds, "test", geom_type=ogr.wkbPoint, fields=[("index", ogr.OFTReal)]
        )

        point = np.array([1198054.34, 648493.09])
        parr = np.array([point, point, point])
        georef.ogr_add_feature(ds, parr)
        georef.ogr_add_feature(ds, parr, name="test")
Esempio n. 3
0
    def test_ogr_add_feature(self):
        ds = gdal_create_dataset('Memory', 'test', gdal_type=gdal.OF_VECTOR)
        georef.ogr_create_layer(ds,
                                'test',
                                geom_type=ogr.wkbPoint,
                                fields=[('index', ogr.OFTReal)])

        point = np.array([1198054.34, 648493.09])
        parr = np.array([point, point, point])
        georef.ogr_add_feature(ds, parr)
        georef.ogr_add_feature(ds, parr, name='test')
Esempio n. 4
0
    def _check_src(self, src):
        """ Basic check of source elements (sequence of points or polygons).

            - array cast of source elements
            - create ogr_src datasource/layer holding src points/polygons
            - transforming source grid points/polygons to ogr.geometries
              on ogr.layer
        """
        ogr_src = io.gdal_create_dataset('Memory',
                                         'out',
                                         gdal_type=gdal.OF_VECTOR)

        try:
            # is it ESRI Shapefile?
            ds_in, tmp_lyr = io.open_shape(
                src, driver=ogr.GetDriverByName('ESRI Shapefile'))
            ogr_src_lyr = ogr_src.CopyLayer(tmp_lyr, self._name)
            if self._srs is None:
                self._srs = ogr_src_lyr.GetSpatialRef()
        except IOError:
            # no ESRI shape file
            raise
        # all failed? then it should be sequence or numpy array
        except RuntimeError:
            src = np.array(src)
            # create memory datasource, layer and create features
            if src.ndim == 2:
                geom_type = ogr.wkbPoint
            # no Polygons, just Points
            else:
                geom_type = ogr.wkbPolygon
            fields = [('index', ogr.OFTInteger)]
            georef.ogr_create_layer(ogr_src,
                                    self._name,
                                    srs=self._srs,
                                    geom_type=geom_type,
                                    fields=fields)
            georef.ogr_add_feature(ogr_src, src, name=self._name)

        return ogr_src