Domanda

I'm trying to combine topojson (produced from a shape file ) and data so I could display the data for relevant selection on the map, but no luck yet.

Shape file features/properties: id, code, name

Data files (I've got both .csv and josh) file 1 columns: year1, year2, year3,....identifier, %change. ('identifier' column in data files is equals to 'code' in the shape file)

I have data in 5 json files.

I was hoping, by combining these two files, to get a topojson file with properties, id, code, name, year1, year2, year3,...%change.

Idea is, I could use just one topojson file for displaying map as well as relevant data..

This is what I have tried so far,

Generating topojson: 1. ogr2ogr -f GeoJSON geojsonoutput.json shpefile.shp 2. topojson -o final.json -e *.json --id-property=identifier -p -- geojsonoutput.json

final.json : 
{
"type":"Topology",
"objects":{"geojsonoutput":{"type":"GeometryCollection","geometries":       [{"type":"Polygon","properties":{"id":"1","name":"some name"},"arcs":

, "file1" : [{id, code, name, year1, year2, year3,...%change}],
"file2" : [{id, code, name, year1, year2, year3,...%change}],

}

I could access map information by using the following,

topojson.feature(data, data.objects.geojsonoutput).features

however, not sure how I could access the data..for example in ("file1" or "file2") keys.

Actually..Am I going in the right direction? is what I have done so far correct? is there any better way achieve what I'm trying to do?

Any guidance would be great. I'm still kind of new to D3 but enjoying working with it so far.

Cheers

È stato utile?

Soluzione

Thanks to this example http://bl.ocks.org/mbostock/5562380! managed to get what I'm after..here is solution..

topojson -e data.csv --id-property id_in_shapefile,id_in_datafile -p -o final.json -- shapefile.shp

it added the properties correctly..

Cheers

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top