mapscript.shapefileObj

class mapscript.shapefileObj(filename: char, type: int = - 1)

An object representing a Shapefile. There is no write access to this object using MapScript.

Attributes

bounds

rectObj immutable Extent of shapes

numshapes

int immutable Number of shapes

thisown

The membership flag

type

int immutable Shapefile type - see mapshape.h for values of type

Methods

__init__(filename: char, type: int = - 1)[source]

Create a new instance. Omit the type argument or use a value of -1 to open an existing shapefile.

Type should be one of MS_SHP_POINT, MS_SHP_ARC, MS_SHP_POLYGON or MS_SHP_MULTIPOINT

add(shape: mapscript.shapeObj) int[source]

Appends a shape to the open shapefile. Returns MS_SUCCESS or MS_FAILURE

addPoint(point: mapscript.pointObj) int[source]

Appends a point to the open shapefile. Returns MS_SUCCESS or MS_FAILURE

get(i: int, shape: mapscript.shapeObj) int[source]

Get the shapefile feature from index i and store it in shape. Returns MS_SUCCESS or MS_FAILURE

getDBF() mapscript.DBFInfo[source]

Returns a DBFInfo object containing information on the associated DBF

getExtent(i: int, rect: rectObj) void[source]

Retrieve a shape’s bounding box by index and stores it in rect.

getPoint(i: int, point: mapscript.pointObj) int[source]

Returns the point feature at index i and store it in pointObj.

getShape(i: int) mapscript.shapeObj[source]

Returns the shapefile feature at index i. More efficient than get.

getTransformed(map: mapscript.mapObj, i: int, shape: mapscript.shapeObj) int[source]

Returns the feature at index i, simplify it, and store it in shape. Uses the map extent and cellsize for simplification. Returns MS_SUCCESS or MS_FAILURE