This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
countries.crs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Look at the geometry column: decimal degrees | |
countries.geometry[:5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Project the data into Mercator Projection epsg=3395 | |
countries_projected = countries.to_crs({'init': 'epsg:3395'}) | |
# See the geometry column of the projected countries | |
countries_projected['geometry'][:5] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig, ax = plt.subplots(figsize=(14,12)) | |
countries_projected.plot(ax=ax) | |
# Cities are still in WGS84 | |
cities.plot(ax=ax, color='red'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save projected countries | |
shp = '1-introData/countries_epsg3395.shp' | |
countries_projected.to_file(shp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Read the data | |
# 1. Read Countries --> Geopackage Format | |
file = '1-introData/countries.gpkg' | |
countries = gpd.read_file(file) | |
# Cities: Point data | |
cities = gpd.read_file('1-introData/cities.geojson') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GeoDataFrame | |
geoDataFrame = countries[['geometry', 'NAME']] | |
geoDataFrame.head() | |
type(geoDataFrame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GeoDataFrame | |
geoDataFrame = countries[['geometry', 'NAME']] | |
geoDataFrame.head() | |
type(geoDataFrame) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Series | |
series = countries['NAME'] | |
series[:5] | |
print(type(series)) | |
# GeoSeries | |
geoSeries = countries['geometry'] | |
geoSeries[:5] | |
print(type(geoSeries)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig, ax = plt.subplots(figsize=(12,12)) | |
geoDataFrame.centroid.plot(ax=ax) | |
plt.tight_layout() | |
plt.show() |