I am trying to read some .shp file in geopandas using .read_file() function, but I am always get error:
DriverError: Failed to read all values for 158775 records in .shx file: No error.
My code:
import geopandas as gpd
path_shp = "./data/gis_osm_buildings_a_07_1.shp"
data_shx = gpd.read_file(path_shp, driver = "SHP")
Out:
DriverError: Failed to read all values for 158775 records in .shx file: No error.
How can I solve this problem?
Related
import geopandas as gpd
shapefile1 = gpd.read_file(r"C:\shapefile1.shp")
shapefile2 = gpd.read_file(r"C:\shapefile2.shp")
clipped_shapefile = gpd.overlay(shapefile1, shapefile2, how="intersection")
clipped_shapefile.to_file(r"C:\clipped_shapefile.shp")
returns an error message of: OSError: exception: access violation reading 0xFFFFFFFFFFFFFFFF
I was hoping to get an output of a clipped polygon.
I want to read an excel file into pandas from an AWS S3 bucket. Everything worked fine But when I import PandasCursor, which I need for another part of the code, I receive the following error message:
import pandas as pd
import s3fs
from pyathena import connect
from pyathena.pandas.cursor import PandasCursor
path = "s3://some/path/to/file.xlsx"
df = pd.read_excel(path)
>>>TypeError: S3FileSystem.__init__() missing 1 required positional argument: 'connection'
Can anyone explain what is happening and how I can fix it?
From the pyathena docs I don't understand how PandasCursor is influencing pd.read_excel()
I'm trying to read a bson file this is my code:
import bson
with open("D:/rl env/chat_log.bson",'rb') as f:
datas = bson.decode_all(f.read())
note that "D:/rl env/chat_log.bson" is my file path.
i got below error:
AttributeError: module 'bson' has no attribute 'decode_all'
I must mention that I didn't get any error when I ran this code in google colab.
Have you tried to use the loads method
with open("D:/rl env/chat_log.bson",'r') as f:
datas = bson.loads(f.read())
While reading a geojson file using GeoPandas in jupyter notebook, I'm getting following error.
import geopandas as gpd
df = gpd.read_file(filepath)
Error:
CRSError: Invalid projection: epsg:4326: (Internal Proj Error: proj_create: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name)
I also got the warning while importing geopandas:
Warning:
PROJ: proj_create_from_database: SQLite error on SELECT name, type, coordinate_system_auth_name, coordinate_system_code, datum_auth_name, datum_code, area_of_use_auth_name, area_of_use_code, text_definition, deprecated FROM geodetic_crs WHERE auth_name = ? AND code = ?: no such column: area_of_use_auth_name
What does it mean?. I have been using 'geopandas' for a long time. Never saw these error and warning.
I downloaded and have been trying to run the following package: https://pypi.org/project/ecomplexity/#description
Which is also available on github here: https://github.com/cid-harvard/py-ecomplexity
The readme page has an example of how the code is supposed to work, given here:
from ecomplexity import ecomplexity
from ecomplexity import proximity
# Import trade data from CID Atlas
data_url = "https://intl-atlas-downloads.s3.amazonaws.com/country_hsproduct2digit_year.csv.zip"
data = pd.read_csv(data_url, compression="zip", low_memory=False)
data = data[['year','location_code','hs_product_code','export_value']]
# Calculate complexity
trade_cols = {'time':'year', 'loc':'location_code', 'prod':'hs_product_code', 'val':'export_value'}
cdata = ecomplexity(data, trade_cols)
# Calculate proximity matrix
prox_df = proximity(data, trade_cols)
I added import pandas as pd so that the .csv file could be read and added print(prox_df) to provide the results of the second function. I expected the second function to produce a matrix of values in which the elements are the minimum conditional probability of any two products coming from any location.
However, when running this example from the readme page, I am presented with the following error:
Traceback (most recent call last):
File "filepath/project.py", line 16, in <module>
prox_df = proximity(data, trade_cols)
File "filepath\venv\lib\site-packages\ecomplexity\proximity.py", line 79, in proximity
output = output.reset_index()
File "filepath\venv\lib\site-packages\pandas\core\frame.py", line 4849, in reset_index
new_obj.insert(0, name, level_values)
File "filepath\venv\lib\site-packages\pandas\core\frame.py", line 3618, in insert
self._mgr.insert(loc, column, value, allow_duplicates=allow_duplicates)
File "filepath\venv\lib\site-packages\pandas\core\internals\managers.py", line 1147, in insert
raise ValueError(f"cannot insert {item}, already exists")
ValueError: cannot insert prod, already exists
What causes this error? How can I prevent this error from occurring so that I can use the 'proximity' function of this package?
I just tried with pandas 1.1.0 and it failed with same error message. I then downgraded to pandas 0.25.0 and it worked.
You should consider contacting library author to upgrade to work with latest versions of pandas
pip3 install -Iv pandas==0.25.0