Comments (5)
Thanks for sharing the file. There is nothing wrong with your data. Temporary solution: if you remove the Points from your geojson file it will be parsed correctly.
Bugs that I've to solve:
Multiple things are going wrong here regarding data collections containing Points.
- If there is a data collection that has a combination of Points and Polygons as such:
polygon_point = [
{
"type": "Polygon",
"coordinates": [[[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]]]
},
{
"type": "Point",
"coordinates": [0.5, 0.5]
}
]
Than the Extract
class parses the Point type incorrectly into an arcs
object containing the coordinate.
import topojson as tp
from topojson.core.extract import Extract
Extract(polygon_point)
Extract(
{'bookkeeping_geoms': [[0]],
'linestrings': [<shapely.geometry.linestring.LineString object at 0x0000000008B5B588>],
'objects': {0: {'arcs': [0], 'type': 'Polygon'},
1: {'arcs': [0.5, 0.5], 'type': 'Point'}},
'options': TopoOptions(
{'prequantize': False,
'presimplify': False,
'simplify_algorithm': 'dp',
'simplify_with': 'shapely',
'topology': True,
'topoquantize': False,
'toposimplify': False,
'winding_order': None}
),
'type': 'Topology'}
)
The coordinates of type Point or Multipoint should remain as coordinates
.
Otherwise you will hit indeed the following error:
tp.Topology(polygon_point)
c:\programdata\miniconda3\lib\site-packages\topojson\core\hashmap.py in resolve_bookkeeping(self, geoms)
311 arcs = []
312 for geom in geoms:
--> 313 arcs_in_geom = self.data["bookkeeping_geoms"][geom]
314 for idx_arc, arc_ref in enumerate(arcs_in_geom):
315 arc_ids = self.data["bookkeeping_arcs"][arc_ref]
TypeError: list indices must be integers or slices, not float
- Moreover, if there is a data object containing only a Point as such:
point = [
{
"type": "Point",
"coordinates": [0.5, 0.5]
}
]
tp.Topology(point)
It cannot compute a bounding box since topojson currently only considers parsed linestrings:
c:\programdata\miniconda3\lib\site-packages\topojson\core\join.py in joiner(self, data)
136
137 data["linestrings"], data["transform"] = quantize(
--> 138 data["linestrings"], data["bbox"], quant_factor
139 )
140
c:\programdata\miniconda3\lib\site-packages\topojson\ops.py in quantize(linestrings, bbox, quant_factor)
403 """
404
--> 405 x0, y0, x1, y1 = bbox
406
407 kx = 1 / ((quant_factor - 1) / (x1 - x0))
ValueError: not enough values to unpack (expected 4, got 0)
- This also means there is currently no delta-encoding of Points within topojson.
from topojson.
Thanks for filling this issue. Could you also share the GeoJSON that gives the errors?
Than I can have look
from topojson.
This is an example json feature collection with 4 features which i could not convert to any way to topojson. It is quite a complex polygon so sorry for hard to read file. Couldn't even convert each feature separately in any way.
I would be really grateful if you could show me a way how it could be acomplished, i'm sure it would be really useful for a lot of people in the future with similar problems :)
from topojson.
I see, Thank you very much for your detailed answer!!!
I will find a workaround for Points.
Wish you all the best.
from topojson.
Fixed by #62
from topojson.
Related Issues (20)
- Topology modifies source data
- Topojson bbox should not be transformed when loading Topojson-dict HOT 1
- toposimplify wrongly applied on Topojson data from file
- Reduce decimal places when converting to GeoJSON HOT 2
- Shapely deprecation warnings in topojson 1.3 HOT 5
- Keep geojson properties HOT 6
- Merge multiple layers in a single topojson HOT 5
- Conversion to Typology object causes overlaps HOT 5
- tp.Topology.to_json(pretty=True) doesn't handle None correctly. (Doens't convert None to null) HOT 1
- Converting GeoJSON FeatureCollection to TopoJSON HOT 1
- BUG: `Topology.to_gdf` should keep the original index HOT 2
- holes in multipolygons are lost by simplification HOT 4
- Deprecation warning for shapely 2.0 HOT 3
- Wrong topologies/arcs being created? HOT 7
- Creating a topology for data without junctions and shared_coords=False, prequantize=False gives error
- Bug: polygons that entirely fill islands in another polygon are often not dedupped
- shared_coords=True vs shared_coords=False HOT 5
- Linestrings that follow the same path but where one contains extra redundant points are not deduplicated
- enh: include features that are possible with shapely 2.0
- tests failing, natural earth dataset changed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from topojson.