1 / 31

GIS 4107 – Day 9

GIS 4107 – Day 9. Base data for Canada. The following is perhaps the best link to vector topographic base data for Canada http://geogratis.gc.ca/geogratis/DownloadDirectory Contains CanVec (1:10k – 1:50k), NTDB (1:50k, 1:250k standard topo maps), 1:1M ( VMap Level 0 – based on DCW).

analu
Télécharger la présentation

GIS 4107 – Day 9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GIS 4107 – Day 9

  2. Base data for Canada The following is perhaps the best link to vector topographic base data for Canada • http://geogratis.gc.ca/geogratis/DownloadDirectory Contains • CanVec (1:10k – 1:50k), • NTDB (1:50k, 1:250k standard topo maps), • 1:1M (VMap Level 0 – based on DCW)

  3. Canada KissMap http://canadakissmap.com/

  4. Overview • The Basics – Python classes and objects • Procedural vs OO Programming • Entity modelling • Operations / methods • Program flow • OOP Concepts and user-defined classes / objects • Class • Object • Python’s self parameter • Overrideable methods __init__ and __str__ • Accessor and mutator methods(“Getter” and “Setter” methods) • Class diagrams in UML

  5. Classes are everywhere …

  6. Python programs • A Python program is a sequence of Python statements in one or more files • When a Python program is executing, everything in a Python program is an object • Each object has a type Program output:

  7. Object and Class Object’s type = Class used to create the object Object can also be referred to as an instance of a class.

  8. Each object has … • A type (class that created it) • Identity (location in computer memory) • Data attributes (variables in a class) and/or methods (functions in a class) • Special data attributes and/or methods prefixed and suffixed with a double underscore (e.g. __doc__)

  9. Variables and objects • Variables are names associated with objects • The object's data attributes and methods can be accessed using the dot operator with the name of the data attribute or method dot operator

  10. Special data attributes and methods • Data attributes (e.g. __doc__, __class__, etc) • Methods (e.g. __add__, __str__, etc) NOTE:

  11. Mutable and Immutable objects • If object data attributes can be changed, the object is mutable • If object data attributes cannot be changed, the object is immutable

  12. One object with many names Assignment of variables to the same values means the variables will be associated with the same objects (same identity and type) Output:

  13. Variables with immutable and mutable types • Assigning variables of immutable types to another and then changing either value creates a new object • Assigning variables of mutable types to one another and then changing either value will modify the value of both immutable mutable

  14. The is operator and isinstance function • The is operator checks to see if the identity of the operands is the same • The isinstance(object, class | type | tuple) built-in function returns True or False

  15. To get a list of standard Python classes, etc. help('__builtin__') provides list of built-in classes, functions, and data

  16. Overview • The Basics – Python classes and objects • Procedural vs OO Programming • Entity modelling • Operations / methods • Program flow • OOP Concepts and user-defined classes / objects • Class • Object • Python’s self parameter • Overrideable methods __init__ and __str__ • Accessor and mutator methods(“Getter” and “Setter” methods) • Class diagrams in UML

  17. Procedural Programming Object Oriented Programming(OOP) Proc vs OOP Good for simple programs with simple flows and models Good for complex programs with complex models and interactions. Not good for modelling real-world objects and interactions. Overkill for simple programs.

  18. Entity representation Procedural Programming Object Oriented Programming(OOP) Entities represented by groups of variables Entities represented by abstractions of real-world objects

  19. Methods Procedural Programming Object Oriented Programming(OOP) Operations represented by functions available at module level Operations represented by object methods available at object level Object properties and methods are encapsulated by the object instance.

  20. Procedural Programming Object Oriented Programming(OOP) Program flow Procedural-OOP Hybrid: Program flow controlled by order of creating objects, calling its methods, and setting its properties. OOP: Program flow controlled by messages sent between objects and/or events raised by an object, code that responds to those events. Program flow controlled by order of setting variables, calling functions, and passing data between functions.

  21. OOP Concepts - Class A class is a template for an object. The class defines the data attributes (properties) and methods (functions in a class) that will be common to all objects created from it. Create user-defined classes using classkeyword.

  22. OOP Concepts - Object Instance of a classcreated when the class definition is executed. Every instance of the class will have thesame attributes -- properties and methods -- but can have different data (property values)

  23. Python’s (self) parameter It is a parameter that gets assigned “automatically” to the object being processed. “self” is the first, and sometimes only, parameter in methods Name “self” is Python convention. Could beanything.

  24. Manual and automatic passing of instance

  25. __init__ ( self [,params] ) It is the first method run when the class is called. The initialization method or constructor.

  26. __str__( self ) Another of many methods that are common to all classes in Python that you can override(replace default behaviour with your own) Others include: __len__ __add__ __eq__ __lt__ etc.

  27. Accessor (“getter”) method Control getting property values (object data) __private No accessor.

  28. Mutator (“setter”) method Control setting property values (object data) Dice __color : str __value : int setColor(color : str) getColor() : str roll() : void getValue() : int

  29. Class Diagram in UML Key Class name Properties (data attributes) Methods Dice __color : str __value : int setColor(color : str) getColor() : str roll() : void getValue() : int

  30. Overview • The Basics – Python classes and objects • Procedural vs OO Programming • Entity modelling • Operations / methods • Program flow • OOP Concepts and user-defined classes / objects • Class • Object • Python’s self parameter • Overrideable methods __init__ and __str__ • Accessor and mutator methods(“Getter” and “Setter” methods) • Class diagrams in UML

More Related