I wish to visualize geographical data in Python, without using ArcGIS/ArcPy, and make a map.
On the internet I found how to make a thematic map using Python:
Here is some code that I tried:
import shpUtils
import matplotlib.pyplot as plt
shpRecords = shpUtils.loadShapefile('C:\\Users\\shapefile.shp')
for i in range(0,len(shpRecords)):
x = []
y = []
for j in range(0,len(shpRecords[i]['shp_data']['parts'][0]['points'])):
tempx = float(shpRecords[i]['shp_data']['parts'][0]['points'][j]['x'])
tempy = float(shpRecords[i]['shp_data']['parts'][0]['points'][j]['y'])
x.append(tempx)
y.append(tempy)
plt.fill(x,y)
plt.axis('equal')
plt.title("Testing")
plt.show()
However, when I run this, it gives me random colors.
If I want to visualise one certain column of my shapefile, how can I implement this using similar code?
This is very unclear in the link provided above where he only discusses the usage of colors…
Would I perhaps need extra modules to accomplish this, like descartes and PySAL?
Best Answer
I do not know ArcPy, but I work with shapefiles and raster in Python for years
After that, it's like a GIS:
So, you must learn matplotib and the other modules. You have to learn ArcPy, it's the same...(there are lots of excellent tutorials on the web, especially for matplolib, and it's easier that ArcPy because it is pure Python).
Some examples with Python only
Geological map (polygon shapefile) with colors based on an attribute
3D Points (PointZ shapefile) with color based on an attribute
3D points (Point shapefile with z as attribute) and 3D line (PolyLineZ shapefile) on a DEM, and on a raster draped onto the DEM surface.
Topographic profile with z values and colors based on attributes (geological formations = Cross section) of the original shapefile (Polyline shapefile)
DEM (GeoTIFF) with the module Mayavi2
DEM (ESRI ascii grid, .asc) and Point shapefiles (with z as attribute) with the module visvis
Boreholes (3D buffer of a polylineZ with colors based on an attribute (geological formations), with a grid surface calculated with the modules numpy and matplotlib from a points shapefile (with z as an attribute), visualized with the module visvis