topojson

Pre-projected geometry v getting the browser to do it (aka efficiency v flexibility)

狂风中的少年 提交于 2019-11-26 22:08:31
问题 To improve the performance of my online maps, especially on smartphones, I'm following Mike Bostock's advice to prepare the geodata as much as possible before uploading it to the server (as per his command-line cartography). For example, I'm projecting the TopoJSON data, usually via d3.geoConicEqualArea() , at the command line rather than making the viewer's browser do this grunt work when loading the map. However, I also want to use methods like .scale , .fitSize , .fitExtent and .translate

D3js: Automatic labels placement to avoid overlaps? (force repulsion)

时间秒杀一切 提交于 2019-11-26 21:33:05
How to apply force repulsion on map's labels so they find their right places automatically ? Bostock' "Let's Make a Map" Mike Bostock's Let's Make a Map (screenshot below). By default, labels are put at the point's coordinates and polygons/multipolygons's path.centroid(d) + a simple left or right align, so they frequently enter in conflict. Handmade label placements One improvement I met requires to add an human made IF fixes, and to add as many as needed, such : .attr("dy", function(d){ if(d.properties.name==="Berlin") {return ".9em"} }) The whole become increasingly dirty as the number of

Is it possible to read geoJSON or topoJSON file in R to draw a choropleth map?

半世苍凉 提交于 2019-11-26 16:43:04
问题 topoJSON and geoJSON files are know very common for drawing maps on the internet. Is it possible to import them in R to draw choropleth maps? 回答1: Get the rgdal package installed. Then if: library(rgdal) > "GeoJSON" %in% ogrDrivers()$name [1] TRUE then you can do something like: > map = readOGR("foo.json", "OGRGeoJSON") > plot(map) But you need GeoJSON support in your ogrDrivers list. 来源: https://stackoverflow.com/questions/24183007/is-it-possible-to-read-geojson-or-topojson-file-in-r-to-draw

How to add properties to topojson file?

a 夏天 提交于 2019-11-26 09:33:53
问题 Given a data.tsv file such : id code name 1 AL Alabama 2 AK Alaska 4 AZ Arizona 5 AR Arkansas 6 CA California ... ... ... Given a topojson.json file such : (the structure is correct, the numeral values are random) { \"type\":\"Topology\", \"transform\": { \"scale\": [0.0015484881821515486,0.0010301030103010299], \"translate\":[-5.491666666666662,41.008333333333354] }, \"objects\": { \"states\": { \"type\":\"GeometryCollection\", \"geometries\": [ {\"type\":\"Polygon\",\"arcs\":[[0]],\

Center a map in d3 given a geoJSON object

女生的网名这么多〃 提交于 2019-11-25 21:54:49
问题 Currently in d3 if you have a geoJSON object that you are going to draw you have to scale it and translate it in order to get it to the size that one wants and translate it in order to center it. This is a very tedious task of trial and error, and I was wondering if anyone knew a better way to obtain these values? So for instance if I have this code var path, vis, xy; xy = d3.geo.mercator().scale(8500).translate([0, -1200]); path = d3.geo.path().projection(xy); vis = d3.select(\"#vis\")