{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyObqNCLpsWtMml3ZpfO539Z",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
""
]
},
{
"cell_type": "code",
"source": [
"!pip install geopandas\n",
"\n",
"# install geopandas"
],
"metadata": {
"id": "d_hSpXedRHEH"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "_rrLe778Q68r"
},
"outputs": [],
"source": [
"import geopandas\n",
"from google.colab import drive\n",
"drive.mount('/content/drive')\n",
"\n",
"#impor the libraries I need"
]
},
{
"cell_type": "code",
"source": [
"data = geopandas.read_file('/content/drive/MyDrive/geospatial training/toxic_release_pennsylvania.shp')\n",
"\n",
"#read in data to variable 'data'"
],
"metadata": {
"id": "7Xzo8XOeWoQX"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"data.head()\n",
"\n",
"# View data"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 424
},
"id": "cVAm13oDXL5D",
"outputId": "4dcc9fa5-dc58-43aa-9646-06f5c5e9eeab"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" YEAR CITY COUNTY ST LATITUDE LONGITUDE \\\n",
"0 2016 PHILADELPHIA PHILADELPHIA PA 40.005901 -75.072103 \n",
"1 2016 PHILADELPHIA PHILADELPHIA PA 39.920120 -75.146410 \n",
"2 2016 PHILADELPHIA PHILADELPHIA PA 40.023880 -75.220450 \n",
"3 2016 PHILADELPHIA PHILADELPHIA PA 39.913540 -75.198890 \n",
"4 2016 PHILADELPHIA PHILADELPHIA PA 39.913540 -75.198890 \n",
"\n",
" CHEMICAL UNIT_OF_ME TOTAL_RELE \\\n",
"0 FORMIC ACID Pounds 0.160 \n",
"1 ETHYLENE GLYCOL Pounds 13353.480 \n",
"2 CERTAIN GLYCOL ETHERS Pounds 104.135 \n",
"3 LEAD COMPOUNDS Pounds 1730.280 \n",
"4 BENZENE Pounds 39863.290 \n",
"\n",
" geometry \n",
"0 POINT (2718560.227 256380.179) \n",
"1 POINT (2698674.606 224522.905) \n",
"2 POINT (2676833.394 261701.856) \n",
"3 POINT (2684030.004 221697.388) \n",
"4 POINT (2684030.004 221697.388) "
],
"text/html": [
"\n",
"
\n",
"
\n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" YEAR | \n",
" CITY | \n",
" COUNTY | \n",
" ST | \n",
" LATITUDE | \n",
" LONGITUDE | \n",
" CHEMICAL | \n",
" UNIT_OF_ME | \n",
" TOTAL_RELE | \n",
" geometry | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2016 | \n",
" PHILADELPHIA | \n",
" PHILADELPHIA | \n",
" PA | \n",
" 40.005901 | \n",
" -75.072103 | \n",
" FORMIC ACID | \n",
" Pounds | \n",
" 0.160 | \n",
" POINT (2718560.227 256380.179) | \n",
"
\n",
" \n",
" 1 | \n",
" 2016 | \n",
" PHILADELPHIA | \n",
" PHILADELPHIA | \n",
" PA | \n",
" 39.920120 | \n",
" -75.146410 | \n",
" ETHYLENE GLYCOL | \n",
" Pounds | \n",
" 13353.480 | \n",
" POINT (2698674.606 224522.905) | \n",
"
\n",
" \n",
" 2 | \n",
" 2016 | \n",
" PHILADELPHIA | \n",
" PHILADELPHIA | \n",
" PA | \n",
" 40.023880 | \n",
" -75.220450 | \n",
" CERTAIN GLYCOL ETHERS | \n",
" Pounds | \n",
" 104.135 | \n",
" POINT (2676833.394 261701.856) | \n",
"
\n",
" \n",
" 3 | \n",
" 2016 | \n",
" PHILADELPHIA | \n",
" PHILADELPHIA | \n",
" PA | \n",
" 39.913540 | \n",
" -75.198890 | \n",
" LEAD COMPOUNDS | \n",
" Pounds | \n",
" 1730.280 | \n",
" POINT (2684030.004 221697.388) | \n",
"
\n",
" \n",
" 4 | \n",
" 2016 | \n",
" PHILADELPHIA | \n",
" PHILADELPHIA | \n",
" PA | \n",
" 39.913540 | \n",
" -75.198890 | \n",
" BENZENE | \n",
" Pounds | \n",
" 39863.290 | \n",
" POINT (2684030.004 221697.388) | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
" \n",
" \n",
"\n",
" \n",
"
\n",
"
\n",
" "
]
},
"metadata": {},
"execution_count": 6
}
]
},
{
"cell_type": "code",
"source": [
"data['CHEMICAL'].unique()\n",
"\n",
"# The types of chemicals available"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "nhjoA8iCXN9B",
"outputId": "297c6a24-aabe-414d-cc4c-c4cfeb790b42"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array(['FORMIC ACID', 'ETHYLENE GLYCOL', 'CERTAIN GLYCOL ETHERS',\n",
" 'LEAD COMPOUNDS', 'BENZENE', 'ETHYLBENZENE',\n",
" '1,2,4-TRIMETHYLBENZENE',\n",
" 'SULFURIC ACID (1994 AND AFTER ACID AEROSOLS\" ONLY)\"',\n",
" 'ZINC COMPOUNDS', 'BARIUM COMPOUNDS', 'ANTIMONY COMPOUNDS',\n",
" 'MERCURY COMPOUNDS', 'SILVER', 'PHTHALIC ANHYDRIDE',\n",
" 'DICYCLOPENTADIENE', 'AMMONIA', 'STYRENE', 'NICKEL',\n",
" 'TETRABROMOBISPHENOL A', 'TOLUENE', 'N-BUTYL ALCOHOL', 'COPPER',\n",
" 'PHENOL', 'XYLENE (MIXED ISOMERS)', 'CUMENE', 'METHANOL',\n",
" 'ETHYLENE', 'HYDROGEN SULFIDE', 'NICKEL COMPOUNDS', 'PROPYLENE',\n",
" 'ACETOPHENONE', 'TRADE SECRET CHEMICAL', 'MANGANESE',\n",
" 'CUMENE HYDROPEROXIDE', 'LEAD', 'METHYL METHACRYLATE', 'CHROMIUM',\n",
" 'BENZO(G,H,I)PERYLENE', 'COPPER COMPOUNDS', 'N-HEXANE',\n",
" 'ACETALDEHYDE', 'MALEIC ANHYDRIDE', 'FORMALDEHYDE',\n",
" '2,2-BIS(BROMOMETHYL)-1,3-PROPANEDIOL', 'MANGANESE COMPOUNDS',\n",
" 'HYDROGEN CYANIDE', 'DICHLOROMETHANE', 'PROPIONALDEHYDE',\n",
" 'COBALT COMPOUNDS', 'NAPHTHALENE', 'CYCLOHEXANE',\n",
" 'HYDROGEN FLUORIDE', 'POLYCYCLIC AROMATIC COMPOUNDS',\n",
" 'ZINC (FUME OR DUST)', 'TETRACHLOROETHYLENE', 'TRICHLOROETHYLENE',\n",
" 'BENZOYL PEROXIDE', 'MERCURY', 'NITRIC ACID',\n",
" 'N,N-DIMETHYLFORMAMIDE', 'N-METHYL-2-PYRROLIDONE', 'OXYFLUORFEN',\n",
" 'POLYCHLORINATED BIPHENYLS', 'METHYL ISOBUTYL KETONE',\n",
" 'ASBESTOS (FRIABLE)', 'NITRATE COMPOUNDS',\n",
" 'DI(2-ETHYLHEXYL) PHTHALATE', 'DIETHANOLAMINE',\n",
" 'METHYL TERT-BUTYL ETHER', 'CHLORODIFLUOROMETHANE',\n",
" 'DIBUTYL PHTHALATE', 'DIOXIN AND DIOXIN-LIKE COMPOUNDS', 'MIXTURE',\n",
" 'VANADIUM COMPOUNDS', '1,3-BUTADIENE', 'METHYL ETHYL KETONE',\n",
" 'CYANIDE COMPOUNDS', 'DECABROMODIPHENYL OXIDE', 'SODIUM NITRITE',\n",
" '1,2-BUTYLENE OXIDE',\n",
" 'CHROMIUM COMPOUNDS(EXCEPT CHROMITE ORE MINED IN THE TRANSVAAL REGION)',\n",
" 'TERT-BUTYL ALCOHOL', '1,2-DICHLOROETHANE',\n",
" 'TOLUENE DIISOCYANATE (MIXED ISOMERS)', 'CHLORENDIC ACID',\n",
" 'BUTYL ACRYLATE', 'CHLORINE', 'SEC-BUTYL ALCOHOL',\n",
" 'ALUMINUM (FUME OR DUST)', 'POLYCHLORINATED ALKANES',\n",
" 'LITHIUM CARBONATE', 'PHOSPHORIC ACID', 'BERYLLIUM',\n",
" 'HYDROCHLORIC ACID (1995 AND AFTER ACID AEROSOLS\" ONLY)\"',\n",
" 'COBALT', 'CHLOROMETHANE', 'CADMIUM', '2-ETHOXYETHANOL',\n",
" 'O-XYLENE', 'FREON 113', '1,1,1-TRICHLOROETHANE',\n",
" 'ISOBUTYRALDEHYDE', 'ETHYLENE OXIDE', '1,2-DICHLOROPROPANE',\n",
" 'M-XYLENE', 'BENZYL CHLORIDE', 'ARSENIC COMPOUNDS',\n",
" 'PROPYLENE OXIDE', 'CARBON TETRACHLORIDE',\n",
" 'DICHLORODIFLUOROMETHANE', 'P-XYLENE', 'ACETONE',\n",
" '1,4-DICHLOROBENZENE', 'CHLOROMETHYL METHYL ETHER', 'BROMOMETHANE',\n",
" 'TOLUENE-2,4-DIISOCYANATE', 'AMMONIUM SULFATE (SOLUTION)',\n",
" 'CHLOROPHENOLS', 'EPICHLOROHYDRIN', 'BIS(CHLOROMETHYL) ETHER',\n",
" 'CHLOROFORM', 'BIPHENYL',\n",
" 'ISOPROPYL ALCOHOL (MANUFACTURING,STRONG-ACID PROCESS ONLY,NO SUPPLIER)',\n",
" 'CHLOROBENZENE', 'DIETHYL PHTHALATE', 'MOLYBDENUM TRIOXIDE',\n",
" '1,2,4-TRICHLOROBENZENE', 'ACRYLIC ACID', 'N-DIOCTYL PHTHALATE',\n",
" 'ALUMINUM OXIDE (FIBROUS FORMS)', 'PHOSPHORUS (YELLOW OR WHITE)',\n",
" 'SODIUM HYDROXIDE (SOLUTION)', 'ANTIMONY', 'BARIUM',\n",
" 'TOLUENE-2,6-DIISOCYANATE', 'SODIUM SULFATE (SOLUTION)',\n",
" '1,2-DIBROMOETHANE', 'VINYL CHLORIDE'], dtype=object)"
]
},
"metadata": {},
"execution_count": 15
}
]
},
{
"cell_type": "markdown",
"source": [
"From assessment this data is only on Pennsylvania, I will drop non-relevant columns"
],
"metadata": {
"id": "3DgLlG9QYNDN"
}
},
{
"cell_type": "code",
"source": [
"data = data.drop(['CITY','COUNTY','ST'], axis = 1)"
],
"metadata": {
"id": "NaaLg_k7X459"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"data. head()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 206
},
"id": "rFyQneOPYxc6",
"outputId": "51d73635-8672-40f4-bc0c-e77f48ef0aa8"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
" YEAR LATITUDE LONGITUDE CHEMICAL UNIT_OF_ME TOTAL_RELE \\\n",
"0 2016 40.005901 -75.072103 FORMIC ACID Pounds 0.160 \n",
"1 2016 39.920120 -75.146410 ETHYLENE GLYCOL Pounds 13353.480 \n",
"2 2016 40.023880 -75.220450 CERTAIN GLYCOL ETHERS Pounds 104.135 \n",
"3 2016 39.913540 -75.198890 LEAD COMPOUNDS Pounds 1730.280 \n",
"4 2016 39.913540 -75.198890 BENZENE Pounds 39863.290 \n",
"\n",
" geometry \n",
"0 POINT (2718560.227 256380.179) \n",
"1 POINT (2698674.606 224522.905) \n",
"2 POINT (2676833.394 261701.856) \n",
"3 POINT (2684030.004 221697.388) \n",
"4 POINT (2684030.004 221697.388) "
],
"text/html": [
"\n",
" \n",
"
\n",
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" YEAR | \n",
" LATITUDE | \n",
" LONGITUDE | \n",
" CHEMICAL | \n",
" UNIT_OF_ME | \n",
" TOTAL_RELE | \n",
" geometry | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" 2016 | \n",
" 40.005901 | \n",
" -75.072103 | \n",
" FORMIC ACID | \n",
" Pounds | \n",
" 0.160 | \n",
" POINT (2718560.227 256380.179) | \n",
"
\n",
" \n",
" 1 | \n",
" 2016 | \n",
" 39.920120 | \n",
" -75.146410 | \n",
" ETHYLENE GLYCOL | \n",
" Pounds | \n",
" 13353.480 | \n",
" POINT (2698674.606 224522.905) | \n",
"
\n",
" \n",
" 2 | \n",
" 2016 | \n",
" 40.023880 | \n",
" -75.220450 | \n",
" CERTAIN GLYCOL ETHERS | \n",
" Pounds | \n",
" 104.135 | \n",
" POINT (2676833.394 261701.856) | \n",
"
\n",
" \n",
" 3 | \n",
" 2016 | \n",
" 39.913540 | \n",
" -75.198890 | \n",
" LEAD COMPOUNDS | \n",
" Pounds | \n",
" 1730.280 | \n",
" POINT (2684030.004 221697.388) | \n",
"
\n",
" \n",
" 4 | \n",
" 2016 | \n",
" 39.913540 | \n",
" -75.198890 | \n",
" BENZENE | \n",
" Pounds | \n",
" 39863.290 | \n",
" POINT (2684030.004 221697.388) | \n",
"
\n",
" \n",
"
\n",
"
\n",
"
\n",
" \n",
" \n",
"\n",
" \n",
"
\n",
"
\n",
" "
]
},
"metadata": {},
"execution_count": 20
}
]
},
{
"cell_type": "code",
"source": [
"data['geometry'].plot()"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 465
},
"id": "7RCBMd-FZAA4",
"outputId": "b17a5f1f-7798-47d8-cb5f-9e7a45d52225"
},
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
""
]
},
"metadata": {},
"execution_count": 22
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"