26

Glad you asked, oh handsome OP. Install topojson From the command line (Mac OSX 10.8, assumes homebrew installed): brew install node.js npm install -g topojson Convert The Data topojson -o output.json input.json


18

According to Mike Bostock (and other contributors to the TopoJSON extension): TopoJSON is an extension of GeoJSON that encodes topology. Rather than representing geometries discretely, geometries in TopoJSON files are stitched together from shared line segments called arcs. TopoJSON eliminates redundancy, offering much more compact representations of ...


12

Before going down any more laborious paths, the simplest option is to reduce the geometry. What are your source datasets? How did you simplify them? How much did this reduce the geojson file size? If you are confident that you have done all you can on the above, then the lowest hanging fruit of your options is Serve the geojson file gzipped, ...


11

Mapshaper.org is a handy free online tool that allows you to upload a geojson file, display it as a map, then choose one of three simplification alogrithims which you can adjust the strength of with a slider. It updates the map and highlights in red any places where there's a loss of integrity like an overlap between two regions. There's a 'fix' button that ...


11

Ask yourself two questions: Are you going to reuse the geography on multiple datasets? If you’ll use the same geography with multiple datasets, then it makes sense to keep the geography and data separate, and join them in the client. Many of my examples have separate CSV (or TSV) files for this reason. This way, the TopoJSON for U.S. states and counties or ...


9

You can use topojson.merge to do this, as shown in bl.ocks.org/5416405: There are a few limitations to this approach (such as its dependence on an exact topology and lack of detection of holes), but it might for you as-is or with a few adjustments. There is also the simpler approach of drawing the set of polygons for each region twice, once with a stroke ...


7

The issue here is TopoJSON’s default quantization behavior; you need to increase the quantization precision if you want to preserve detail when zoomed in. Try -q 1e5 to increase the quantization factor from the default by 10, or -q 1e6 by 100. The appropriate value of Q depends on the maximum effective size of your map and limited by the original precision ...


7

You have two ways of reducing the file size: Remove all the pretty formatting and redundant white space. In some 'XML-style' files this can be a surprisingly large amount and can easily double or even treble your file size. However I doubt it accounts for the difference in your volume and the data you link to above. Reduce the volume of actual data either ...


6

I wonder if you could make use of the compression found in this answer that talks about compressing the GeoJSON with topojson. I don't know if Leaflet will still be able to read the GeoJSON - something to try =) More about topojson: https://github.com/mbostock/topojson/


6

The problem is that, for the moment, QGIS does not recognize the TopoJSON format (too recent). The solution is to transform the TopoJSON file into GeoJSON format: online GeoJSON - TopoJSON conversion in Python Sean Gillies TopoJSON with Python and Calving Metcalf topojson.py and you can import the GeoJSON file in QGIS


5

You can only use ogr2ogr to reproject your shapefile if ogr2ogr knows the source projection, which is typically defined in "infile.prj" (assuming your shapefile is "infile.shp"). Your GeoJSON file does not include any embedded projection information, so trying to reproject as follows has no effect: ogr2ogr -f 'GeoJSON' -t_srs 'EPSG:4326' hexmap-still-broken....


5

Try this link: https://www.baruch.cuny.edu/confluence/display/geoportal/ESRI+USA+Data There is a link to ZIP3 Shapefiles. As for how to convert to topojson, try Mike Bostock's tools: https://github.com/mbostock/topojson


5

Read the documentation of Leaflet-omnivore here: https://github.com/mapbox/leaflet-omnivore You can pass a custom layer as a third parameter of omnivore.topojson(). By default, it is simply L.geoJson(). In your case, you should use something like this: var customLayer = L.geoJson(null, {style: style}); omnivore.topojson('./data/bmw_parcels_4326.json', null, ...


5

UPDATE: Your problem seems to be with your data. Here is a snippet of your file: }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 585951.8, 181704.9 ], [ 576293.9, 181299.8 ], If I'm not mistaken, those ...


4

