jvectormap
jvectormap copied to clipboard
What environments are people using to get these converter or processor scripts to run?
I attempted using the converter on some US Census Tiger Line shape files. I was using python 2.7, 3.6, & 3.7 with Anaconda.
I'm running OS X 10.15.
On python 3.7 there were some syntax errors print "message" vs. print("message").
My most recent progress gets me here:
(jvectormapmaker) jserra1-3:converter jserra$ python converter.py pa.json pa.js
Traceback (most recent call last):
File "converter.py", line 298, in <module>
paramsJson = json.loads(paramsJson)
File "/Users/jserra/opt/anaconda3/envs/jvectormapmaker/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/Users/jserra/opt/anaconda3/envs/jvectormapmaker/lib/python3.7/json/decoder.py", line 340, in decode
raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 4 column 2 (char 62)
Here is my configuration file:
{
"name": "read_data",
"file_name": "map_data/US-PA.shp"
},{
"name": "write_data",
"format": "jvectormap",
"params": {
"code_field": "STATEFP",
"name_field": "NAME",
"name": "us-pa"
}
}
If I add []'s around my config file like this:
[{
"name": "read_data",
"file_name": "map_data/US-PA.shp"
},{
"name": "write_data",
"format": "jvectormap",
"params": {
"code_field": "STATEFP",
"name_field": "NAME",
"name": "us-pa"
}
}]
My result is as follows:
Traceback (most recent call last):
File "converter.py", line 300, in <module>
converter = Converter(paramsJson)
File "converter.py", line 49, in __init__
args.update(config)
ValueError: dictionary update sequence element #1 has length 3; 2 is required
This looks like a great tool, if I could only figure out the right configuration for the environment to run it.
Your second config file should apply to processor.py. According to code : https://github.com/bjornd/jvectormap/blob/master/converter/converter.py#L54 The config file should be like this if you want to use converter.py:
{
"input_file": "path_to_shp_file",
"output_file": "the js file path/name generated by converter.py",
"code_field": "ISO_A2",
"name_field": "NAME",
"input_file_encoding": "UTF-8"
}
This works for me. If you need more options, I suggest you review the converter.py code.