0% found this document useful (0 votes)
33 views5 pages

GIS Python

The document details the installation process of the Geopandas library and its dependencies using pip, including Fiona, Shapely, and Pyproj. It also demonstrates how to read a CSV file containing fire data and visualize it on a map using Geopandas. The final sections include code snippets for plotting geographical data and displaying it using Matplotlib.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views5 pages

GIS Python

The document details the installation process of the Geopandas library and its dependencies using pip, including Fiona, Shapely, and Pyproj. It also demonstrates how to read a CSV file containing fire data and visualize it on a map using Geopandas. The final sections include code snippets for plotting geographical data and displaying it using Matplotlib.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Untitled

November 2, 2022

[3]: !pip install geopandas


.
Defaulting to user installation because normal site-packages is not writeable
Collecting geopandas
Downloading geopandas-0.9.0-py2.py3-none-any.whl (994 kB)
|��������������������������������| 994 kB 2.3 MB/s
Collecting fiona>=1.8
Downloading
Fiona-1.8.22-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.6 MB)
|��������������������������������| 16.6 MB 116 kB/s
| 389 kB 16.3 MB/s eta 0:00:01
Collecting shapely>=1.6
Downloading
Shapely-1.8.5.post1-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
(2.0 MB)
|��������������������������������| 2.0 MB 3.5 MB/s
Requirement already satisfied: pandas>=0.24.0 in
/usr/local/lib64/python3.6/site-packages (from geopandas) (0.25.3)
Collecting pyproj>=2.2.0
Downloading pyproj-3.0.1-cp36-cp36m-manylinux2010_x86_64.whl (6.5 MB)
|��������������������������������| 6.5 MB 5.9 MB/s
Collecting munch
Downloading munch-2.5.0-py2.py3-none-any.whl (10 kB)
Collecting click>=4.0
Downloading click-8.0.4-py3-none-any.whl (97 kB)
|��������������������������������| 97 kB 1.6 MB/s
Requirement already satisfied: six>=1.7 in /usr/lib/python3.6/site-
packages (from fiona>=1.8->geopandas) (1.14.0)
Collecting click-plugins>=1.0
Downloading click_plugins-1.1.1-py2.py3-none-any.whl (7.5 kB)
Requirement already satisfied: attrs>=17 in /usr/local/lib/python3.6/site-
packages (from fiona>=1.8->geopandas) (19.3.0)
Collecting cligj>=0.5
Downloading cligj-0.7.2-py3-none-any.whl (7.1 kB)
Requirement already satisfied: setuptools in /usr/local/lib/python3.6/site-
packages (from fiona>=1.8->geopandas) (41.6.0)
Requirement already satisfied: certifi in /usr/local/lib/python3.6/site-packages
(from fiona>=1.8->geopandas) (2019.9.11)

1
Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/site-
packages (from pandas>=0.24.0->geopandas) (2019.3)
Requirement already satisfied: python-dateutil>=2.6.1 in
/usr/local/lib/python3.6/site-packages (from pandas>=0.24.0->geopandas) (2.8.1)
Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib64/python3.6/site-
packages (from pandas>=0.24.0->geopandas) (1.17.3)
Requirement already satisfied: importlib-metadata in
/usr/local/lib/python3.6/site-packages (from click>=4.0->fiona>=1.8->geopandas)
(4.8.3)
Requirement already satisfied: typing-extensions>=3.6.4 in
/usr/local/lib/python3.6/site-packages (from importlib-
metadata->click>=4.0->fiona>=1.8->geopandas) (3.10.0.0)
Requirement already satisfied: zipp>=0.5 in
/data/urk20ai1015/.local/lib/python3.6/site-packages (from importlib-
metadata->click>=4.0->fiona>=1.8->geopandas) (3.6.0)
Installing collected packages: click, munch, cligj, click-plugins, shapely,
pyproj, fiona, geopandas
WARNING: The script pyproj is installed in '/data/urk20ai1015/.local/bin'
which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this
warning, use --no-warn-script-location.
WARNING: The script fio is installed in '/data/urk20ai1015/.local/bin'
which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this
warning, use --no-warn-script-location.
Successfully installed click-8.0.4 click-plugins-1.1.1 cligj-0.7.2 fiona-1.8.22
geopandas-0.9.0 munch-2.5.0 pyproj-3.0.1 shapely-1.8.5.post1

[17]: import geopandas as gpd


import pandas as pd
.
[19]: df = pd.read_csv("fire_archive_M6_96619.csv",
usecols=["latitude", "longitude", "brightness"])
df.head()
.
[19]: latitude longitude brightness
0 -28.9087 152.3548 504.4
1 -15.5483 134.6275 500.0
2 -14.4032 132.2878 499.9
3 -28.9069 152.3487 476.9
4 -29.5197 153.3373 474.8
.
[5]: countries = gpd.read_file(
gpd.datasets.get_path("naturalearth_lowres"))
.

2
countries.head()
.
[5]: pop_est continent name iso_a3 gdp_md_est \
0 920938 Oceania Fiji FJI 8374.0
1 53950935 Africa Tanzania TZA 150600.0
2 603253 Africa W. Sahara ESH 906.5
3 35623680 North America Canada CAN 1674000.0
4 326625791 North America United States of America USA 18560000.0

geometry
0 MULTIPOLYGON (((180.00000 -16.06713, 180.00000…
1 POLYGON ((33.90371 -0.95000, 34.07262 -1.05982…
2 POLYGON ((-8.66559 27.65643, -8.66512 27.58948…
3 MULTIPOLYGON (((-122.84000 49.00000, -122.9742…
4 MULTIPOLYGON (((-122.84000 49.00000, -120.0000…
.
[21]: df.plot(x="longitude", y="latitude", kind="scatter", c="brightness",
colormap="YlOrRd")
.
[21]: <matplotlib.axes._subplots.AxesSubplot at 0x7fb9e2015b38>
.

[14]: fig = plt.Figure()


fig.set_figheight(100)
fig.set_figwidth(100)
countries.plot(color="lightgrey")
plt.show()
.

3
[33]: fig, ax = plt.subplots(figsize=(8,6))
countries[countries["name"] == "Australia"].plot(color="lightgrey", ax = ax)
df.plot(x="longitude", y="latitude", kind="scatter",
c="Blue", ax=ax)
ax.grid(b=True, alpha=0.5)
plt.show()
.

4
[ ]:
.

You might also like