concept point in category geoprocessing

This is an excerpt from Manning's book Geoprocessing with Python.
You’ll learn how to work with the two main types of spatial data, vector and raster. Vector data is made up of points, lines, and polygons, while raster data is a two- or three-dimensional array of data values such as the pixels in a photograph. A dataset containing country boundaries is an example of vector data. In this case, each country is generally represented as a polygon. Datasets that use lines to represent roads or rivers, or points to show the location of weather stations, are other examples. Early primitive maps, such as those drawn on cave walls, only showed the features themselves. Later maps contained labels for features of interest such as cities or seaports; for example, the Portolan map of northwest Africa shown in figure 1.1.
You have several kinds of geometries with which you can work, points being the simplest. All other types are made up of points connected by straight line segments, and the points are what store the coordinate values, so points can be thought of as the building blocks of geometries. These points that are used to build other geometries are called vertices, and there can be thousands of vertices per geometry, if needed. For example, line geometries are an ordered collection of points that are connected by straight line segments, with a vertex at every location where the line needs to change direction. A line representing a short dead-end street wouldn’t require many vertices, but one representing the Amazon River in much detail would need thousands. Polygons are somewhat similar to lines, but they’re closed, meaning the first and last vertex are identical and they enclose a specific area. You’ll start with creating and editing points and work your way up to the more complicated geometries as you go along.
Multipoint geometries contain one or more points in a single object. This means that multiple points can be attached to a single feature rather than requiring a separate feature per point. For example, a dataset with multiple points might be the locations of all fire hydrants within city boundaries, where each hydrant is treated as a unique feature. Perhaps you also want to map outdoor water faucets in private yards. In this case, you might treat all spigots in an individual yard as one multipoint item so that you have only one feature per yard. In fact, that’s what you’ll do with the yard example. Three faucets are shown as circles in figure 6.4, and you’ll build one multipoint object with three vertices to represent them.
Figure 6.4. You can use a multipoint geometry to hold the water spigot geometries, shown here as dots.
![]()
To create a multipoint geometry, you need to create at least two geometries. You need at least one point object and also a multipoint object to hold the points. Referring back to table 6.1, you can see that the correct OGR constant for a multipoint object is wkbMultiPoint. You create the points exactly as before and then add them to your multipoint geometry. Here’s one way to do this, using coordinates obtained from figure 6.4:
You can get a specific point from a multipoint geometry by passing the index of the desired point to GetGeometryRef. The first point added has index 0, the second has index 1, and so on. Once you have an individual point, you can edit it the same way as a single point. Because GetGeometryRef returns a reference to the point inside the multipoint instead of a copy, the multipoint is automatically updated when the point is changed. For example, this would get the second faucet and then edit its coordinates:
faucets.GetGeometryRef(1).AddPoint(75, 32)You can also find out how many points are in a multipoint object, which is useful if you need to loop through them all. For example, to move all spigots two meters to the east, you’d need to loop through the points and add 2 to each x coordinate while leaving the y coordinates unchanged. The results are shown in figure 6.5.
As with points, the first step to creating a line geometry is to create an empty Geometry object and then add the vertices. Although the direction you traverse the line when adding coordinates isn’t important, the vertices must be added in order. Try creating the line representing the sidewalk shown in figure 6.8, going from west to east: