update

parent 0c0f2e41
......@@ -171,9 +171,9 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_114312/2248574375.py:2: DtypeWarning: Columns (8) have mixed types. Specify dtype option on import or set low_memory=False.\n",
"/tmp/ipykernel_7306/2248574375.py:2: DtypeWarning: Columns (8) have mixed types. Specify dtype option on import or set low_memory=False.\n",
" cpv_df = pd.read_csv(\"../data/inegi/ccpv//conjunto_de_datos_iter_00CSV20.csv\")\n",
"/tmp/ipykernel_114312/2248574375.py:7: DtypeWarning: Columns (0,2,4,7,8,177) have mixed types. Specify dtype option on import or set low_memory=False.\n",
"/tmp/ipykernel_7306/2248574375.py:7: DtypeWarning: Columns (0,2,4,7,8,177) have mixed types. Specify dtype option on import or set low_memory=False.\n",
" cpv_mzn_df = pd.read_csv(\"../data/inegi/ccpv/ageb_mza_urbana_cpv2020.csv\")\n"
]
}
......@@ -218,7 +218,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 10,
"id": "47cf6183-d898-4288-8c1c-437d08e07ea9",
"metadata": {},
"outputs": [
......@@ -459,7 +459,7 @@
"[13075 rows x 11 columns]"
]
},
"execution_count": 12,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
......@@ -485,7 +485,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 11,
"id": "068076d3-d492-4d2c-97ee-21af49a146b9",
"metadata": {},
"outputs": [],
......@@ -519,7 +519,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 12,
"id": "bde6ea08-26e2-41db-85de-84098ee8cbfa",
"metadata": {},
"outputs": [
......@@ -532,7 +532,7 @@
"<POLYGON ((2770769.233 843071.698, 2770768.308 843063.161, 2770767.584 84305...>"
]
},
"execution_count": 14,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
......@@ -544,7 +544,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 13,
"id": "1ff84700-9c31-4022-b948-6c5ef3b784cc",
"metadata": {},
"outputs": [
......@@ -557,7 +557,7 @@
"<MULTIPOLYGON (((-98.162 19.107, -98.162 19.107, -98.162 19.107, -98.162 19....>"
]
},
"execution_count": 15,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
......@@ -584,7 +584,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 14,
"id": "df48320b-db2e-4545-924b-3c0288f94c2e",
"metadata": {
"editable": true,
......@@ -617,7 +617,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 15,
"id": "ee4293b8-6abd-4bd5-865e-8bbc13d67c3a",
"metadata": {
"editable": true,
......@@ -685,7 +685,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 16,
"id": "34c6149c-d474-45af-b769-51a17917470c",
"metadata": {
"editable": true,
......@@ -791,7 +791,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 17,
"id": "ee3eddce-41d1-4ef0-8ec4-bb0b0cc5391c",
"metadata": {
"editable": true,
......@@ -804,22 +804,22 @@
{
"data": {
"text/plain": [
"3605961522"
"3606037696"
]
},
"execution_count": 19,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#codigo para overpass\n",
"getAreaId(\"31050\")+ 3600000000"
"getAreaId(\"30085\")+ 3600000000"
]
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": 18,
"id": "e0bda493-7ba0-4c91-a6c8-069123167f96",
"metadata": {
"editable": true,
......@@ -843,7 +843,7 @@
"<Axes: >"
]
},
"execution_count": 20,
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
},
......@@ -864,7 +864,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 19,
"id": "1fd318e4-120e-46fc-8155-fa7b660a3c6f",
"metadata": {
"editable": true,
......@@ -883,7 +883,7 @@
"<POLYGON ((2791349.819 815583.059, 2791369.938 815548.359, 2791396.144 81550...>"
]
},
"execution_count": 21,
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
......@@ -894,7 +894,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 20,
"id": "f74ac051-fa28-4e4c-be82-2b01accc2fa9",
"metadata": {},
"outputs": [
......@@ -907,7 +907,7 @@
"<POLYGON ((3029278.483 851967.163, 3029217.788 852039.421, 3029240.014 85208...>"
]
},
"execution_count": 22,
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
......@@ -928,7 +928,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 21,
"id": "3f71d3e0-eaa0-4cfa-be12-1d252451ffc2",
"metadata": {
"editable": true,
......@@ -962,7 +962,7 @@
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 22,
"id": "5cb22d01-7bcb-4763-b44d-f6df65b49e2f",
"metadata": {
"editable": true,
......@@ -1048,7 +1048,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 23,
"id": "623cf608-d268-4aaa-aaec-40c6bdc748ee",
"metadata": {
"editable": true,
......@@ -1138,7 +1138,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 24,
"id": "6fcbfbad-ef01-41f7-9cec-058fce0614f1",
"metadata": {
"editable": true,
......@@ -1169,7 +1169,7 @@
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 25,
"id": "614078e9-50ce-43ab-862f-bc94d4dc9e58",
"metadata": {
"editable": true,
......@@ -1198,7 +1198,7 @@
"dtype: int64"
]
},
"execution_count": 27,
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
......@@ -1209,7 +1209,7 @@
},
{
"cell_type": "code",
"execution_count": 28,
"execution_count": 26,
"id": "c1e950de-5c97-4134-af6e-8860a612efcd",
"metadata": {
"editable": true,
......@@ -1225,7 +1225,7 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 27,
"id": "392bb52f-7034-4691-a785-6d75520407f7",
"metadata": {
"editable": true,
......@@ -1441,7 +1441,7 @@
"169 Nuevo León 643143.0 "
]
},
"execution_count": 29,
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
......@@ -1450,25 +1450,11 @@
"statistics_df[(statistics_df.porcentajeEP_urbano>=0.10) & (statistics_df.urbanarea_percent>=0.35)].sort_values(by=['porcentajeEP_urbano'], ascending=False)[[\"CVEGEO\",\"total_area\",\"urban_area\",\"urbanarea_percent\",\"publicspace_area\",\"porcentajeEP\",\"porcentajeEP_urbano\",\"NOMGEO_mun\", \"NOMGEO_ent\",\"POBTOT\"]].sort_values(by=['porcentajeEP_urbano'], ascending=False)"
]
},
{
"cell_type": "markdown",
"id": "e5cf0e5c-7ee5-4e41-b4ee-f19435837ce5",
"metadata": {},
"source": [
"## Municipios con mas de 10% de espacio publico urbano y mas de 35% de pircentaje de area urbana."
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "ed2696e6-2fd7-47d6-a093-39901bcc29d8",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"execution_count": 38,
"id": "bec50812-b930-4758-86ea-daf008fcfef9",
"metadata": {},
"outputs": [
{
"data": {
......@@ -1491,177 +1477,298 @@
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>CVEGEO</th>\n",
" <th>total_area</th>\n",
" <th>urban_area</th>\n",
" <th>publicspace_area</th>\n",
" <th>latlng</th>\n",
" <th>porcentajeEP</th>\n",
" <th>porcentajeEP_urbano</th>\n",
" <th>CVE_ENT</th>\n",
" <th>CVE_MUN</th>\n",
" <th>NOMGEO_mun</th>\n",
" <th>geometry</th>\n",
" <th>NOMGEO_ent</th>\n",
" </tr>\n",
" <tr>\n",
" <th>CVEGEO</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>POBTOT</th>\n",
" <th>urbanarea_percent</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>09010</th>\n",
" <td>12.803726</td>\n",
" <td>0.184458</td>\n",
" <td>Álvaro Obregón</td>\n",
" <td>Ciudad de México</td>\n",
" <th>0</th>\n",
" <td>01001</td>\n",
" <td>1161.387798</td>\n",
" <td>136.345089</td>\n",
" <td>6.986234</td>\n",
" <td>POINT (-102.28217994097264 21.882460442519434)</td>\n",
" <td>0.006015</td>\n",
" <td>0.051239</td>\n",
" <td>01</td>\n",
" <td>001</td>\n",
" <td>Aguascalientes</td>\n",
" <td>POLYGON ((2488980.227 1117358.447, 2489013.495...</td>\n",
" <td>Aguascalientes</td>\n",
" <td>948990.0</td>\n",
" <td>0.117398</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09016</th>\n",
" <td>7.769687</td>\n",
" <td>0.168341</td>\n",
" <td>Miguel Hidalgo</td>\n",
" <td>Ciudad de México</td>\n",
" <th>1</th>\n",
" <td>01005</td>\n",
" <td>551.257984</td>\n",
" <td>17.710448</td>\n",
" <td>0.408575</td>\n",
" <td>POINT (-102.32071028165859 21.969206117424136)</td>\n",
" <td>0.000741</td>\n",
" <td>0.023070</td>\n",
" <td>01</td>\n",
" <td>005</td>\n",
" <td>Jesús María</td>\n",
" <td>POLYGON ((2463657.764 1116053.82, 2463738.92 1...</td>\n",
" <td>Aguascalientes</td>\n",
" <td>129929.0</td>\n",
" <td>0.032127</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19039</th>\n",
" <td>35.140171</td>\n",
" <td>0.161972</td>\n",
" <td>Monterrey</td>\n",
" <td>Nuevo León</td>\n",
" <th>2</th>\n",
" <td>01011</td>\n",
" <td>137.769453</td>\n",
" <td>6.392478</td>\n",
" <td>0.096735</td>\n",
" <td>POINT (-102.26511571361571 22.03389567355689)</td>\n",
" <td>0.000702</td>\n",
" <td>0.015133</td>\n",
" <td>01</td>\n",
" <td>011</td>\n",
" <td>San Francisco de los Romo</td>\n",
" <td>POLYGON ((2483638.349 1120034.022, 2483946.175...</td>\n",
" <td>Aguascalientes</td>\n",
" <td>61997.0</td>\n",
" <td>0.046400</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09005</th>\n",
" <td>14.095417</td>\n",
" <td>0.161315</td>\n",
" <td>Gustavo A. Madero</td>\n",
" <td>Ciudad de México</td>\n",
" <th>3</th>\n",
" <td>02004</td>\n",
" <td>1090.937294</td>\n",
" <td>322.557140</td>\n",
" <td>10.011862</td>\n",
" <td>POINT (-116.96228309586247 32.5108411628942)</td>\n",
" <td>0.009177</td>\n",
" <td>0.031039</td>\n",
" <td>02</td>\n",
" <td>004</td>\n",
" <td>Tijuana</td>\n",
" <td>MULTIPOLYGON (((1058853.778 2337446.07, 105884...</td>\n",
" <td>Baja California</td>\n",
" <td>1922523.0</td>\n",
" <td>0.295670</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19019</th>\n",
" <td>7.470699</td>\n",
" <td>0.158754</td>\n",
" <td>San Pedro Garza García</td>\n",
" <td>Nuevo León</td>\n",
" <th>4</th>\n",
" <td>02005</td>\n",
" <td>513.145384</td>\n",
" <td>40.872326</td>\n",
" <td>0.866766</td>\n",
" <td>POINT (-117.03212842892269 32.33864342743674)</td>\n",
" <td>0.001689</td>\n",
" <td>0.021207</td>\n",
" <td>02</td>\n",
" <td>005</td>\n",
" <td>Playas de Rosarito</td>\n",
" <td>POLYGON ((1076736.333 2336649.366, 1076738.335...</td>\n",
" <td>Baja California</td>\n",
" <td>126890.0</td>\n",
" <td>0.079651</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09003</th>\n",
" <td>7.779830</td>\n",
" <td>0.145086</td>\n",
" <td>Coyoacán</td>\n",
" <td>Ciudad de México</td>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09013</th>\n",
" <td>9.125320</td>\n",
" <td>0.142611</td>\n",
" <td>Xochimilco</td>\n",
" <td>Ciudad de México</td>\n",
" <th>329</th>\n",
" <td>31101</td>\n",
" <td>350.969896</td>\n",
" <td>16.917890</td>\n",
" <td>0.299418</td>\n",
" <td>POINT (-89.73952990718742 20.888419253037785)</td>\n",
" <td>0.000853</td>\n",
" <td>0.017698</td>\n",
" <td>31</td>\n",
" <td>101</td>\n",
" <td>Umán</td>\n",
" <td>POLYGON ((3764005.91 1050216.72, 3765142.31 10...</td>\n",
" <td>Yucatán</td>\n",
" <td>69147.0</td>\n",
" <td>0.048203</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30118</th>\n",
" <td>2.104083</td>\n",
" <td>0.108663</td>\n",
" <td>Orizaba</td>\n",
" <td>Veracruz de Ignacio de la Llave</td>\n",
" <th>330</th>\n",
" <td>32017</td>\n",
" <td>808.286730</td>\n",
" <td>35.529357</td>\n",
" <td>0.819829</td>\n",
" <td>POINT (-102.4923897474762 22.754685509408485)</td>\n",
" <td>0.001014</td>\n",
" <td>0.023075</td>\n",
" <td>32</td>\n",
" <td>017</td>\n",
" <td>Guadalupe</td>\n",
" <td>POLYGON ((2476735.114 1218907.462, 2478520.954...</td>\n",
" <td>Zacatecas</td>\n",
" <td>211740.0</td>\n",
" <td>0.043956</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09007</th>\n",
" <td>11.536119</td>\n",
" <td>0.102608</td>\n",
" <td>Iztapalapa</td>\n",
" <td>Ciudad de México</td>\n",
" <th>331</th>\n",
" <td>32032</td>\n",
" <td>178.977897</td>\n",
" <td>4.695048</td>\n",
" <td>0.023328</td>\n",
" <td>POINT (-102.60937065165437 22.849848836474635)</td>\n",
" <td>0.000130</td>\n",
" <td>0.004969</td>\n",
" <td>32</td>\n",
" <td>032</td>\n",
" <td>Morelos</td>\n",
" <td>POLYGON ((2433337.984 1212149.706, 2433350.587...</td>\n",
" <td>Zacatecas</td>\n",
" <td>13207.0</td>\n",
" <td>0.026233</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19026</th>\n",
" <td>9.753139</td>\n",
" <td>0.101106</td>\n",
" <td>Guadalupe</td>\n",
" <td>Nuevo León</td>\n",
" <th>332</th>\n",
" <td>32056</td>\n",
" <td>436.821011</td>\n",
" <td>28.453654</td>\n",
" <td>1.015034</td>\n",
" <td>POINT (-102.57354861177434 22.766425986481412)</td>\n",
" <td>0.002324</td>\n",
" <td>0.035673</td>\n",
" <td>32</td>\n",
" <td>056</td>\n",
" <td>Zacatecas</td>\n",
" <td>POLYGON ((2421780.086 1201989.77, 2421852.949 ...</td>\n",
" <td>Zacatecas</td>\n",
" <td>149607.0</td>\n",
" <td>0.065138</td>\n",
" </tr>\n",
" <tr>\n",
" <th>333</th>\n",
" <td>32057</td>\n",
" <td>218.447007</td>\n",
" <td>5.384439</td>\n",
" <td>0.016277</td>\n",
" <td>POINT (-102.36490935295603 22.738986947654105)</td>\n",
" <td>0.000075</td>\n",
" <td>0.003023</td>\n",
" <td>32</td>\n",
" <td>057</td>\n",
" <td>Trancoso</td>\n",
" <td>POLYGON ((2477546.115 1200173.286, 2477482.311...</td>\n",
" <td>Zacatecas</td>\n",
" <td>20455.0</td>\n",
" <td>0.024649</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>334 rows × 14 columns</p>\n",
"</div>"
],
"text/plain": [
" publicspace_area porcentajeEP_urbano NOMGEO_mun \\\n",
"CVEGEO \n",
"09010 12.803726 0.184458 Álvaro Obregón \n",
"09016 7.769687 0.168341 Miguel Hidalgo \n",
"19039 35.140171 0.161972 Monterrey \n",
"09005 14.095417 0.161315 Gustavo A. Madero \n",
"19019 7.470699 0.158754 San Pedro Garza García \n",
"09003 7.779830 0.145086 Coyoacán \n",
"09013 9.125320 0.142611 Xochimilco \n",
"30118 2.104083 0.108663 Orizaba \n",
"09007 11.536119 0.102608 Iztapalapa \n",
"19026 9.753139 0.101106 Guadalupe \n",
" CVEGEO total_area urban_area publicspace_area \\\n",
"0 01001 1161.387798 136.345089 6.986234 \n",
"1 01005 551.257984 17.710448 0.408575 \n",
"2 01011 137.769453 6.392478 0.096735 \n",
"3 02004 1090.937294 322.557140 10.011862 \n",
"4 02005 513.145384 40.872326 0.866766 \n",
".. ... ... ... ... \n",
"329 31101 350.969896 16.917890 0.299418 \n",
"330 32017 808.286730 35.529357 0.819829 \n",
"331 32032 178.977897 4.695048 0.023328 \n",
"332 32056 436.821011 28.453654 1.015034 \n",
"333 32057 218.447007 5.384439 0.016277 \n",
"\n",
" latlng porcentajeEP \\\n",
"0 POINT (-102.28217994097264 21.882460442519434) 0.006015 \n",
"1 POINT (-102.32071028165859 21.969206117424136) 0.000741 \n",
"2 POINT (-102.26511571361571 22.03389567355689) 0.000702 \n",
"3 POINT (-116.96228309586247 32.5108411628942) 0.009177 \n",
"4 POINT (-117.03212842892269 32.33864342743674) 0.001689 \n",
".. ... ... \n",
"329 POINT (-89.73952990718742 20.888419253037785) 0.000853 \n",
"330 POINT (-102.4923897474762 22.754685509408485) 0.001014 \n",
"331 POINT (-102.60937065165437 22.849848836474635) 0.000130 \n",
"332 POINT (-102.57354861177434 22.766425986481412) 0.002324 \n",
"333 POINT (-102.36490935295603 22.738986947654105) 0.000075 \n",
"\n",
" porcentajeEP_urbano CVE_ENT CVE_MUN NOMGEO_mun \\\n",
"0 0.051239 01 001 Aguascalientes \n",
"1 0.023070 01 005 Jesús María \n",
"2 0.015133 01 011 San Francisco de los Romo \n",
"3 0.031039 02 004 Tijuana \n",
"4 0.021207 02 005 Playas de Rosarito \n",
".. ... ... ... ... \n",
"329 0.017698 31 101 Umán \n",
"330 0.023075 32 017 Guadalupe \n",
"331 0.004969 32 032 Morelos \n",
"332 0.035673 32 056 Zacatecas \n",
"333 0.003023 32 057 Trancoso \n",
"\n",
" geometry NOMGEO_ent \\\n",
"0 POLYGON ((2488980.227 1117358.447, 2489013.495... Aguascalientes \n",
"1 POLYGON ((2463657.764 1116053.82, 2463738.92 1... Aguascalientes \n",
"2 POLYGON ((2483638.349 1120034.022, 2483946.175... Aguascalientes \n",
"3 MULTIPOLYGON (((1058853.778 2337446.07, 105884... Baja California \n",
"4 POLYGON ((1076736.333 2336649.366, 1076738.335... Baja California \n",
".. ... ... \n",
"329 POLYGON ((3764005.91 1050216.72, 3765142.31 10... Yucatán \n",
"330 POLYGON ((2476735.114 1218907.462, 2478520.954... Zacatecas \n",
"331 POLYGON ((2433337.984 1212149.706, 2433350.587... Zacatecas \n",
"332 POLYGON ((2421780.086 1201989.77, 2421852.949 ... Zacatecas \n",
"333 POLYGON ((2477546.115 1200173.286, 2477482.311... Zacatecas \n",
"\n",
" POBTOT urbanarea_percent \n",
"0 948990.0 0.117398 \n",
"1 129929.0 0.032127 \n",
"2 61997.0 0.046400 \n",
"3 1922523.0 0.295670 \n",
"4 126890.0 0.079651 \n",
".. ... ... \n",
"329 69147.0 0.048203 \n",
"330 211740.0 0.043956 \n",
"331 13207.0 0.026233 \n",
"332 149607.0 0.065138 \n",
"333 20455.0 0.024649 \n",
"\n",
" NOMGEO_ent \n",
"CVEGEO \n",
"09010 Ciudad de México \n",
"09016 Ciudad de México \n",
"19039 Nuevo León \n",
"09005 Ciudad de México \n",
"19019 Nuevo León \n",
"09003 Ciudad de México \n",
"09013 Ciudad de México \n",
"30118 Veracruz de Ignacio de la Llave \n",
"09007 Ciudad de México \n",
"19026 Nuevo León "
"[334 rows x 14 columns]"
]
},
"execution_count": 30,
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"results_ep = statistics_df[(statistics_df.porcentajeEP_urbano>=0.10) & (statistics_df.urbanarea_percent>=0.35)].sort_values(by=['porcentajeEP_urbano'], ascending=False)[[\"CVEGEO\", \"publicspace_area\",\"porcentajeEP_urbano\",\"NOMGEO_mun\", \"NOMGEO_ent\"]].sort_values(by=['porcentajeEP_urbano'], ascending=False)\n",
"results_ep=results_ep.set_index(\"CVEGEO\")\n",
"results_ep"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "4de80e93-039d-42e4-859a-00b44c72df41",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"results_ep[\"porcentajeEP_urbano\"] = (results_ep[\"porcentajeEP_urbano\"]*100).apply(lambda x: \"{:.2f}\".format(x))\n",
"results_ep[\"publicspace_area\"] = results_ep[\"publicspace_area\"].apply(lambda x: \"{:.2f}\".format(x))\n"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "31576634-0378-4ddf-ac43-2dba70f36d02",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"results_ep.to_csv(\"espaciopublico.csv\", index=False)"
"statistics_df"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "27803b7b-f62d-4008-9394-c8899a2b076d",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"execution_count": 37,
"id": "3933786e-4b67-4f10-b282-67887d398ecb",
"metadata": {},
"outputs": [
{
"data": {
......@@ -1684,157 +1791,134 @@
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>CVEGEO</th>\n",
" <th>total_area</th>\n",
" <th>urban_area</th>\n",
" <th>urbanarea_percent</th>\n",
" <th>publicspace_area</th>\n",
" <th>porcentajeEP</th>\n",
" <th>porcentajeEP_urbano</th>\n",
" <th>NOMGEO_mun</th>\n",
" <th>NOMGEO_ent</th>\n",
" </tr>\n",
" <tr>\n",
" <th>CVEGEO</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th>POBTOT</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>09010</th>\n",
" <td>12.80</td>\n",
" <td>18.45</td>\n",
" <td>Álvaro Obregón</td>\n",
" <td>Ciudad de México</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09016</th>\n",
" <td>7.77</td>\n",
" <td>16.83</td>\n",
" <td>Miguel Hidalgo</td>\n",
" <td>Ciudad de México</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19039</th>\n",
" <td>35.14</td>\n",
" <td>16.20</td>\n",
" <td>Monterrey</td>\n",
" <td>Nuevo León</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09005</th>\n",
" <td>14.10</td>\n",
" <td>16.13</td>\n",
" <td>Gustavo A. Madero</td>\n",
" <td>Ciudad de México</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19019</th>\n",
" <td>7.47</td>\n",
" <td>15.88</td>\n",
" <td>San Pedro Garza García</td>\n",
" <td>Nuevo León</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09003</th>\n",
" <td>7.78</td>\n",
" <td>14.51</td>\n",
" <td>Coyoacán</td>\n",
" <td>Ciudad de México</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09013</th>\n",
" <td>9.13</td>\n",
" <td>14.26</td>\n",
" <td>Xochimilco</td>\n",
" <td>Ciudad de México</td>\n",
" </tr>\n",
" <tr>\n",
" <th>30118</th>\n",
" <td>2.10</td>\n",
" <td>10.87</td>\n",
" <td>Orizaba</td>\n",
" <td>Veracruz de Ignacio de la Llave</td>\n",
" </tr>\n",
" <tr>\n",
" <th>09007</th>\n",
" <td>11.54</td>\n",
" <td>10.26</td>\n",
" <td>Iztapalapa</td>\n",
" <td>Ciudad de México</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19026</th>\n",
" <td>9.75</td>\n",
" <td>10.11</td>\n",
" <td>Guadalupe</td>\n",
" <td>Nuevo León</td>\n",
" <th>323</th>\n",
" <td>31050</td>\n",
" <td>848.011821</td>\n",
" <td>268.255115</td>\n",
" <td>0.316334</td>\n",
" <td>19.891791</td>\n",
" <td>0.023457</td>\n",
" <td>0.074153</td>\n",
" <td>Mérida</td>\n",
" <td>Yucatán</td>\n",
" <td>995129.0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" publicspace_area porcentajeEP_urbano NOMGEO_mun \\\n",
"CVEGEO \n",
"09010 12.80 18.45 Álvaro Obregón \n",
"09016 7.77 16.83 Miguel Hidalgo \n",
"19039 35.14 16.20 Monterrey \n",
"09005 14.10 16.13 Gustavo A. Madero \n",
"19019 7.47 15.88 San Pedro Garza García \n",
"09003 7.78 14.51 Coyoacán \n",
"09013 9.13 14.26 Xochimilco \n",
"30118 2.10 10.87 Orizaba \n",
"09007 11.54 10.26 Iztapalapa \n",
"19026 9.75 10.11 Guadalupe \n",
" CVEGEO total_area urban_area urbanarea_percent publicspace_area \\\n",
"323 31050 848.011821 268.255115 0.316334 19.891791 \n",
"\n",
" NOMGEO_ent \n",
"CVEGEO \n",
"09010 Ciudad de México \n",
"09016 Ciudad de México \n",
"19039 Nuevo León \n",
"09005 Ciudad de México \n",
"19019 Nuevo León \n",
"09003 Ciudad de México \n",
"09013 Ciudad de México \n",
"30118 Veracruz de Ignacio de la Llave \n",
"09007 Ciudad de México \n",
"19026 Nuevo León "
" porcentajeEP porcentajeEP_urbano NOMGEO_mun NOMGEO_ent POBTOT \n",
"323 0.023457 0.074153 Mérida Yucatán 995129.0 "
]
},
"execution_count": 33,
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"statistics_df[(statistics_df.NOMGEO_mun==\"Mérida\")].sort_values(by=['porcentajeEP_urbano'], ascending=False)[[\"CVEGEO\",\"total_area\",\"urban_area\",\"urbanarea_percent\",\"publicspace_area\",\"porcentajeEP\",\"porcentajeEP_urbano\",\"NOMGEO_mun\", \"NOMGEO_ent\",\"POBTOT\"]].sort_values(by=['porcentajeEP_urbano'], ascending=False)"
]
},
{
"cell_type": "markdown",
"id": "e5cf0e5c-7ee5-4e41-b4ee-f19435837ce5",
"metadata": {},
"source": [
"## Municipios con mas de 10% de espacio publico urbano y mas de 35% de porcentaje de area urbana."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ed2696e6-2fd7-47d6-a093-39901bcc29d8",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"results_ep = statistics_df[(statistics_df.porcentajeEP_urbano>=0.10) & (statistics_df.urbanarea_percent>=0.35)].sort_values(by=['porcentajeEP_urbano'], ascending=False)[[\"CVEGEO\", \"publicspace_area\",\"porcentajeEP_urbano\",\"NOMGEO_mun\", \"NOMGEO_ent\"]].sort_values(by=['porcentajeEP_urbano'], ascending=False)\n",
"results_ep=results_ep.set_index(\"CVEGEO\")\n",
"results_ep"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4de80e93-039d-42e4-859a-00b44c72df41",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"results_ep[\"porcentajeEP_urbano\"] = (results_ep[\"porcentajeEP_urbano\"]*100).apply(lambda x: \"{:.2f}\".format(x))\n",
"results_ep[\"publicspace_area\"] = results_ep[\"publicspace_area\"].apply(lambda x: \"{:.2f}\".format(x))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "31576634-0378-4ddf-ac43-2dba70f36d02",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"results_ep.to_csv(\"espaciopublico.csv\", index=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "27803b7b-f62d-4008-9394-c8899a2b076d",
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"source": [
"results_ep"
]
},
{
"cell_type": "code",
"execution_count": 34,
"execution_count": null,
"id": "917045d9-d493-483f-9d9c-c16ebd968733",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['09010',\n",
" '09016',\n",
" '19039',\n",
" '09005',\n",
" '19019',\n",
" '09003',\n",
" '09013',\n",
" '30118',\n",
" '09007',\n",
" '19026']"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"results_ep.index.to_list()"
]
......@@ -1849,7 +1933,7 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": null,
"id": "571176eb-113b-419e-b249-ea21f461d72d",
"metadata": {},
"outputs": [],
......@@ -1866,17 +1950,17 @@
},
{
"cell_type": "code",
"execution_count": 36,
"execution_count": null,
"id": "b9ce4856-d99f-459d-9626-0fccf74752d7",
"metadata": {},
"outputs": [],
"source": [
"isocrhones_parameters = [{\"distance\": [400], \"area_range\":(0.0003, 0.004)}, {\"distance\":[800], \"area_range\":(0.004, .1)}]"
"isocrhones_parameters = [{\"distance\":[800], \"area_range\":(0.004, .1), \"color\": \"limegreen\"}, {\"distance\": [400], \"area_range\":(0.0003, 0.004), \"color\":\"orange\"}]"
]
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": null,
"id": "ca817781-68b0-4669-926d-c6477b9806d9",
"metadata": {},
"outputs": [],
......@@ -1908,104 +1992,37 @@
" node_points = [Point((data[\"x\"], data[\"y\"])) for node, data in subgraph.nodes(data=True)]\n",
" bounding_poly = gpd.GeoSeries(node_points).union_all().convex_hull\n",
" isochrone_polys.append(bounding_poly)\n",
" return isochrone_polys\n"
" return isochrone_polys\n",
"def getIsochronePolys2(cityNetwork, publicSpacePolygins, trip_times = [400]):\n",
" # make the isochrone polygons\n",
" isochrone_polys = []\n",
" nodes = []\n",
" for center_node in getCenterNodes(publicSpacePolygins):\n",
" for trip_time in sorted(trip_times, reverse=True):\n",
" subgraph = nx.ego_graph(cityNetwork, center_node, radius=trip_time, distance=\"length\")\n",
" node_points = [Point((data[\"x\"], data[\"y\"])) for node, data in subgraph.nodes(data=True)]\n",
" bounding_poly = gpd.GeoSeries(node_points).union_all().convex_hull\n",
" isochrone_polys.append(bounding_poly)\n",
" nodes += subgraph.nodes()\n",
" return isochrone_polys, nodes"
]
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": null,
"id": "09aa401e-b5d5-4537-94fd-2371710ba5a1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0 POLYGON ((2469592.842 1101420.419, 2469595.825...\n",
"4 POLYGON ((2469559.613 1101504.72, 2469551.46 1...\n",
"5 POLYGON ((2469379.158 1101559.98, 2469433.676 ...\n",
"6 POLYGON ((2469514.461 1101572.876, 2469516.936...\n",
"7 POLYGON ((2469561.884 1101443.819, 2469560.282...\n",
" ... \n",
"2519186 POLYGON ((2406061.979 1095317.002, 2406038.419...\n",
"2519192 POLYGON ((2405231.044 1094486.47, 2405243.068 ...\n",
"2519193 POLYGON ((2406428.192 1094651.977, 2406454.661...\n",
"2519194 POLYGON ((2406399.339 1094617.586, 2406399.61 ...\n",
"2519197 POLYGON ((2406515.836 1093767.193, 2406517.415...\n",
"Name: geometry, Length: 1391216, dtype: geometry"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"data_mzn_df.geometry"
]
},
{
"cell_type": "code",
"execution_count": 60,
"execution_count": null,
"id": "8062a355-3163-4aa7-aa76-61da9f5ee492",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"09010../data/graphx/09010.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:00:26.513326\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:16.107634\n",
"09016../data/graphx/09016.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:00:16.872916\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:10.567090\n",
"19039../data/graphx/19039.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:02:55.257601\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:02:37.322553\n",
"09005../data/graphx/09005.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:00:44.608399\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:29.560695\n",
"19019../data/graphx/19019.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:00:08.648338\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:09.564972\n",
"09003../data/graphx/09003.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:00:34.168363\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:28.957644\n",
"09013../data/graphx/09013.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:00:09.645861\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:07.172558\n",
"30118../data/graphx/30118.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:00:02.740532\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:01.747167\n",
"09007../data/graphx/09007.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:01:04.778722\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:51.727849\n",
"19026../data/graphx/19026.p\n",
". {'distance': [400], 'area_range': (0.0003, 0.004)}\n",
"Duration: 0:00:41.901243\n",
"{'distance': [800], 'area_range': (0.004, 0.1)}\n",
"Duration: 0:00:32.427858\n"
]
}
],
"outputs": [],
"source": [
"popservice = {}\n",
"for mun_id in results_ep.index.to_list():\n",
......@@ -2041,44 +2058,104 @@
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": null,
"id": "586b6e26-de30-4c9b-8c99-63c05f87f0c1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'09010': 280 0.771618\n",
" Name: POBTOT, dtype: float64,\n",
" '09016': 282 0.913953\n",
" Name: POBTOT, dtype: float64,\n",
" '19039': 979 0.906574\n",
" Name: POBTOT, dtype: float64,\n",
" '09005': 287 0.88375\n",
" Name: POBTOT, dtype: float64,\n",
" '19019': 981 0.947196\n",
" Name: POBTOT, dtype: float64,\n",
" '09003': 281 0.978846\n",
" Name: POBTOT, dtype: float64,\n",
" '09013': 286 0.754242\n",
" Name: POBTOT, dtype: float64,\n",
" '30118': 2276 0.924973\n",
" Name: POBTOT, dtype: float64,\n",
" '09007': 278 0.88194\n",
" Name: POBTOT, dtype: float64,\n",
" '19026': 989 0.934439\n",
" Name: POBTOT, dtype: float64}"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"popservice"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "500f4da3-25d6-4a1b-b6cf-20ade741e0fb",
"metadata": {},
"outputs": [],
"source": [
"iso_colors = ox.plot.get_colors(n=2, cmap=\"plasma\", start=0)\n",
"iso_colors"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1d404abc-a1fa-48cc-9cf6-1db5e0faa793",
"metadata": {},
"outputs": [],
"source": [
"mun_id =\"09003\"\n",
"G = ox.graph.graph_from_polygon(getUrbanMask(mun_id)[1], network_type=\"all_public\")\n",
"iso_colors = ox.plot.get_colors(n=2, cmap=\"plasma\", start=0)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4e9845cb-0247-482e-be62-39fec517b7fb",
"metadata": {},
"outputs": [],
"source": [
"from descartes import PolygonPatch\n",
"isochronePolylist = []\n",
"node_colors = {}\n",
"for i in isocrhones_parameters:\n",
" print(i)\n",
" polylist = OSM_ops_df[(OSM_ops_df.wkt_area_Km2>=i[\"area_range\"][0]) & (OSM_ops_df.wkt_area_Km2<i[\"area_range\"][1]) & (OSM_ops_df.CVEGEO==int(mun_id)) & (~ OSM_ops_df.wkt.is_empty) ][\"wkt\"].to_list()\n",
" #print(len(polylist))\n",
" tempList, nodes = getIsochronePolys2(G, polylist, trip_times=i[\"distance\"])\n",
" isochronePolylist += tempList\n",
" for node in nodes:\n",
" node_colors[node] = i[\"color\"]\n",
"\n",
" \n",
"nc = [node_colors[node] if node in node_colors else \"none\" for node in G.nodes()]\n",
"ns = [8 if node in node_colors else 0 for node in G.nodes()]\n",
"fig, ax = ox.plot.plot_graph(\n",
" G,\n",
" node_color=nc,\n",
" node_size=ns,\n",
" node_alpha=0.8,\n",
" edge_linewidth=0.4,\n",
" edge_color=\"#999999\", filepath = \"plot.png\", show=True, save=True\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "71edf6a4-2d8a-4644-8449-c53a7f968d1e",
"metadata": {},
"outputs": [],
"source": [
"fig, ax = ox.plot.plot_graph(\n",
" G,\n",
" node_color=nc,\n",
" node_size=ns,\n",
" node_alpha=0.8,\n",
" edge_linewidth=0.8,\n",
" bgcolor=\"#00000000\",\n",
" edge_color=\"darkgray\",\n",
" filepath = \"plot.png\", show=True, save=True\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5f69d103-7c2a-4737-8a35-b40bc24ed715",
"metadata": {},
"outputs": [],
"source": [
"fig, ax = ox.plot.plot_graph(\n",
" G,\n",
" node_size=ns,\n",
" node_alpha=0.8,\n",
" edge_linewidth=0.2,\n",
" edge_color=\"#999999\",\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
......@@ -2086,7 +2163,7 @@
"metadata": {},
"outputs": [],
"source": [
"gdf.plot()"
"isochronePolylist.plot"
]
},
{
......@@ -2151,11 +2228,19 @@
"outputs": [],
"source": [
"#poly=getMunicipality(\"31050\",data_mun_df)[1]\n",
"\n",
"poly=getUrbanMask(\"31050\")\n",
"print(type(poly[0]),type(poly[1]))\n",
"G = ox.graph.graph_from_polygon(poly[1], network_type=\"all_public\")\n",
"#G = ox.simplification.simplify_graph(G)\n",
"fig, ax = ox.plot_graph(G)\n"
"fig, ax = ox.plot.plot_graph(\n",
" G,\n",
" node_color=nc,\n",
" node_size=ns,\n",
" node_alpha=0.8,\n",
" edge_linewidth=0.2,\n",
" edge_color=\"#999999\",\n",
")"
]
},
{
......@@ -2167,7 +2252,7 @@
"source": [
"for mun_id in results_ep.index.to_list():\n",
" print(mun_id, end=\"\")\n",
" filename = \"../data/\"+mun_id+\".p\"\n",
" filename = \"../data/graphx/\"+mun_id+\".p\"\n",
" if not os.path.isfile(filename):\n",
" print(\"↓\", end =\" \")\n",
"\n",
......@@ -2242,7 +2327,7 @@
"metadata": {},
"outputs": [],
"source": [
"polylist = OSM_ops_df[(OSM_ops_df.wkt_area_Km2>0.004) &(OSM_ops_df.CVEGEO==31050) & (~ OSM_ops_df.wkt.is_empty) ][\"wkt\"].to_list()\n",
"polylist = OSM_ops_df[(OSM_ops_df.wkt_area_Km2>0.00004) &(OSM_ops_df.CVEGEO==09003) & (~ OSM_ops_df.wkt.is_empty) ][\"wkt\"].to_list()\n",
"print(len(polylist))"
]
},
......@@ -2626,7 +2711,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.3"
"version": "3.13.5"
}
},
"nbformat": 4,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment