class LayerMapping(model, data_source, mapping, layer=0, source_srs=None, encoding=None, transaction_mode='commit_on_success', transform=True, unique=True, using='default')
The following are the arguments and keywords that may be used during instantiation of LayerMapping
objects.
Argument | Description |
---|---|
model | The geographic model, not an instance. |
data_source | The path to the OGR-supported data source file (e.g., a shapefile). Also accepts django.contrib.gis.gdal.DataSource instances. |
mapping | A dictionary: keys are strings corresponding to the model field, and values correspond to string field names for the OGR feature, or if the model field is a geographic then it should correspond to the OGR geometry type, e.g., 'POINT' , 'LINESTRING' , 'POLYGON' . |
Keyword Arguments | |
---|---|
layer | The index of the layer to use from the Data Source (defaults to 0) |
source_srs | Use this to specify the source SRS manually (for example, some shapefiles don’t come with a '.prj' file). An integer SRID, WKT or PROJ.4 strings, and django.contrib.gis.gdal.SpatialReference objects are accepted. |
encoding | Specifies the character set encoding of the strings in the OGR data source. For example, 'latin-1' , 'utf-8' , and 'cp437' are all valid encoding parameters. |
transaction_mode | May be 'commit_on_success' (default) or 'autocommit' . |
transform | Setting this to False will disable coordinate transformations. In other words, geometries will be inserted into the database unmodified from their original state in the data source. |
unique | Setting this to the name, or a tuple of names, from the given model will create models unique only to the given name(s). Geometries from each feature will be added into the collection associated with the unique model. Forces the transaction mode to be 'autocommit' . |
using | Sets the database to use when importing spatial data. Default is 'default' . |
Please login to continue.