TypeError Reading a GeoJSON file
See original GitHub issuePython version: Python 3.6.3 OS: Mac OSX 10.12.6
I’m wondering if anyone could help me with this error? I’m trying to load a Geojson file into a dataframe with OSM2PGSQL data downloaded from https://mapzen.com/data/metro-extracts/metro/birmingham_england/
When calling gpd.read_file with the points datafile I get the below error. I’m on a new Mac for work so perhaps I havn’t got a dependency installed? Any help would be great.
TypeError Traceback (most recent call last)
<ipython-input-17-e215e87f454f> in <module>()
----> 1 gpd.read_file(points_datafile)
/usr/local/lib/python3.6/site-packages/geopandas/io/file.py in read_file(filename, **kwargs)
24 else:
25 f_filt = f
---> 26 gdf = GeoDataFrame.from_features(f_filt, crs=crs)
27
28 # re-order with column order from metadata, with geometry last
/usr/local/lib/python3.6/site-packages/geopandas/geodataframe.py in from_features(cls, features, crs)
207
208 rows = []
--> 209 for f in features_lst:
210 if hasattr(f, "__geo_interface__"):
211 f = f.__geo_interface__
fiona/ogrext.pyx in fiona.ogrext.Iterator.__next__()
fiona/ogrext.pyx in fiona.ogrext.FeatureBuilder.build()
TypeError: startswith first arg must be bytes or a tuple of bytes, not str```
Issue Analytics
- State:
- Created 6 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
geopandas cannot read a geojson properly
TypeError : unhashable type: 'numpy.ndarray' when I use Series.str.len() in pandas query? Hot Network Questions · What was ...
Read more >Reading geojson into Leaflet results in error?
I'm trying to read a geojson file into leaflet. Everything works out when I copy the text from the geojson file and paste...
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >Cannot read properties of undefined (reading 'json') : r/node
Getting error -> TypeError: Cannot read properties of undefined (reading 'json'). Update: No need to use ".then" since I am using "async ...
Read more >JSON encoder and decoder — Python 3.11.1 documentation
Be cautious when parsing JSON data from untrusted sources. ... Let the base class default method raise the TypeError ... return json.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I did the following and it’s working
I had the same issue an in my case it was an encoding error while reading the GeoJSON. I expected that the encoding of the input GeoJSON was UTF-8, but instead, it was ANSI. After I encoded the GeoJSON to UTF-8, everything worked properly. I noticed the error on the first occurrence of a special case in the properties (e.g. the German Umlaut ä, Ä, ö, Ö, ü, Ü), thus, I thought it could have something to do with the encoding.