Creating Geometries and Handling Projections with OGR
Creating Geometries and Handling Projections with
OGR
Open Source RS/GIS Python Week 2
OS Python week 2: Geometries & projections [1]
Creating a new geometry
1. Create an empty Geometry object with
ogr.Geometry()
2. Define what the geometry is in a different way for each type (point, line, polygon, etc.)
OS Python week 2: Geometries & projections [2]
Creating points
? Use AddPoint( , , []) to set coordinates
? The height value is optional and defaults to 0
point = ogr.Geometry(ogr.wkbPoint) point.AddPoint(10,20)
OS Python week 2: Geometries & projections [3]
Creating lines
? Add new vertices to the line with
AddPoint(, , [])
? Change the coordinates of a vertex with
SetPoint(, , , [])
where is the index of the vertex to change
line = ogr.Geometry(ogr.wkbLineString) line.AddPoint(10,10) line.AddPoint(20,20) line.SetPoint(0,30,30) #(10,10) -> (30,30)
OS Python week 2: Geometries & projections [4]
? To get the number of vertices in a line use
GetPointCount()
print line.GetPointCount()
? To get the x,y coordinates for a specific vertex use GetX() and
GetY()
print line.GetX(0) print line.GetY(0)
OS Python week 2: Geometries & projections [5]
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- roblox username and password list with robux
- data classification and handling policy
- muscle and joint pain with fatigue
- phrase and clause worksheets with answer key
- adding and subtracting fractions with like denominators
- mean median and mode worksheets with answers
- ratio and proportion worksheets with answers
- chicken and rice casserole with minute rice
- creating tables and graphs ratios
- free shipping and handling codes
- speed and velocity worksheets with answers
- find and fix problems with devices dvd