In Python "Functions that extract GeoJSON-ish data structures from TopoJSON (https://github.com/mbostock/topojson) topology data. Author: Sean Gillies (https://github.com/sgillies)" Example: from itertools import chain def rel2abs(arc, scale=None, translate=None): """Yields absolute coordinate tuples from a delta-encoded arc. If either ...


4

Your input GeoJSON is invalid. Your feature collection has a doubly-nested features array: { "type": "FeatureCollection", "properties": { "kind": "state", "state": "PR" }, "features": [ [ { "type": "Feature", "properties": { "kind": "county", "name": "Vieques", "state": "PR" }, ...


4

The default projection in D3 is the U.S.-centric d3.geo.albersUsa projection. This is a composite projection design to display the 48 contiguous United States, Hawaii, Alaska and Puerto Rico. If you want to make a map of Canada, you’ll have to specify the appropriate projection rather than relying on the default.


4

TopoJSON uses fixed-precision integer coordinates, so no, you can’t create a TopoJSON file without first quantizing coordinates. The precision is controlled with the -q argument to topojson, as described in the command-line reference. (Edit: as of TopoJSON 1.4, you can now construct lossless TopoJSON without quantization by saying --no-quantization (or ...


4

The function to create a topojson from a geojson in topojson has been moved to geo2topo npm install topojson-server geo2topo input.geojson > output.topojson


4

Fortunately, OGR objects model does allow to have geometries of different types in single layer - a heterogeneous layer. Source: http://www.gdal.org/ogr/drv_geojson.html For instance, if we have three shapefiles of different geometry types (points.shp, lines.shp and polygons.shp) we can define the union layer using the OGR VRT driver specifying its ...


4

A simple bash script should do the trick. For example, you can paste this into your terminal, assuming you’re in the same directory as your shapefiles: for shapefile in *.shp; do topojson -o `basename -s .shp $shapefile`.json -- $shapefile done Alternatively, you can put this code into a script, batch.sh: #!/bin/bash for shapefile in *.shp; do ...


4

There's this Leaflet plugin called omnivore that adds support for multiple formats like csv, kml, gpx, wkt and topojson. Hopefully, that will solve your problem. Good luck :)


4

It's obvious here that you can't expect to get 200 MB from a server to a client in a reasonable amount of time. Your only options are to drastically simplify it (probably will resulting unusable information) or tiling it (either vector or raster tiling should work). What you do depends on what you know and what you want to achieve. Here's what I suggest, ...


4

The combine-files option is only for the input (-i) command which is not available on the browser version. When using mapshaper in the browser you can see all your layers but notice that the "source file" for each one is different. I think that the simplification command can only take in consideration layers in the same file, hence the combine-files option ...


4

That piece of Russia is supposed to be there - the edge of your map in D3 (and many other GIS packages) is 180 degrees West. That edge cuts through Russia (hence why Sarah Palin could see it from her house), so D3 has cleverly chopped the Russian coastline along that edge and drawn it in for you in the right place. The advantage of doing it this way is ...


4

Yes. Vector tiles certainly have the potential to improve the performance of client side data rendering (not to mention the flexibility). Boundless appear working on this exact need. From what I have seen though, the hurdle in the NetCDF > GeoServer > VectorTile approach is GeoServer's limited support for NetCDF, in particular 2D coordinate systems ...


3

Use TOPOJSON, I had a 20 MB file and topojson simplified it down to 300 KB! See here: https://github.com/mbostock/topojson/wiki for instructions and how to install. You want to play with this parameter: --simplify-proportion


3

Good question. One of the examples you provided seems to do the trick, though it is hard to follow. You'll note that the example has two external data files, us.json and unemployment.tsv. You can think of unemployment.tsv as like your danger.csv; us.json are the geographic features with which you want to associate parameters from danger.csv. The latter, ...


3

I agree with @Kelso above on simplifying your geometry. If you don't have access to your server to deflate the data with gzip easily you could take a look at the MessagePack library to serialise your geoJSON into binary data (I believe it's an implementation of the BSON spec that's used by things like MongoDB to store data, but I could be wrong). There are ...


3

The short answer to your question is: topojson \ -o world-110m.json \ -- \ land=ne_110m_land.shp \ states=ne_110m_admin_1_states_provinces.shp This will produce a topology with "land" and "states" objects. You can omit the land= and states= if you'd prefer the objects to have the file names instead. However, a couple gotchas to be aware of:...


Only top voted, non community-wiki answers of a minimum length are eligible