Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • M mapnik3
  • Project information
    • Project information
    • Activity
    • Members
  • Analytics
    • Analytics
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
Collapse sidebar
  • 周峰
  • mapnik3
  • Wiki
  • ShapeFile

ShapeFile · Changes

Page history
clone mapnik wiki from github. authored May 14, 2021 by 周峰's avatar 周峰
Show whitespace changes
Inline Side-by-side
ShapeFile.md 0 → 100644
View page @ 8516de00
<!-- Name: ShapeFile -->
<!-- Version: 2 -->
<!-- Last-Modified: 2009/12/11 13:26:05 -->
<!-- Author: springmeyer -->
# Shapefile Plugin
This plugin supports reading shapefiles. They can also be read using the [[OGR]] Plugin, but the *shape* plugin is better tested and more mature.
The shapefile plugin will run fastest if you build indexes for your shapefiles using the 'shapeindex' command line tool installed when you build Mapnik.
For other plugins see: [[PluginArchitecture]]
# Installation
To check if the raster plugin built and was installed correctly you can do:
```python
>>> from mapnik import DatasourceCache as c
>>> 'shape' in c.plugin_names()
True
```
## Parameters
| *parameter* | *value* | *description* | *default* |
|:------------------|----------|---------------|----------:|
| encoding | string | Encoding Used | utf-8. ESRI Shapefiles are usually 'latin1' |
| file | string | name of shapefile (without extension) | |
# Styling
To style a layer, use any of the Symbolizers like Point, Polygon, or Line, depending on the geometry type.
# Usage
## Python
## C++
Plugin datasource initialization example code can be found on PluginArchitecture.
A Shapefile datasource may be created as follows:
```cpp
{
parameters p;
p["type"]="shape";
p["file"]="path/to/my/shapefile.shp";
// Bridges
Layer lyr("Vector");
lyr.set_datasource(datasource_cache::instance()->create(p));
lyr.add_style("vector");
m.addLayer(lyr);
}
```
## XML
```xml
<Layer name="vector" srs="+init=epsg:4236">
<StyleName>polygon</StyleName>
<Datasource>
<Parameter name="type">shape</Parameter>
<!-- you can also point to your shapefile without the 'shp' extention -->
<Parameter name="file">/path/to/your/shapefile.shp</Parameter>
</Datasource>
</Layer>
```
## Further References
Clone repository
  • A perfect testcase
  • API changes between v2.0 and v2.1
  • API changes between v3.0 and v3.1
  • AWS Lambda
  • About Mapnik
  • AlsoFilter
  • Api changes between v2.1 and v2.2
  • Api changes between v2.2 and v2.3
  • Api changes between v2.3 and v3.0
  • ArchInstallation
  • Aspect Fix Mode
  • Benchmark Notes
  • BoundsClipping
  • BrokenExceptions
  • BuildingSymbolizer
View All Pages