Geoscience Reference
In-Depth Information
ax.set_aspect(1.0)
plt.show()
This last code block includes a crucial function main as it controls the running
of the program:
if __name__ == "__main__":
main()
We can now run the script from the command line by specifying the datasource name,
i.e. the full or relative path of the Shapefile, and the color that should be used to fill
the vectors (Fig. 14.3 ).
python plotVector.py -d FRA_adm0.shp -c blue
Clearly this script only provides the user with a basic way of visualizing a vector
dataset. However, it should give the reader a good understanding of how OGR can
be used to read vector features and iterate over them using control structures. It is
also obvious that it can be enhanced to provide more functionality with respect to
scale bars, north arrow and other items to annotate the figure.
Fig. 14.3 Plot Shapefile using Python
Search WWH ::




Custom Search