create classes
]
},
{
- "cell_type": "code",
- "execution_count": 1,
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "-- Found 250 rasters\n"
- ]
- }
- ],
"source": [
- "# Prepare a list of Images\n",
+ "```python\n",
+ "# Imports\n",
+ "import arcpy\n",
"from glob import glob\n",
+ "from multiprocessing.pool import Pool\n",
+ "import os\n",
+ "\n",
+ "# Prepare a list of Images\n",
"rasters = glob(r'c:\\data\\imagery\\**\\*.sid')\n",
- "print(f\"-- Found {len(rasters)} rasters\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
+ "print(f\"-- Found {len(rasters)} rasters\")\n",
+ "\n",
"# other parameters\n",
"lbl_shp = r'c:\\data\\labels\\uswtdbSHP\\uswtdb_v4_0_20210409_buffer_25m.shp'\n",
"tile_size = 400\n",
"cell_size = 0.6\n",
- "output_path = r\"c:\\data\\exported_training_data\""
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
+ "output_path = r\"c:\\data\\exported_training_data\"\n",
+ "\n",
"# Prepare arguments list\n",
- "import os\n",
"arglist = []\n",
"for idx, raster in enumerate(rasters):\n",
" outpath = os.path.join(output_path, os.path.basename(raster)[:4])\n",
" \"PROCESS_AS_MOSAICKED_IMAGE\",\n",
" \"NO_BLACKEN\",\n",
" \"FIXED_SIZE\"\n",
- " ))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "-- Done\n"
- ]
- }
- ],
- "source": [
+ " ))\n",
+ " \n",
"# Export training data using multiprocessing\n",
- "from multiprocessing.pool import Pool\n",
- "import arcpy\n",
"nprocesses = os.cpu_count() - 1\n",
"print(f\"-- using {nprocesses} Processes\")\n",
"my_pool = Pool(nprocesses)\n",
"print(\"-- Done\")\n",
"my_pool.close()\n",
"my_pool.join()\n",
- "del my_pool"
+ "del my_pool\n",
+ "```"
]
},
{
]
},
{
- "attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
]
},
{
- "attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
]
},
{
- "attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
]
},
{
- "attachments": {},
"cell_type": "markdown",
"metadata": {},
"source": [
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.7.10"
+ "version": "3.7.11"
}
},
"nbformat": 4,
