Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topojson for polygons #24

Closed
pere opened this issue Mar 18, 2019 · 4 comments
Closed

Topojson for polygons #24

pere opened this issue Mar 18, 2019 · 4 comments

Comments

@pere
Copy link

pere commented Mar 18, 2019

this plugin is great, i am trying to reuse your examples with some other polygonal topojson, but they appear with completely wrong shapes.

I downloaded several shapefiles and converted to topojson using mapshaper. All of them result in weird geographical shapes. Also the topojson downloaded (http://bl.ocks.org/mapsam/raw/6083585/) from the most basic D3.js example (http://bl.ocks.org/mapsam/raw/6083585/) creates this incorrect geometry... (have to zoom out full map to see it)

I assume the plugin uses 4326 projection? so topojson should be in 4326? I also see that the structure from your topojson is different than the standard one (yours doesn't have transform nor translate properties, and big array of arcs are at the beginning, not at the end of the file...)

Thanks in advance for some information

@manubb
Copy link
Owner

manubb commented Mar 18, 2019

Hi.
It is possible that i'm using topojson a bit weirdly (it's been a while and i do not remember clearly).
However, the demos use Leaflet default projection which expects 4326 coords.
The example you are giving use d3.geo.albersUsa projection so bad results can be expected when using Leaflet default projection.

Can you give me a topojson sample (using 4326 coords) so that i can have a look?

@pere
Copy link
Author

pere commented Mar 18, 2019

thanks for this fast answer

I am not sure the json i sent you is on Albers, I think is transforming to Albers from a spherical (geographical) coordinates, that is 4326... but I have never been good on projections
link

In any case here, on the EU comission official webpage can download different Topojson polygonal layers at different projections, including 4326. I cannot send here any example JSON, please download from the site.

I send also a screenshot of my result with one of these json. Of course I had to change a few things on code to generate it, but with this code and your french topojson it works. So, should work for others topojsons...

topojson_incorrect

I think the plugin has a great potential, dreaming on creating color transitions on polygons on changing various parameters... any help appreciated

I suggest to add as base layer a grey map (see below), because maybe generated (weird) polygons are not very visible.

 var grayLayer =L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', {
  attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> &copy; <a href="https://carto.com/attributions">CARTO</a>',
  subdomains: 'abcd',
  maxZoom: 19
}).addTo(map);

@pere pere closed this as completed Mar 18, 2019
@pere pere reopened this Mar 18, 2019
@manubb
Copy link
Owner

manubb commented Mar 19, 2019

I think you are right for the coordinate system of d3 demo.
I have added a basic demo to display the US states:
https://manubb.github.io/Leaflet.PixiOverlay/simple-topojson.html
The sources are in the doc directory. Hope this will help you.

@pere
Copy link
Author

pere commented Mar 22, 2019

This is great! thanks a lot

@pere pere closed this as completed Mar 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants