topojson-simplify | simplify geometries while preserving topology
kandi X-RAY | topojson-simplify Summary
kandi X-RAY | topojson-simplify Summary
Topology-preserving simplification and filtering for TopoJSON. Smaller files, faster rendering!.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of topojson-simplify
topojson-simplify Key Features
topojson-simplify Examples and Code Snippets
Community Discussions
Trending Discussions on topojson-simplify
QUESTION
I've got the lovely topojson library working for me in a Rails app locally:
https://github.com/topojson/topojson
and it's allowing us to show some nice geoJSON in a google map like so:
I show it with the map.js file exposed, since that seems to be where the trouble is when we deploy to heroku. On heroku the map.js file gives an error on chrome:
maps-....js:27 Uncaught SyntaxError: Unexpected token export
and a similar error (although on a different line) on firefox:
SyntaxError: export declarations may only appear at top level of a module maps-...js:1
I've been in touch with heroku support who suggested locking down our npm version, as it seems like the minified js file is ending up with slightly different content locally than on heroku. I note that I've done everything I can to replicate production mode locally, clobbering and recompiling the static assets etc. and running like so:
...ANSWER
Answered 2019-Jun-04 at 09:43Heroku support are saying that the problem here is using npm with the asset pipeline and the better approach would be to use webpacker
QUESTION
I'm building a map that displays a map of the US. On this map I am plotting heat circles that correspond to a Nielsen DMA topography.
The first topojson that I'm using, is this Nielsen DMA topojson (from simzhou's repo here) to visually plot these heat circles across the US map.
Below you can see the map, with the DMA heat circles, and also the DMA border lines built completely from the Nielsen DMA topojson.
Problem:The issue I'm having is trying to draw state border lines, instead of these DMA border lines. I've brought in the "https://unpkg.com/us-atlas@1/us/10m.json" that @mbostock has provided for us. When drawing the state borders via topojson.feature(us, us.objects.states).features
(i've tried topojson.mesh
too), that's when things go awry. I am 99% sure that this is because the two json files are using different transform
values, and therefore the positions/coordinates are transformed on different scales.
Here are the two jsons: Nielsen DMA here and the US here
You can see how the transform object differs below:
Transform object from US Atlas
...ANSWER
Answered 2018-Jun-11 at 23:20When I first read this I attempted to address the underlying problem in the comments (for which I missed the mark a bit, as I assumed the code to display the map looked a little different than it likely was - I apologize for the misread). However, on second examination, I realized that while the question is an x,y problem, the attempted solution leads to some interesting questions about D3 and topojson that aren't immediately clear - but the underlying issue remains mixing projected and unprojected data, so I'll attempt to address both the x and the y here:
Topojson
Topojson essentially is a method of storing geojson features or feature classes by encoding topology and, optionally, quantized delta encoded integer coordinates. Topojson itself doesn't change the underlying coordinates, it changes their representation.
In order to use topojson with D3, we need to convert it back to geojson, as D3 geoPaths only accept geojson - topojson.feature() returns geojson.
The Underlying Source of Pain
The ultimate issue doesn't arise from the topojson at all. You have two topojon sources that use different coordinate systems:
the US json uses two dimensional Cartesian coordinate space (features projected with an Albers projection). The uncompressed coordinates are SVG pixels.
the Nielsen json uses latitude/longitude coordinate space (points on a 3d globe). The uncompressed coordinates are not Cartesian (unless applying a straight Plate Carree projection: long = x, lat = y).
When the US json is passed through topojson.feature()
, the returned geojson will have x,y values within a bounding box of roughly [0,0],[960,600] (in this case). When any unprojected topojson (Nielsen json for exmaple) is passed through topojson.feature()
, the returned geojson will have long,lat values within a bounding box of [-180,90],[180,-90] - that is it will have valid long/lat pairs.
These underlying and differing coordinate systems are the issue, not the representation of the coordinates in the topojson.
Combining Topojson
I'm not sure on the details of how you combined the two. A topojson splits geojson into constituent parts - arcs and features (which reference the arcs and hold the feature properties). The arcs are referenced numerically - if you didn't modify the indexes, then you can't just use:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install topojson-simplify
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page