I am trying to read shape file from geopandas library using gpd.read_file() DriverError: not recognized as a supported file format. ERROR - geospatial

DriverError: '/vsizip//vsimem/3a044273ad394c659206ed9154647032.zip' not recognized as a supported file format.
I am trying to read shape file link which is on my github using gpd.read_file() but I got this error help me please
DriverError: '/vsizip//vsimem/3a044273ad394c659206ed9154647032.zip' not recognized as a supported file format.
I tried without using zip format as well
url_shp_file = "https://github.com/Ezeysay16/veridosyalari/blob/main/shapefile/countries.shp?raw=true"
countries_gdf = gpd.read_file(url_shp_file)#Geopandas ile verilen shape dosyasını read_file() fonksiyonu ile okuyabiliriz.

Related

Unable to solve multiprocessing.Manager.Lock() error in Python code (VS editor)

I am using machine learning in my Python (version 3.8.5) code. In the preprocessing part, I need to hash encode few features. So earlier I have dumped a hash encoder pickle file using the features in the training phase. Saved the file with the name of 'hash_encoder.pkl'. Now in the testing phase, I need to transform the features using this pickle file. I'm using the following code given in screenshot to hash encode three string features as given in the first line.
In the encoder.transform line, I'm getting the error of "data_lock=mutiprocessing.Manager().Lock()".
At the end I'm also getting 'raise EOF error'.
I have tried using same version of pandas (1.1.3) to dump the hash_encoder file and also to load it. I'm not sure why is this coming up.
Can someone help me in understand or debugging this part?
I have added the screenshot of the error.

torchaudio: Error opening '_sample_data\\steam.mp3': File contains data in an unknown format

I'm new to torch audio and i'm following the this tutorial step by step. I'm having a problem loading an mp3 audio using torchaudio.info(path).
Here is my code:
metadata = torchaudio.info(SAMPLE_MP3_PATH)
print(metadata)
Here is the error that i'm getting:
..
RuntimeError: Error opening '_sample_data\\steam.mp3': File contains data in an unknown format.
torch: v1.9.1+cpu
torchaudio: v0.9.1
torchaudio.info will call its backend to show the information.
If you use it in windows, and the backend is Soundfile, then this problem will occur. Because Soundfile does not support mp3 format.
You can use the below code to see the available formats.
import soundfile as sf
sf.available_formats()

Getting error to read edf file using mne-python

I am trying to visualize the EEG data fie which is in .edf file format.For this purpose I am using MNE python.
here is my code
import mne
file = "/home/test.edf"
data = mne.io.read_raw_edf(file,preload=True)
Whenever I run this code below error massage is showing
ValueError: not enough values to unpack (expected 3, got 0)
I could not figure out where is my wrong.
It's not possible to use use the file by specifying the path, event if you add a "~", the directory won't be identified. Better you try to be in the exact directory and try reading the file, i.e go to your home directory and then try specifying the file.
import mne
file = "test.edf"
data = mne.io.read_raw_edf(file)

Cannot load csv file using numpy loadtxt

I cannot load a csv file using the numpy loadtxt function. There must be something wrong with the file format or something else. I am using anocanda notebook on macbook.
OSError: Macintosh HD⁩\\Users⁩\\binhao⁩\\Downloads⁩\\Iris_data.csv not found.
np.loadtxt("Macintosh HD⁩\\Users⁩\\binhao⁩\\Downloads⁩\\Iris_data.csv")
I tried a solution I found on stackflow involved using:
f = open(u"Macintosh HD⁩\\Users⁩\\binhao⁩\\Downloads⁩\\Iris_data.csv")
f = open("Macintosh HD⁩\\Users⁩\\binhao⁩\\Downloads⁩\\Iris_data.csv")
Above don't work - No such file or directory error
Most of the time is due to some non-escaped charter, try to use raw string:
r"Macintosh HD⁩\\Users⁩\\binhao⁩\\Downloads⁩\\Iris_data.csv"

Read NetCDF file from Azure file storage

I have uploaded a file to my Azure file storage account and created a SAS (shared access signature). Let's pretend the file in question is called fileA.nc
Now, with Python3, I am attempting to read fileA.nc:
from netCDF4 import Dataset
url ='https://<my-azure-resource-group>.file.core.windows.net/<some-file-share>/fileA.nc<SAS-token>';
dataset = Dataset(url)
print(dataset.variables.keys())
The above code does not work, instead giving me the following error:
Traceback (most recent call last): File "yadaYadaYada/test.py", line
8, in
dataset = Dataset(url) File "netCDF4/_netCDF4.pyx", line 1848, in netCDF4._netCDF4.Dataset.init (netCDF4/_netCDF4.c:13983)
OSError: NetCDF: Malformed or unexpected Constraint
This is line 8:
dataset = Dataset(url)
I know the URL provided works. If I paste it into the browser, the file downloads...
I have checked the netCDF4 documentation, which says this:
Remote OPeNDAP-hosted datasets can be accessed for reading over
http
if a URL is provided to the Dataset constructor instead of a filename.
However, this requires that the netCDF library be built with OPenDAP
support, via the --enable-dap configure option (added in version
4.0.1).
However, I have no idea how to tell if when Pycharms installed netcdf4, it used the --enable-dap argument, but I cannot imagine why it would not. Besides, if I stick in a url which points to some HTML, I get the HTML in the error dump and so from that I would think netcdf4 is actually trying to load a remote dataset and so the problem is somewhere else.
I'd really appreciate some help here. Maybe someone knows of another Python 3 netCDF library that will allow me to load my datasets from Azure?
UPDATE
Okay, I can now confirm that the python netcdf4 library does come with --OPenDAP enabled:
Hello again, netCDF4 1.0.4 with OpenDAP support is now available in
the conda respoitory on Unix. To install: $ conda install netcdf4
Ilan
I have found a solution. It turns out that you cannot read directly from an Azure File share, even though when you paste the link to a file in the browser, the file begins to download.
What I needed to do was to mount the File Share on my OS. In my case, I was using Windows but this can be done with Linux, too. The following code should be modified accordingly and then put into Command Prompt:
net use <drive-letter>: \\<storage-account-name>.file.core.windows.net\<share-name>
example :
net use z: \\samples.file.core.windows.net\logs
Once the File Share is mounted, you can read from it as if it were an external HDD. You may need to add permission, but I didn't.
Here is the link to the documentation for mounting the File Share: Documentation

Resources