Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble Joining Features in a Layer #13

Open
cspencer51 opened this issue Mar 8, 2013 · 7 comments
Open

Trouble Joining Features in a Layer #13

cspencer51 opened this issue Mar 8, 2013 · 7 comments

Comments

@cspencer51
Copy link

I realize this may not be a bug and is probably just a problem with the way I am trying to group these regions together, but I couldn't find any message board where I could post my question.

I am trying to create an SVG of the U.S Virgin Islands using Kartograph via the command line. I have read through the documentation multiple times and have been able to get Kartograph to produce a simple .svg file using the following json array:

{
        "layers": [{
                "src": "vi_shapes_fips.shp",
                "attributes": ["state_fips", "state"]
        }]
}

However, it does not produce an .svg file when I try to create an SVG where the islands are grouped by FIPS code (one of the attributes in the .shp file using the following json array:

{
        "layers": [{
                "src": "vi_shapes_fips.shp",
                "attributes": ["state_fips", "state"],
                "join": {
                        "group-by": "state_fips",
                        "groups": {
                                "St_Thomas": [78030],
                                "St_John": [78020],
                                "St_Croix": [78010]
                        },
                        "
                        "export-ids": "no"
                }
        }]
}

When I use the grouping json array, I get the following output:

  cli.py, in render_map()
  71: K.generate(cfg, args.output, preview=args.preview, format=format, stylesheet=css)  kartograph.py, in generate()
  46: _map = Map(opts, self.layerCache, format=format)  map.py, in __init__()
  64: me._join_features()  map.py, in _join_features()
  509: if join['export-ids']:
 'export-ids'

There doesn't seem to be any error. But I'm also not sure what I've done wrong. I've looked through the code and not been able to figure it out. Again, this probably isn't a bug, just me not completely understanding how to use the tool. Any help would be appreciated. This is an amazing tool and will save me a lot of time if I can get it working properly. Thanks!

@gka
Copy link
Contributor

gka commented Mar 8, 2013

The second config you posted doesn't seem to be valid. There's a " in the line before "export-ids": "no". Do you have used the same config?

Could you try to provide a reproducible example, perhaps using a free shapefile?
Btw, have your tried without that "export-ids"?

@cspencer51
Copy link
Author

Thanks for the quick reply, gka! Sorry, I must have copied that file before I saved the changes to it. Here is the corrected json that I was using and causing an error:

{
        "layers": [{
                "src": "vi_shapes_fips.shp",
                "attributes": ["state_fips", "state"],
                "join": {
                        "group-by": "state_fips",
                        "groups": {
                                "St_Thomas": [78030],
                                "St_John": [78020],
                                "St_Croix": [78010]
                        }
                }
        }]
}

But I get the same error when I try to group all countries by continent using your sample ne_50m_admin_0_countries.shp file. Here's the .json file I used:

{
   "layers": [{
       "src": "ne_50m_admin_0_countries.shp",
        "join": {
                "group-by": "continent"
        }
   }]
}

And here's the error I get when trying to group the countries by continent:

cli.py, in render_map()
  71: K.generate(cfg, args.output, preview=args.preview, format=format, stylesheet=css)  kartograph.py, in generate()
  46: _map = Map(opts, self.layerCache, format=format)  map.py, in __init__()
  64: me._join_features()  map.py, in _join_features()
  509: if join['export-ids']:
'export-ids'

If I use the json without the "join", it creates an .svg just fine:

{
    "layers": [{
        "src": "ne_50m_admin_0_countries.shp"
    }]
}

Thanks again for your help.

@chilles1
Copy link

Hi, I have exactly the same error. Is there already a solution?

This config works perfectly:

{
    "id": "continents",
    "src": "ne_50m_admin_0_countries.shp",
    "class": "continents",
    "attributes": "all",
    "filter-islands": 40,
    "filter": { 
        "and": [
            ["adm0_a3", "not in", ["ATA"]]
        ]
    },
    "join": {
        "group-by": "continent", "group-as": "region_code",
        "attributes": { "admin": "continent" },
        "export-ids": "adm0_a3"
    },
    "simplify": 0
}

But I need to group special countries. So I tried the following:

{
            "id": "continents",
            "src": "ne_50m_admin_0_countries.shp",
            "class": "continents",
            "filter": {
                "and": [
                    ["iso_a2", "in", ["AI", "AG", "AW", "BB", "BZ", "VG", "CR", "CW", "BS", "DM", "DO", "SV", "GD", "GT", "HT", "HN", "JM", "VI", "KY", "CU", "MS", "NI", "PA", "PR", "SX", "BL", "KN", "LC", "MF", "VC", "TT", "TC"]]
                ]
            },
            "join": {
                    "group-by": "iso_a2",
                    "groups": {
                        "CAC": ["AI", "AG", "AW", "BB", "BZ", "VG", "CR", "CW", "BS", "DM", "DO", "SV", "GD", "GT", "HT", "HN", "JM", "VI", "KY", "CU", "MS", "NI", "PA", "PR", "SX", "BL", "KN", "LC", "MF", "VC", "TT", "TC"]
                    }
            },
            "simplify": 0
        }

Then I get the error:

cli.py, in render_map()
  66: K.generate(cfg, args.output, preview=args.preview, format=format, stylesheet=css)  kartograph.py, in generate()
  46: _map = Map(opts, self.layerCache, format=format)  map.py, in __init__()
  65: me._join_features()  map.py, in _join_features()
  503: if join['export-ids']:
'export-ids'

Thanks for help!
Christian

@cspencer51
Copy link
Author

Hi gka. Just wondering what the status of this issue is. Did chilles1 and I uncover a bug that you are trying to fix or is there a problem with our configuration arrays? Thanks!

@slaweet
Copy link

slaweet commented Sep 17, 2013

I had exactly the same error and I was able to fix it by setting "export-ids" property with value false to "join".
Like this:

{
   "layers": [{
       "src": "ne_50m_admin_0_countries.shp",
        "join": {
                "group-by": "continent",
                "export-ids": false
        }
   }]
}

@stefanvangastel
Copy link

Same issue here.
509: if join['export-ids']:

Also fixed it with the "export-ids": false workaround

@navgarcha
Copy link

Same issue and once again it was resolved by setting "export-ids": false - is there a fix for this coming in the main repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants