Spaces:
Sleeping
Sleeping
File size: 3,458 Bytes
62dd0f3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import geopandas as gpd\n",
"from tqdm.notebook import tqdm\n",
"from joblib import Parallel, delayed"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "e90c443ceec74b3e9bf223587db76898",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/15 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://drive.google.com/open?id=1skBV8miaZN3gE2lPVnHQQG-n-RwbMH2d has 5 geometries\n",
"https://drive.google.com/open?id=12OJzdi0RE5BDdMHzBovnYK_QhC5jIiSy has 6 geometries\n",
"https://drive.google.com/open?id=1lge4nZKw7gxuDbQtM_v7D8eBHzUsLoBI has 3 geometries\n"
]
}
],
"source": [
"files = \"\"\"https://drive.google.com/open?id=1QHbcxHRw3EQWsw5-UN6AUnVI-bhmhCQ5\n",
"https://drive.google.com/open?id=1skBV8miaZN3gE2lPVnHQQG-n-RwbMH2d\n",
"https://drive.google.com/open?id=1jyG_D6UudyAgicZjsvEfNLT_vNK1G3EB\n",
"https://drive.google.com/open?id=1NxO399MvzufeT6-xigq3qi79psA40rkQ\n",
"https://drive.google.com/open?id=1P2ZPMsxX82P12m460EBjpYMrdXUkZ05l\n",
"https://drive.google.com/open?id=1Pc4sIYbRcu761fuXV5HVDG3EaqQC-uiz\n",
"https://drive.google.com/open?id=1xskOyh888HrxCrB0Ue9bNGG6r1CvlH3J\n",
"https://drive.google.com/open?id=12OJzdi0RE5BDdMHzBovnYK_QhC5jIiSy\n",
"https://drive.google.com/open?id=18bDqdNIZOlp97GHpEOaYsCLSTML--aEA\n",
"https://drive.google.com/open?id=1lge4nZKw7gxuDbQtM_v7D8eBHzUsLoBI\n",
"https://drive.google.com/open?id=1XzzPh1q0uU3eMPoSC5stCLC7r8oMtgok\n",
"https://drive.google.com/open?id=1JGmGCVYjdcUeFVmcoa7LcJE36HH0MGoF\n",
"https://drive.google.com/open?id=1EPp6DZUGFcUESQSeMjQ9famygnWM-3BM\n",
"https://drive.google.com/open?id=1XY7HbmY0fakAaZaxvUFF5UYk7Qovnit2\n",
"https://drive.google.com/open?id=1VSVOpw9TFAxPKClHGPFXI_anBSHZOIi-\"\"\"\n",
"\n",
"df = pd.DataFrame(columns=['Failed URL', '# of geometries'])\n",
"i = 0\n",
"def get_gdf(link):\n",
" link = link.strip()\n",
" original_link = link\n",
" if link.startswith('https://drive.google.com/open?id='):\n",
" link = 'https://drive.google.com/uc?id=' + link.split('=')[-1]\n",
" gdf = gpd.read_file(link)\n",
" if len(gdf) != 1:\n",
" print(f\"{original_link} has {len(gdf)} geometries\")\n",
" # df.loc[i, ['Failed URL', '# of geometries']] = [original_link, len(gdf)]\n",
" # i += 1\n",
" \n",
"# df.to_csv('failed_links.csv', index=False)\n",
"_ = Parallel(n_jobs=32)(delayed(get_gdf)(link) for link in tqdm(files.split('\\n')))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "zeel_py310",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.15"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|