def test_reproject_gdf_utm_default(self): input_data = os.path.join(data_dir, 'gt_epsg4326.json') output = reproject(input_data) expected_result = gpd.read_file(os.path.join(data_dir, 'gt.geojson')) out_geoms = cascaded_union(output.geometry) exp_geoms = cascaded_union(expected_result.geometry) assert out_geoms.intersection(exp_geoms).area/out_geoms.area > 0.99999
def test_reproject_gdf(self): input_data = os.path.join(data_dir, 'gt.geojson') output = reproject(input_data, target_crs=4326, dest_path=os.path.join(data_dir, 'tmp.json')) expected_result = gpd.read_file(os.path.join(data_dir, 'gt_epsg4326.json')) out_geoms = cascaded_union(output.geometry) exp_geoms = cascaded_union(expected_result.geometry) assert out_geoms.intersection(exp_geoms).area/out_geoms.area > 0.99999 os.remove(os.path.join(data_dir, 'tmp.json'))
def test_reproject_rasterio_dataset(self): input_data = os.path.join(data_dir, 'sample_geotiff.tif') output = reproject(input_data, target_crs=4326, dest_path=os.path.join(data_dir, 'tmp.tiff')) with rasterio.open(input_data) as input_rio: input_bounds = input_rio.bounds expected_bounds = rasterio.warp.transform_bounds(input_rio.crs, 'EPSG:4326', *input_bounds) expected_bounds = tuple([round(i, 4) for i in tuple(expected_bounds)]) output_bounds = tuple([round(i, 4) for i in tuple(output.bounds)]) assert expected_bounds == output_bounds assert output.crs.to_epsg() == 4326 os.remove(os.path.join(data_dir, 'tmp.tiff'))