def test_crop_pandas(self): """ Test cropping (within process) for vector inputs """ reader1 = readers.GaiaReader( os.path.join(testfile_path, 'iraq_hospitals.geojson')) reader2 = readers.GaiaReader( os.path.join(testfile_path, 'baghdad_districts.geojson')) output = crop(reader1.read(), reader2.read()) self.assertEqual(len(output.get_data()), 19)
def create(*args, **kwargs): """ Convenience method to provide a simpler API for creating GaiaDataObject """ from gaia.io import readers reader = readers.GaiaReader(*args, **kwargs) return reader.read()
def test_crop_gdal(self): """ Test cropping (subset process) for vector & raster inputs """ try: reader1 = readers.GaiaReader( os.path.join(testfile_path, 'globalairtemp.tif')) rasterData = reader1.read() reader2 = readers.GaiaReader( os.path.join(testfile_path, '2states.geojson')) vectorData = reader2.read() output = crop(rasterData, vectorData) self.assertEqual(type(output.get_data()).__name__, 'Dataset') except Exception: raise
def test_crop_gdal(self): """ Test cropping (subset process) for vector & raster inputs """ zipfile = ZipFile(os.path.join(testfile_path, '2states.zip'), 'r') zipfile.extract('2states.geojson', testfile_path) try: reader1 = readers.GaiaReader( os.path.join(testfile_path, 'globalairtemp.tif')) rasterData = reader1.read() reader2 = readers.GaiaReader( os.path.join(testfile_path, '2states.geojson')) vectorData = reader2.read() output = crop(rasterData, vectorData) self.assertEqual(type(output.get_data()).__name__, 'Dataset') finally: testfile = os.path.join(testfile_path, '2states.geojson') if os.path.exists(testfile): os.remove(testfile)
def create(data_source, *args, **kwargs): """ Convenience method to provide a simpler API for creating GaiaDataObject :param data_source: the source data for the object. Can be one of: * a path (string) on local filesystem * a web url (string) that Gaia can download from * a python object (numpy array, GeoPandas dataframe, etc.) * TBD a tuple indicating postgis parameters * a 2-tuple specifying a GirderInterface object and path(string) to the file :return: Gaia data obkject """ from gaia.io import readers reader = readers.GaiaReader(data_source, *args, **kwargs) return reader.read()