[ Log On ]
  • Home
  • Tst
  • Cha
  • Enc
  • Code
  • IP
  • Fun
  • Sub
  • DigF
  • Cis
  • Com
  • Db
  • About
  • Netsim
  • Big Data

Plotting with Geo Pandas

 

[Back] Python Geo Pandas allows Python to work with geospatial data.

Pandas axis

Plotting:

View image [SVG] View image [PNG]

Source code

The following outlines the Python code used:

import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import sys

import fiona.crs
from shapely.geometry import Point


file='1111'
val=0

world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))

cities = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))

if (val==0):
	print world.head()
	world.plot()
if (val==1):
	base = world.plot(color='white')
	cities.plot(ax=base, marker='o', color='red', markersize=5);	
if (val==2):
	world = world[(world.pop_est>0) & (world.name!="Antarctica")]
	world['gdp_per_cap'] = world.gdp_md_est / world.pop_est
	world.plot(column='gdp_per_cap');

f2=+file+".svg"

plt.savefig(f2,format='SVG')

f2= +file+".png"

plt.savefig(f2,format='PNG')

Demo