Pregunta

I 'm trying to generate svg maps from the GEOFLA shapefiles.

Using 'bbox' bounds mode with manually setting the bbox values works well :

{
    "layers": [{
        "id": "depts", 
        "src": "data/DEPARTEMENTS/DEPARTEMENT.shp",
        "filter": {"CODE_REG": "24"},
        "simplify": {
            "method": "distance",
            "tolerance": 8
        },
        "attributes": "all"
    }],
    "bounds": {
        "mode": "bbox",
        "data": [-4.5, 42, 8, 48],
    },
    "export": {
       "width": 600,
       "ratio": 0.8
    }
}

But when setting the bounds mode to 'polygons', then i get an empty svg map :

{
    "layers": [{
        "id": "depts", 
        "src": "data/DEPARTEMENTS/DEPARTEMENT.shp",
        "filter": {"CODE_REG": "24"},
        "simplify": {
            "method": "distance",
            "tolerance": 8
        },
        "attributes": "all"
    }],
    "bounds": {
        "mode": "polygons",
        "data": {
            "layer": "depts"
        },
        "padding": 0.06
    },
    "export": {
       "width": 600,
       "ratio": 0.8
    }
}

I had a look in kartograph files and i noticed that the "get_features" method in "map.py" return a Polygon which coordinates doesn't intersect with the features geometry previouly extracted from the shapefile.

Then, each feature are throw away in the "get_features" method of the "maplayer.py" file when checking if feature geometry intersects with the "layer.map.view_poly" property.

¿Fue útil?

Solución

I had a similar problem using GEOFLA file projection. The solution I've found is basically to change my shapefile projection using QGIS. My idea was to use the projection of the shapefile given in installation guide which worked for me.

Get example shape file from kartograph installation page

  1. Load this vector layer in QGIS Add your GEOFLASH layer in QGIS
  2. Right-click on GEOFLASH layer and "Save as..." menu
  3. In the save window, give a new name for your layer (eg : DEPARTEMENT_WGS84.shp)
  4. Click CSR button and select the test layer projection (WGS 84 / EPSG:4326)
  5. Click OK

Check the new shape file has correct projection :

cat DEPARTEMENT_WGS84.prj
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]

Now your script should work fine using new shape file.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top