working with geojson and vincent on python

360 Views Asked by At

I want to import a geojson file into python so I can map it with a visualization package vincent and merge with other data in a pandas data frame.

To be specific, the said geojson file is: http://ec2-54-235-58-226.compute-1.amazonaws.com/storage/f/2013-05-12T03%3A50%3A18.251Z/dcneighorhoodboundarieswapo.geojson. It's a map of DC with neighborhoods, put together by Justin Grimes.

Right now, I'm just trying to visualize this map on notebook. Here's my code:

import vincent
map=r'http://ec2-54-235-58-226.compute-1.amazonaws.com/storage/f/2013-05-12T03%3A50%3A18.251Z/dcneighorhoodboundarieswapo.geojson'

geo_data = [{'name': 'countries',
             'url': map,
             'feature': "features"}] 
vis = vincent.Map(geo_data=geo_data, scale=5000) 
vis

but I keep getting an error message, local host says: [Vega err] loading failed.

What am I doing wrong here?

I don't yet know much about GIS and Python so I ask you be specific in your explanation. Thank you in advance.

1

There are 1 best solutions below

0
On

At this moment you can't use for you maps with vincent anything but topojson file format (see https://github.com/mbostock/topojson/wiki).

You can convert geojson into topojson using web tools like https://mapshaper.org/ or using command-line utility (https://github.com/mbostock/topojson/wiki/Command-Line-Reference) with command like this:

topojson -p -o <target-file>.topo.json -- <input-file>.json

(-p says utility to keep properties of geometries.)