Skip to content

Instantly share code, notes, and snippets.

@rutgerhofste
Created August 24, 2017 19:29
Show Gist options
  • Save rutgerhofste/0c60da27da85cc815cfe729633ab067b to your computer and use it in GitHub Desktop.
Save rutgerhofste/0c60da27da85cc815cfe729633ab067b to your computer and use it in GitHub Desktop.
{
"cells": [
{
"cell_type": "code",
"execution_count": 64,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"S3_INPUT_PATH = \"s3://wri-projects/Aqueduct30/test/testGpd/\"\n",
"EC2_INPUT_PATH = \"/volumes/data/temp/\"\n",
"EC2_OUTPUT_PATH = \"/volumes/data/temp/output/\"\n",
"S3_OUTPUT_PATH = \"s3://wri-projects/Aqueduct30/test/output/\""
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"!mkdir -p {EC2_INPUT_PATH}\n",
"!mkdir -p {EC2_OUTPUT_PATH}"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"download: s3://wri-projects/Aqueduct30/test/testGpd/FAO/faoBuffered.dbf to ../../../../data/temp/FAO/faoBuffered.dbf\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/FAO/faoBuffered.cpg to ../../../../data/temp/FAO/faoBuffered.cpg\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_V01.prj to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_V01.prj\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_V01.cpg to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_V01.cpg\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.qpj to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.qpj\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/FAO/faoBuffered.qpj to ../../../../data/temp/FAO/faoBuffered.qpj\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.cpg to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.cpg\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/FAO/faoBuffered.shx to ../../../../data/temp/FAO/faoBuffered.shx\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.shx to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.shx\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.dbf to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.dbf\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.prj to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.prj\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_V01.shx to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_V01.shx\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/FAO/faoBuffered.prj to ../../../../data/temp/FAO/faoBuffered.prj\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.shp to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.shp\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_V01.dbf to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_V01.dbf\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/FAO/faoBuffered.shp to ../../../../data/temp/FAO/faoBuffered.shp\n",
"download: s3://wri-projects/Aqueduct30/test/testGpd/Hybas/hybas_lev06_v1c_merged_fiona_V01.shp to ../../../../data/temp/Hybas/hybas_lev06_v1c_merged_fiona_V01.shp\n"
]
}
],
"source": [
"!aws s3 cp {S3_INPUT_PATH} {EC2_INPUT_PATH} --recursive"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"import geopandas as gpd\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib notebook\n",
"import os\n",
"import folium"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from shapely.wkt import loads\n",
"from shapely.geometry import Point"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"gdfFAO = gpd.read_file('/volumes/data/temp/FAO/faoBuffered.shp')\n",
"gdfHybas = gpd.read_file('/volumes/data/temp/Hybas/hybas_lev06_v1c_merged_fiona_Cropped_V01.shp')"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>COAST</th>\n",
" <th>DIST_MAIN</th>\n",
" <th>DIST_SINK</th>\n",
" <th>ENDO</th>\n",
" <th>HYBAS_ID</th>\n",
" <th>MAIN_BAS</th>\n",
" <th>NEXT_DOWN</th>\n",
" <th>NEXT_SINK</th>\n",
" <th>ORDER</th>\n",
" <th>PFAF_ID</th>\n",
" <th>SORT</th>\n",
" <th>SUB_AREA</th>\n",
" <th>UP_AREA</th>\n",
" <th>geometry</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>227.1</td>\n",
" <td>227.1</td>\n",
" <td>0</td>\n",
" <td>2060499090</td>\n",
" <td>2060021030</td>\n",
" <td>2060502710</td>\n",
" <td>2060021030</td>\n",
" <td>2</td>\n",
" <td>232260</td>\n",
" <td>526</td>\n",
" <td>13664.2</td>\n",
" <td>13664.2</td>\n",
" <td>POLYGON ((1.133333333333358 47.35833333333336,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0</td>\n",
" <td>227.3</td>\n",
" <td>227.3</td>\n",
" <td>0</td>\n",
" <td>2060498990</td>\n",
" <td>2060021030</td>\n",
" <td>2060502710</td>\n",
" <td>2060021030</td>\n",
" <td>1</td>\n",
" <td>232270</td>\n",
" <td>527</td>\n",
" <td>10041.2</td>\n",
" <td>42572.4</td>\n",
" <td>POLYGON ((2.87916666666669 46.73750000000003, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0</td>\n",
" <td>275.6</td>\n",
" <td>275.6</td>\n",
" <td>0</td>\n",
" <td>2060455290</td>\n",
" <td>2060022150</td>\n",
" <td>2060446440</td>\n",
" <td>2060022150</td>\n",
" <td>1</td>\n",
" <td>232405</td>\n",
" <td>542</td>\n",
" <td>1088.5</td>\n",
" <td>44526.2</td>\n",
" <td>POLYGON ((2.079166666666683 48.98750000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0</td>\n",
" <td>275.7</td>\n",
" <td>275.7</td>\n",
" <td>0</td>\n",
" <td>2060455180</td>\n",
" <td>2060022150</td>\n",
" <td>2060446440</td>\n",
" <td>2060022150</td>\n",
" <td>2</td>\n",
" <td>232404</td>\n",
" <td>543</td>\n",
" <td>16783.0</td>\n",
" <td>16783.0</td>\n",
" <td>POLYGON ((3.770833333333363 49.19166666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0</td>\n",
" <td>353.6</td>\n",
" <td>353.6</td>\n",
" <td>0</td>\n",
" <td>2060459800</td>\n",
" <td>2060022150</td>\n",
" <td>2060455290</td>\n",
" <td>2060022150</td>\n",
" <td>1</td>\n",
" <td>232407</td>\n",
" <td>544</td>\n",
" <td>7203.8</td>\n",
" <td>12783.1</td>\n",
" <td>POLYGON ((2.90416666666669 49.13750000000003, ...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" COAST DIST_MAIN DIST_SINK ENDO HYBAS_ID MAIN_BAS NEXT_DOWN \\\n",
"0 0 227.1 227.1 0 2060499090 2060021030 2060502710 \n",
"1 0 227.3 227.3 0 2060498990 2060021030 2060502710 \n",
"2 0 275.6 275.6 0 2060455290 2060022150 2060446440 \n",
"3 0 275.7 275.7 0 2060455180 2060022150 2060446440 \n",
"4 0 353.6 353.6 0 2060459800 2060022150 2060455290 \n",
"\n",
" NEXT_SINK ORDER PFAF_ID SORT SUB_AREA UP_AREA \\\n",
"0 2060021030 2 232260 526 13664.2 13664.2 \n",
"1 2060021030 1 232270 527 10041.2 42572.4 \n",
"2 2060022150 1 232405 542 1088.5 44526.2 \n",
"3 2060022150 2 232404 543 16783.0 16783.0 \n",
"4 2060022150 1 232407 544 7203.8 12783.1 \n",
"\n",
" geometry \n",
"0 POLYGON ((1.133333333333358 47.35833333333336,... \n",
"1 POLYGON ((2.87916666666669 46.73750000000003, ... \n",
"2 POLYGON ((2.079166666666683 48.98750000000003,... \n",
"3 POLYGON ((3.770833333333363 49.19166666666669,... \n",
"4 POLYGON ((2.90416666666669 49.13750000000003, ... "
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gdfHybas.head()"
]
},
{
"cell_type": "code",
"execution_count": 66,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style>\n",
" .dataframe thead tr:only-child th {\n",
" text-align: right;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>COAST</th>\n",
" <th>DIST_MAIN</th>\n",
" <th>DIST_SINK</th>\n",
" <th>ENDO</th>\n",
" <th>HYBAS_ID</th>\n",
" <th>MAIN_BAS</th>\n",
" <th>NEXT_DOWN</th>\n",
" <th>NEXT_SINK</th>\n",
" <th>ORDER</th>\n",
" <th>SORT</th>\n",
" <th>SUB_AREA</th>\n",
" <th>UP_AREA</th>\n",
" <th>geometry</th>\n",
" </tr>\n",
" <tr>\n",
" <th>PFAF_ID</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>232260</th>\n",
" <td>0</td>\n",
" <td>227.1</td>\n",
" <td>227.1</td>\n",
" <td>0</td>\n",
" <td>2060499090</td>\n",
" <td>2060021030</td>\n",
" <td>2060502710</td>\n",
" <td>2060021030</td>\n",
" <td>2</td>\n",
" <td>526</td>\n",
" <td>13664.2</td>\n",
" <td>13664.2</td>\n",
" <td>POLYGON ((1.133333333333358 47.35833333333336,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232270</th>\n",
" <td>0</td>\n",
" <td>227.3</td>\n",
" <td>227.3</td>\n",
" <td>0</td>\n",
" <td>2060498990</td>\n",
" <td>2060021030</td>\n",
" <td>2060502710</td>\n",
" <td>2060021030</td>\n",
" <td>1</td>\n",
" <td>527</td>\n",
" <td>10041.2</td>\n",
" <td>42572.4</td>\n",
" <td>POLYGON ((2.87916666666669 46.73750000000003, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232405</th>\n",
" <td>0</td>\n",
" <td>275.6</td>\n",
" <td>275.6</td>\n",
" <td>0</td>\n",
" <td>2060455290</td>\n",
" <td>2060022150</td>\n",
" <td>2060446440</td>\n",
" <td>2060022150</td>\n",
" <td>1</td>\n",
" <td>542</td>\n",
" <td>1088.5</td>\n",
" <td>44526.2</td>\n",
" <td>POLYGON ((2.079166666666683 48.98750000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232404</th>\n",
" <td>0</td>\n",
" <td>275.7</td>\n",
" <td>275.7</td>\n",
" <td>0</td>\n",
" <td>2060455180</td>\n",
" <td>2060022150</td>\n",
" <td>2060446440</td>\n",
" <td>2060022150</td>\n",
" <td>2</td>\n",
" <td>543</td>\n",
" <td>16783.0</td>\n",
" <td>16783.0</td>\n",
" <td>POLYGON ((3.770833333333363 49.19166666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232407</th>\n",
" <td>0</td>\n",
" <td>353.6</td>\n",
" <td>353.6</td>\n",
" <td>0</td>\n",
" <td>2060459800</td>\n",
" <td>2060022150</td>\n",
" <td>2060455290</td>\n",
" <td>2060022150</td>\n",
" <td>1</td>\n",
" <td>544</td>\n",
" <td>7203.8</td>\n",
" <td>12783.1</td>\n",
" <td>POLYGON ((2.90416666666669 49.13750000000003, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232406</th>\n",
" <td>0</td>\n",
" <td>353.8</td>\n",
" <td>353.8</td>\n",
" <td>0</td>\n",
" <td>2060459960</td>\n",
" <td>2060022150</td>\n",
" <td>2060455290</td>\n",
" <td>2060022150</td>\n",
" <td>2</td>\n",
" <td>545</td>\n",
" <td>30654.0</td>\n",
" <td>30654.8</td>\n",
" <td>POLYGON ((4.554166666666687 47.20416666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232408</th>\n",
" <td>0</td>\n",
" <td>613.4</td>\n",
" <td>613.4</td>\n",
" <td>0</td>\n",
" <td>2060461380</td>\n",
" <td>2060022150</td>\n",
" <td>2060459800</td>\n",
" <td>2060022150</td>\n",
" <td>2</td>\n",
" <td>546</td>\n",
" <td>2134.4</td>\n",
" <td>2134.5</td>\n",
" <td>POLYGON ((5.200000000000026 48.56666666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232409</th>\n",
" <td>0</td>\n",
" <td>613.6</td>\n",
" <td>613.6</td>\n",
" <td>0</td>\n",
" <td>2060461420</td>\n",
" <td>2060022150</td>\n",
" <td>2060459800</td>\n",
" <td>2060022150</td>\n",
" <td>1</td>\n",
" <td>547</td>\n",
" <td>3444.4</td>\n",
" <td>3444.5</td>\n",
" <td>POLYGON ((5.475000000000028 48.01666666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232502</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060022380</td>\n",
" <td>2060022380</td>\n",
" <td>0</td>\n",
" <td>2060022380</td>\n",
" <td>1</td>\n",
" <td>549</td>\n",
" <td>6194.5</td>\n",
" <td>6194.8</td>\n",
" <td>POLYGON ((3.512500000000028 49.92500000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232503</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060022390</td>\n",
" <td>2060022390</td>\n",
" <td>0</td>\n",
" <td>2060022390</td>\n",
" <td>0</td>\n",
" <td>550</td>\n",
" <td>5546.6</td>\n",
" <td>5546.6</td>\n",
" <td>POLYGON ((2.641666666666687 51.12500000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232504</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060022610</td>\n",
" <td>2060022610</td>\n",
" <td>0</td>\n",
" <td>2060022610</td>\n",
" <td>1</td>\n",
" <td>551</td>\n",
" <td>1554.0</td>\n",
" <td>1554.0</td>\n",
" <td>POLYGON ((2.833333333333356 50.77500000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232505</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060022620</td>\n",
" <td>2060022620</td>\n",
" <td>0</td>\n",
" <td>2060022620</td>\n",
" <td>0</td>\n",
" <td>552</td>\n",
" <td>2600.6</td>\n",
" <td>2600.6</td>\n",
" <td>POLYGON ((4.295833333333352 51.26250000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>227999</th>\n",
" <td>0</td>\n",
" <td>2646.7</td>\n",
" <td>2646.7</td>\n",
" <td>0</td>\n",
" <td>2060461540</td>\n",
" <td>2060008490</td>\n",
" <td>2060457260</td>\n",
" <td>2060008490</td>\n",
" <td>1</td>\n",
" <td>352</td>\n",
" <td>14756.0</td>\n",
" <td>14756.1</td>\n",
" <td>POLYGON ((8.279166666666685 48.10833333333337,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232506</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060022770</td>\n",
" <td>2060022770</td>\n",
" <td>0</td>\n",
" <td>2060022770</td>\n",
" <td>1</td>\n",
" <td>553</td>\n",
" <td>19000.8</td>\n",
" <td>19001.5</td>\n",
" <td>POLYGON ((2.312500000000018 50.51666666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232507</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060022780</td>\n",
" <td>2060022780</td>\n",
" <td>0</td>\n",
" <td>2060022780</td>\n",
" <td>0</td>\n",
" <td>554</td>\n",
" <td>3584.8</td>\n",
" <td>3584.8</td>\n",
" <td>(POLYGON ((3.948611111111143 51.76250000000003...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232508</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060022970</td>\n",
" <td>2060022970</td>\n",
" <td>0</td>\n",
" <td>2060022970</td>\n",
" <td>1</td>\n",
" <td>555</td>\n",
" <td>32771.2</td>\n",
" <td>32771.2</td>\n",
" <td>POLYGON ((5.900000000000015 49.48750000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232509</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060022980</td>\n",
" <td>2060022980</td>\n",
" <td>0</td>\n",
" <td>2060022980</td>\n",
" <td>0</td>\n",
" <td>556</td>\n",
" <td>450.1</td>\n",
" <td>450.1</td>\n",
" <td>POLYGON ((4.200000000000018 51.88750000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232610</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060023010</td>\n",
" <td>2060023010</td>\n",
" <td>0</td>\n",
" <td>2060023010</td>\n",
" <td>1</td>\n",
" <td>557</td>\n",
" <td>25335.7</td>\n",
" <td>163008.5</td>\n",
" <td>POLYGON ((8.058333333333366 50.69166666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232620</th>\n",
" <td>0</td>\n",
" <td>447.8</td>\n",
" <td>447.8</td>\n",
" <td>0</td>\n",
" <td>2060420240</td>\n",
" <td>2060023010</td>\n",
" <td>2060023010</td>\n",
" <td>2060023010</td>\n",
" <td>2</td>\n",
" <td>558</td>\n",
" <td>28101.2</td>\n",
" <td>28101.4</td>\n",
" <td>POLYGON ((7.412500000000027 50.32916666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232630</th>\n",
" <td>0</td>\n",
" <td>447.9</td>\n",
" <td>447.9</td>\n",
" <td>0</td>\n",
" <td>2060420340</td>\n",
" <td>2060023010</td>\n",
" <td>2060023010</td>\n",
" <td>2060023010</td>\n",
" <td>1</td>\n",
" <td>559</td>\n",
" <td>11589.0</td>\n",
" <td>109585.3</td>\n",
" <td>POLYGON ((7.604166666666695 50.12500000000002,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232640</th>\n",
" <td>0</td>\n",
" <td>546.3</td>\n",
" <td>546.3</td>\n",
" <td>0</td>\n",
" <td>2060429670</td>\n",
" <td>2060023010</td>\n",
" <td>2060420340</td>\n",
" <td>2060023010</td>\n",
" <td>2</td>\n",
" <td>560</td>\n",
" <td>27404.6</td>\n",
" <td>27405.1</td>\n",
" <td>POLYGON ((11.62083333333336 49.60000000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232650</th>\n",
" <td>0</td>\n",
" <td>546.5</td>\n",
" <td>546.5</td>\n",
" <td>0</td>\n",
" <td>2060429770</td>\n",
" <td>2060023010</td>\n",
" <td>2060420340</td>\n",
" <td>2060023010</td>\n",
" <td>1</td>\n",
" <td>561</td>\n",
" <td>2780.0</td>\n",
" <td>70590.9</td>\n",
" <td>POLYGON ((8.541666666666687 49.57500000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232670</th>\n",
" <td>0</td>\n",
" <td>616.6</td>\n",
" <td>616.6</td>\n",
" <td>0</td>\n",
" <td>2060441280</td>\n",
" <td>2060023010</td>\n",
" <td>2060429770</td>\n",
" <td>2060023010</td>\n",
" <td>1</td>\n",
" <td>562</td>\n",
" <td>20549.5</td>\n",
" <td>53864.9</td>\n",
" <td>POLYGON ((8.40000000000002 48.49166666666669, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232660</th>\n",
" <td>0</td>\n",
" <td>616.7</td>\n",
" <td>616.7</td>\n",
" <td>0</td>\n",
" <td>2060441290</td>\n",
" <td>2060023010</td>\n",
" <td>2060429770</td>\n",
" <td>2060023010</td>\n",
" <td>2</td>\n",
" <td>563</td>\n",
" <td>13946.2</td>\n",
" <td>13946.2</td>\n",
" <td>POLYGON ((9.066666666666691 48.35416666666669,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232680</th>\n",
" <td>0</td>\n",
" <td>953.0</td>\n",
" <td>953.0</td>\n",
" <td>0</td>\n",
" <td>2060491750</td>\n",
" <td>2060023010</td>\n",
" <td>2060441280</td>\n",
" <td>2060023010</td>\n",
" <td>2</td>\n",
" <td>564</td>\n",
" <td>17568.6</td>\n",
" <td>17568.6</td>\n",
" <td>POLYGON ((8.87916666666669 46.82083333333336, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>216029</th>\n",
" <td>0</td>\n",
" <td>498.7</td>\n",
" <td>498.7</td>\n",
" <td>0</td>\n",
" <td>2060510690</td>\n",
" <td>2060016510</td>\n",
" <td>2060536360</td>\n",
" <td>2060016510</td>\n",
" <td>1</td>\n",
" <td>430</td>\n",
" <td>7831.6</td>\n",
" <td>7831.6</td>\n",
" <td>POLYGON ((5.141666666666691 46.72083333333336,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232690</th>\n",
" <td>0</td>\n",
" <td>953.1</td>\n",
" <td>953.1</td>\n",
" <td>0</td>\n",
" <td>2060491760</td>\n",
" <td>2060023010</td>\n",
" <td>2060441280</td>\n",
" <td>2060023010</td>\n",
" <td>1</td>\n",
" <td>565</td>\n",
" <td>15847.8</td>\n",
" <td>15847.8</td>\n",
" <td>POLYGON ((8.916666666666689 46.62500000000002,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>216028</th>\n",
" <td>0</td>\n",
" <td>498.9</td>\n",
" <td>498.9</td>\n",
" <td>0</td>\n",
" <td>2060510560</td>\n",
" <td>2060016510</td>\n",
" <td>2060536360</td>\n",
" <td>2060016510</td>\n",
" <td>2</td>\n",
" <td>431</td>\n",
" <td>11805.6</td>\n",
" <td>11805.6</td>\n",
" <td>POLYGON ((6.479166666666687 47.4916666666667, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232701</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060023020</td>\n",
" <td>2060023020</td>\n",
" <td>0</td>\n",
" <td>2060023020</td>\n",
" <td>0</td>\n",
" <td>566</td>\n",
" <td>6727.0</td>\n",
" <td>6727.0</td>\n",
" <td>(POLYGON ((4.669444444444466 52.95833333333336...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232702</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060023320</td>\n",
" <td>2060023320</td>\n",
" <td>0</td>\n",
" <td>2060023320</td>\n",
" <td>1</td>\n",
" <td>567</td>\n",
" <td>10569.5</td>\n",
" <td>10569.5</td>\n",
" <td>POLYGON ((7.066666666666691 51.92500000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232703</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060023330</td>\n",
" <td>2060023330</td>\n",
" <td>0</td>\n",
" <td>2060023330</td>\n",
" <td>0</td>\n",
" <td>568</td>\n",
" <td>7853.3</td>\n",
" <td>7853.3</td>\n",
" <td>(POLYGON ((6.48611111111113 53.52083333333336,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232704</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060023600</td>\n",
" <td>2060023600</td>\n",
" <td>0</td>\n",
" <td>2060023600</td>\n",
" <td>1</td>\n",
" <td>569</td>\n",
" <td>12103.1</td>\n",
" <td>12103.2</td>\n",
" <td>POLYGON ((8.554166666666687 51.98333333333337,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232705</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060023610</td>\n",
" <td>2060023610</td>\n",
" <td>0</td>\n",
" <td>2060023610</td>\n",
" <td>0</td>\n",
" <td>570</td>\n",
" <td>3100.5</td>\n",
" <td>3100.5</td>\n",
" <td>(POLYGON ((7.198611111111136 53.69583333333337...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232706</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060023940</td>\n",
" <td>2060023940</td>\n",
" <td>0</td>\n",
" <td>2060023940</td>\n",
" <td>1</td>\n",
" <td>571</td>\n",
" <td>44776.2</td>\n",
" <td>44776.2</td>\n",
" <td>POLYGON ((10.22916666666668 51.31250000000003,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232707</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060023950</td>\n",
" <td>2060023950</td>\n",
" <td>0</td>\n",
" <td>2060023950</td>\n",
" <td>0</td>\n",
" <td>572</td>\n",
" <td>1925.6</td>\n",
" <td>1925.6</td>\n",
" <td>(POLYGON ((8.436111111111131 53.94583333333337...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232708</th>\n",
" <td>0</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060024080</td>\n",
" <td>2060024080</td>\n",
" <td>0</td>\n",
" <td>2060024080</td>\n",
" <td>1</td>\n",
" <td>573</td>\n",
" <td>1804.9</td>\n",
" <td>1805.1</td>\n",
" <td>POLYGON ((9.245833333333358 53.4916666666667, ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232709</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060024090</td>\n",
" <td>2060024090</td>\n",
" <td>0</td>\n",
" <td>2060024090</td>\n",
" <td>0</td>\n",
" <td>574</td>\n",
" <td>1171.5</td>\n",
" <td>1171.5</td>\n",
" <td>POLYGON ((9.825000000000031 53.20833333333336,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>232900</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060024180</td>\n",
" <td>2060024180</td>\n",
" <td>0</td>\n",
" <td>2060024180</td>\n",
" <td>0</td>\n",
" <td>584</td>\n",
" <td>917.5</td>\n",
" <td>917.5</td>\n",
" <td>(POLYGON ((9.525000000000027 53.70000000000003...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>241001</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060024230</td>\n",
" <td>2060024230</td>\n",
" <td>0</td>\n",
" <td>2060024230</td>\n",
" <td>0</td>\n",
" <td>585</td>\n",
" <td>13793.6</td>\n",
" <td>13793.6</td>\n",
" <td>(POLYGON ((8.331944444444463 55.5041666666667,...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>241005</th>\n",
" <td>1</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>0</td>\n",
" <td>2060025270</td>\n",
" <td>2060025270</td>\n",
" <td>0</td>\n",
" <td>2060025270</td>\n",
" <td>0</td>\n",
" <td>589</td>\n",
" <td>12910.1</td>\n",
" <td>12910.1</td>\n",
" <td>(POLYGON ((10.81111111111113 56.12916666666668...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" COAST DIST_MAIN DIST_SINK ENDO HYBAS_ID MAIN_BAS \\\n",
"PFAF_ID \n",
"232260 0 227.1 227.1 0 2060499090 2060021030 \n",
"232270 0 227.3 227.3 0 2060498990 2060021030 \n",
"232405 0 275.6 275.6 0 2060455290 2060022150 \n",
"232404 0 275.7 275.7 0 2060455180 2060022150 \n",
"232407 0 353.6 353.6 0 2060459800 2060022150 \n",
"232406 0 353.8 353.8 0 2060459960 2060022150 \n",
"232408 0 613.4 613.4 0 2060461380 2060022150 \n",
"232409 0 613.6 613.6 0 2060461420 2060022150 \n",
"232502 0 0.0 0.0 0 2060022380 2060022380 \n",
"232503 1 0.0 0.0 0 2060022390 2060022390 \n",
"232504 0 0.0 0.0 0 2060022610 2060022610 \n",
"232505 1 0.0 0.0 0 2060022620 2060022620 \n",
"227999 0 2646.7 2646.7 0 2060461540 2060008490 \n",
"232506 0 0.0 0.0 0 2060022770 2060022770 \n",
"232507 1 0.0 0.0 0 2060022780 2060022780 \n",
"232508 0 0.0 0.0 0 2060022970 2060022970 \n",
"232509 1 0.0 0.0 0 2060022980 2060022980 \n",
"232610 0 0.0 0.0 0 2060023010 2060023010 \n",
"232620 0 447.8 447.8 0 2060420240 2060023010 \n",
"232630 0 447.9 447.9 0 2060420340 2060023010 \n",
"232640 0 546.3 546.3 0 2060429670 2060023010 \n",
"232650 0 546.5 546.5 0 2060429770 2060023010 \n",
"232670 0 616.6 616.6 0 2060441280 2060023010 \n",
"232660 0 616.7 616.7 0 2060441290 2060023010 \n",
"232680 0 953.0 953.0 0 2060491750 2060023010 \n",
"216029 0 498.7 498.7 0 2060510690 2060016510 \n",
"232690 0 953.1 953.1 0 2060491760 2060023010 \n",
"216028 0 498.9 498.9 0 2060510560 2060016510 \n",
"232701 1 0.0 0.0 0 2060023020 2060023020 \n",
"232702 0 0.0 0.0 0 2060023320 2060023320 \n",
"232703 1 0.0 0.0 0 2060023330 2060023330 \n",
"232704 0 0.0 0.0 0 2060023600 2060023600 \n",
"232705 1 0.0 0.0 0 2060023610 2060023610 \n",
"232706 0 0.0 0.0 0 2060023940 2060023940 \n",
"232707 1 0.0 0.0 0 2060023950 2060023950 \n",
"232708 0 0.0 0.0 0 2060024080 2060024080 \n",
"232709 1 0.0 0.0 0 2060024090 2060024090 \n",
"232900 1 0.0 0.0 0 2060024180 2060024180 \n",
"241001 1 0.0 0.0 0 2060024230 2060024230 \n",
"241005 1 0.0 0.0 0 2060025270 2060025270 \n",
"\n",
" NEXT_DOWN NEXT_SINK ORDER SORT SUB_AREA UP_AREA \\\n",
"PFAF_ID \n",
"232260 2060502710 2060021030 2 526 13664.2 13664.2 \n",
"232270 2060502710 2060021030 1 527 10041.2 42572.4 \n",
"232405 2060446440 2060022150 1 542 1088.5 44526.2 \n",
"232404 2060446440 2060022150 2 543 16783.0 16783.0 \n",
"232407 2060455290 2060022150 1 544 7203.8 12783.1 \n",
"232406 2060455290 2060022150 2 545 30654.0 30654.8 \n",
"232408 2060459800 2060022150 2 546 2134.4 2134.5 \n",
"232409 2060459800 2060022150 1 547 3444.4 3444.5 \n",
"232502 0 2060022380 1 549 6194.5 6194.8 \n",
"232503 0 2060022390 0 550 5546.6 5546.6 \n",
"232504 0 2060022610 1 551 1554.0 1554.0 \n",
"232505 0 2060022620 0 552 2600.6 2600.6 \n",
"227999 2060457260 2060008490 1 352 14756.0 14756.1 \n",
"232506 0 2060022770 1 553 19000.8 19001.5 \n",
"232507 0 2060022780 0 554 3584.8 3584.8 \n",
"232508 0 2060022970 1 555 32771.2 32771.2 \n",
"232509 0 2060022980 0 556 450.1 450.1 \n",
"232610 0 2060023010 1 557 25335.7 163008.5 \n",
"232620 2060023010 2060023010 2 558 28101.2 28101.4 \n",
"232630 2060023010 2060023010 1 559 11589.0 109585.3 \n",
"232640 2060420340 2060023010 2 560 27404.6 27405.1 \n",
"232650 2060420340 2060023010 1 561 2780.0 70590.9 \n",
"232670 2060429770 2060023010 1 562 20549.5 53864.9 \n",
"232660 2060429770 2060023010 2 563 13946.2 13946.2 \n",
"232680 2060441280 2060023010 2 564 17568.6 17568.6 \n",
"216029 2060536360 2060016510 1 430 7831.6 7831.6 \n",
"232690 2060441280 2060023010 1 565 15847.8 15847.8 \n",
"216028 2060536360 2060016510 2 431 11805.6 11805.6 \n",
"232701 0 2060023020 0 566 6727.0 6727.0 \n",
"232702 0 2060023320 1 567 10569.5 10569.5 \n",
"232703 0 2060023330 0 568 7853.3 7853.3 \n",
"232704 0 2060023600 1 569 12103.1 12103.2 \n",
"232705 0 2060023610 0 570 3100.5 3100.5 \n",
"232706 0 2060023940 1 571 44776.2 44776.2 \n",
"232707 0 2060023950 0 572 1925.6 1925.6 \n",
"232708 0 2060024080 1 573 1804.9 1805.1 \n",
"232709 0 2060024090 0 574 1171.5 1171.5 \n",
"232900 0 2060024180 0 584 917.5 917.5 \n",
"241001 0 2060024230 0 585 13793.6 13793.6 \n",
"241005 0 2060025270 0 589 12910.1 12910.1 \n",
"\n",
" geometry \n",
"PFAF_ID \n",
"232260 POLYGON ((1.133333333333358 47.35833333333336,... \n",
"232270 POLYGON ((2.87916666666669 46.73750000000003, ... \n",
"232405 POLYGON ((2.079166666666683 48.98750000000003,... \n",
"232404 POLYGON ((3.770833333333363 49.19166666666669,... \n",
"232407 POLYGON ((2.90416666666669 49.13750000000003, ... \n",
"232406 POLYGON ((4.554166666666687 47.20416666666669,... \n",
"232408 POLYGON ((5.200000000000026 48.56666666666669,... \n",
"232409 POLYGON ((5.475000000000028 48.01666666666669,... \n",
"232502 POLYGON ((3.512500000000028 49.92500000000003,... \n",
"232503 POLYGON ((2.641666666666687 51.12500000000003,... \n",
"232504 POLYGON ((2.833333333333356 50.77500000000003,... \n",
"232505 POLYGON ((4.295833333333352 51.26250000000003,... \n",
"227999 POLYGON ((8.279166666666685 48.10833333333337,... \n",
"232506 POLYGON ((2.312500000000018 50.51666666666669,... \n",
"232507 (POLYGON ((3.948611111111143 51.76250000000003... \n",
"232508 POLYGON ((5.900000000000015 49.48750000000003,... \n",
"232509 POLYGON ((4.200000000000018 51.88750000000003,... \n",
"232610 POLYGON ((8.058333333333366 50.69166666666669,... \n",
"232620 POLYGON ((7.412500000000027 50.32916666666669,... \n",
"232630 POLYGON ((7.604166666666695 50.12500000000002,... \n",
"232640 POLYGON ((11.62083333333336 49.60000000000003,... \n",
"232650 POLYGON ((8.541666666666687 49.57500000000003,... \n",
"232670 POLYGON ((8.40000000000002 48.49166666666669, ... \n",
"232660 POLYGON ((9.066666666666691 48.35416666666669,... \n",
"232680 POLYGON ((8.87916666666669 46.82083333333336, ... \n",
"216029 POLYGON ((5.141666666666691 46.72083333333336,... \n",
"232690 POLYGON ((8.916666666666689 46.62500000000002,... \n",
"216028 POLYGON ((6.479166666666687 47.4916666666667, ... \n",
"232701 (POLYGON ((4.669444444444466 52.95833333333336... \n",
"232702 POLYGON ((7.066666666666691 51.92500000000003,... \n",
"232703 (POLYGON ((6.48611111111113 53.52083333333336,... \n",
"232704 POLYGON ((8.554166666666687 51.98333333333337,... \n",
"232705 (POLYGON ((7.198611111111136 53.69583333333337... \n",
"232706 POLYGON ((10.22916666666668 51.31250000000003,... \n",
"232707 (POLYGON ((8.436111111111131 53.94583333333337... \n",
"232708 POLYGON ((9.245833333333358 53.4916666666667, ... \n",
"232709 POLYGON ((9.825000000000031 53.20833333333336,... \n",
"232900 (POLYGON ((9.525000000000027 53.70000000000003... \n",
"241001 (POLYGON ((8.331944444444463 55.5041666666667,... \n",
"241005 (POLYGON ((10.81111111111113 56.12916666666668... "
]
},
"execution_count": 66,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gdfHybas.set_index('PFAF_ID')"
]
},
{
"cell_type": "code",
"execution_count": 73,
"metadata": {},
"outputs": [],
"source": [
"gdfHybasBuffer = gdfHybas['geometry'].buffer(-0.005,resolution=16)"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 POLYGON ((0.4802056493726044 47.33676526482385...\n",
"1 POLYGON ((0.3946555531847661 47.49782138220293...\n",
"2 POLYGON ((1.985697993274555 48.88870001490769,...\n",
"3 POLYGON ((1.642712429100236 49.6413141345426, ...\n",
"4 POLYGON ((2.414370437159644 48.81750000000003,...\n",
"dtype: object"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gdfHybas[]"
]
},
{
"cell_type": "code",
"execution_count": 60,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"gdfHybasBuffer.to_file(os.path.join(EC2_OUTPUT_PATH,'output.shp'))"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"upload: ../../../../data/temp/output/output.cpg to s3://wri-projects/Aqueduct30/test/output/output.cpg\n",
"upload: ../../../../data/temp/output/output.shx to s3://wri-projects/Aqueduct30/test/output/output.shx\n",
"upload: ../../../../data/temp/output/output.prj to s3://wri-projects/Aqueduct30/test/output/output.prj\n",
"upload: ../../../../data/temp/output/output.shp to s3://wri-projects/Aqueduct30/test/output/output.shp\n",
"upload: ../../../../data/temp/output/output.dbf to s3://wri-projects/Aqueduct30/test/output/output.dbf\n"
]
}
],
"source": [
"!aws s3 cp {EC2_OUTPUT_PATH} {S3_OUTPUT_PATH} --recursive"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 35",
"language": "python",
"name": "python35"
},
"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.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment