topojson

Scaling d3 v4 map to fit SVG (or at all)

假如想象 提交于 2019-12-27 10:39:41
问题 I am trying to make this map of the us scale smaller. Either to my SVG, or even manually. This is my code in its simplest from: function initializeMapDifferent(){ var svg = d3.select("#map").append("svg") .attr("width", 1000) .attr("height", 500); d3.json("https://d3js.org/us-10m.v1.json", function (error, us){ svg.append("g") .attr("class", "states") .selectAll("path") .data(topojson.feature(us, us.objects.states).features) .enter().append("path") .attr("fill", "gray") .attr("d", d3.geoPath(

Queue error “Uncaught TypeError: Cannot read property 'objects' of null”

こ雲淡風輕ζ 提交于 2019-12-24 11:25:06
问题 I'm trying to using queues to ensure my files are loaded fully before the script continues. However, when I load in my json map files and try to use them in a function, I get an error. var counties = svg.append("g") .attr("id", "counties") .attr("class", "Blues"); var states = svg.append("g") .attr("id", "states"); queue() .defer(d3.json, "county.json") .defer(d3.json, "state.json") .defer(d3.json, "Crashes.json") .await(ready); function ready(county, state, crashes) { var countyFeatures =

D3.js - Changes from path.area in version 2 to version 4

邮差的信 提交于 2019-12-24 11:18:52
问题 I am trying to update d3-cartogram to work with D3.js version 4. So far, everything is going fine — I've just been updating all the functions so that they're written in the flattened namespace of version 4. For example, instead of d3.geo.path() , it's d3.geoPath() . I've also changed a few small things so that the code works with the latest version of TopoJSON. For example, instead of topojson.object(topology, geom).coordinates , it's topojson.feature(topology, geom).geometry.coordinates .

Shapefile to TopoJSON conversion problems

拜拜、爱过 提交于 2019-12-24 07:18:38
问题 I'm trying to convert a shapefile to GeoJSON and then to TopoJSON as described in Let's Make a Map. Somewhere along the chain, something gets corrupted and my resulting image looks like below: My workflow is as follows: Download shapefile from: http://vcgi.vermont.gov/warehouse/search_tools - I am working with the Master Town Boundary data, specifically, the "Boundary_BNDHASH_region_towns.shp" file. Convert shapefile to GeoJSON ogr2ogr -f GeoJSON vt_towns.json Boundary_BNDHASH_region_towns

How can I merge multiple topojson files into single topojson file

浪尽此生 提交于 2019-12-23 09:10:33
问题 I have US state topojson and Canada state topojson I want to merge them into single file. Can some one tell me how to merge two files into single topojson file. I'm using mercator projection while creating map 回答1: I was facing a similar issue, and ended up converting topojson files to geojson, merging them with geojson-merge, finally converting to topojson. As Canada and the US share some boundaries ( arcs in topojson), it should reduce the total file size. for item in "us" "ca" do topo2geo

d3 world map — calculate geo bounds on zoom

▼魔方 西西 提交于 2019-12-23 02:48:46
问题 I am trying to adapt Mike Bostock's constrained zoom example to fit my needs. (http://bl.ocks.org/mbostock/4987520). Is there any way to calculate the geo bounds (in long/lat) of the projection when the map is zoomed. The d3.geo.bounds() method expects a 'feature' -- I really don't want to zoom on any particular feature. All I want is the geo bounds for the visible area of the projection. Thanks in advance, Kishore 回答1: My other answer was a misreading of the question, but I'll leave it there

D3js-Topojson : how to move from pixelized to Bézier curves?

徘徊边缘 提交于 2019-12-22 10:01:40
问题 D3js topojson visalization by default use quantification and straight lines between points resulting in unelegant lines. See by example the following France Topography map and it's zoomed version. The code I use is : //Append Topo polygons svg.append("path") .datum(topojson.object(json, json.objects.levels) ) .attr("d", path) svg.selectAll(".levels") .data( topojson.object(json, json.objects.levels).geometries) .enter().append("path") .attr("class", function(d) { return "Topo_" + d.properties

Adding external properties to TopoJSON file of counties

人盡茶涼 提交于 2019-12-21 17:35:33
问题 related question I'm trying to add external properties to a topojson file, us-counties.json (made with us-atlas using make topo/us-counties.json ). I'm working off this example. But my resulting topojson file us-counties-with-population.json has no properties at all . My call looks like: topojson --external-properties data.csv \ --id-property id_county \ --properties population=+percent_population \ -o us-counties-with-population.json \ -- us-counties.json and my data looks like ( head -n5

How to convert ocean shape file into topojson

一曲冷凌霜 提交于 2019-12-21 14:58:46
问题 I have gdal 1.10.1 and topojson 1.4.0 installed on my MacOs 10.7.5. I have downloaded the ne_110m_ocean form Natural Earth. I successfully transformed the shape file in GeoJSON: ogr2ogr \ -f GeoJSON \ ocean.json \ ne_110m_ocean.shp Then I transformed the GeoJSON into topojson: topojson \ -o ocean_tj.json \ ocean=ocean.json \ When I plot using the GeoJSON file all works fine. d3.json("ocean.json", function(json) { svg.selectAll("path") .data(json.features) .enter() .append("path") .attr("d",

Double clicking Europe data visualization

老子叫甜甜 提交于 2019-12-21 02:56:17
问题 I would like to create a choropleth map of Europe with the possibility of zooming. I would also like to see that when the user double-clicks on a country, the country in question is zoomed and divided into regions (NUTS 2), each of which is colored according to a second measure. Here an example: Suppose that Europe is composed of 5 countries: Country1, ..., Country5. Each country is colored according to the first measure (suppose the number of inhabitants). When the user double-clicks on