Useful links and snippets regarding Python and Jupyter notebooks


iPython/Jupyter resources

Quick and dirty

  • Decode URLs using Python
    • # py3
      from urllib import parse
      # or in py2.7
      import urllib
    • Translate coordinate reference system from *.prj files to proj4-Syntax as required by QGIS using the gdal python module (via GIS on Stackexchange:
    • import sys
      from osgeo import osr
      prjtxt = """PROJCS["your_crs",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["the_prj"],PARAMETER["Central_Meridian",0.0],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["Latitude_Of_Origin",0.0],PARAMETER["Standard_Parallel_1",-10],PARAMETER["Standard_Parallel_2",50],UNIT["Meter",1.0],AUTHORITY["me",123456]]"""
      srs = osr.SpatialReference()
      print 'Proj4 is: %s' % srs.ExportToProj4()
      Proj4 is: <string with proj4 parameters follows>
  • Installing a new module in Enthough Canopy Light's distro on Windows: I managed to install the DBF module by navigating to the unzipped content downloaded in the Python console. Then I just typed %run install and the compiled module is then installed in the Canopy's User\Lib\site-packages directory. Easy.