2024年6月26日星期三

mikeio encoding error

 ---------------------------------------------------------------------------

UnicodeEncodeError                        Traceback (most recent call last)
Cell In[16], line 2
      1 for f  in file_lst:
----> 2     df = mikeio.read(f).to_dataframe()

File C:\py_venv\py_leafmap\Lib\site-packages\mikeio\__init__.py:133, in read(filename, items, time, keepdims, **kwargs)
    130 if "dfs" not in ext:
    131     raise ValueError("mikeio.read() is only supported for Dfs files")
--> 133 dfs = open(filename)
    135 return dfs.read(items=items, time=time, keepdims=keepdims, **kwargs)

File C:\py_venv\py_leafmap\Lib\site-packages\mikeio\__init__.py:186, in open(filename, **kwargs)
    180     raise Exception(
    181         f"{ext} is not a supported format for mikeio.open. Valid formats are {valid_formats}"
    182     )
    184 reader_klass = READERS[ext]
--> 186 return reader_klass(filename, **kwargs)

File C:\py_venv\py_leafmap\Lib\site-packages\mikeio\dfs\_dfs0.py:101, in Dfs0.__init__(self, filename)
     98 if not path.exists():
     99     raise FileNotFoundError(path)
--> 101 dfs = DfsFileFactory.DfsGenericOpen(str(path))
    102 self._source = dfs
    104 # Read items

File C:\py_venv\py_leafmap\Lib\site-packages\mikecore\DfsFileFactory.py:84, in DfsFileFactory.DfsGenericOpen(filename, parameters)
     81 @staticmethod
     82 def DfsGenericOpen(filename, parameters = None):
     83     dfs = DfsFile();
---> 84     dfs.Open(filename, DfsFileMode.Read, parameters);
     85     return dfs

File C:\py_venv\py_leafmap\Lib\site-packages\mikecore\DfsFile.py:726, in DfsFile.Open(self, filename, mode, parameters)
    724 # Marshal filename string to C char*
    725 fnp = ctypes.c_char_p()
--> 726 fnp.value = filename.encode("cp1252")
    728 if mode is DfsFileMode.Read:
    729     # Open file for reading
    730     rok = DfsDLL.Wrapper.dfsFileRead(
    731         fnp.value, ctypes.byref(self.headPointer), ctypes.byref(self.filePointer)
    732     )

File ~\AppData\Local\Programs\Python\Python312\Lib\encodings\cp1252.py:12, in Codec.encode(self, input, errors)
     11 def encode(self,input,errors='strict'):
---> 12     return codecs.charmap_encode(input,errors,encoding_table)

UnicodeEncodeError: 'charmap' codec can't encode character '\u5e74' in position 10: character maps to <undefined>
encoding with 'cp1252' codec failed

2024年6月22日星期六

chrome socks5 proxy from cmd

 https://www.chromium.org/developers/design-documents/network-stack/socks-proxy/

To configure chrome to proxy traffic through the SOCKS v5 proxy server myproxy:8080, launch chrome with these two command-line flags:


--proxy-server="socks5://myproxy:8080"


--host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE myproxy"


Explanation


The --proxy-server="socks5://myproxy:8080" flag tells Chrome to send all http:// and https:// URL requests through the SOCKS proxy server "myproxy:8080", using version 5 of the SOCKS protocol. The hostname for these URLs will be resolved by the proxy server, and not locally by Chrome.


NOTE: proxying of ftp:// URLs through a SOCKS proxy is not yet implemented.

The --proxy-server flag applies to URL loads only. There are other components of Chrome which may issue DNS resolves directly and hence bypass this proxy server. The most notable such component is the "DNS prefetcher".Hence if DNS prefetching is not disabled in Chrome then you will still see local DNS requests being issued by Chrome despite having specified a SOCKS v5 proxy server.


Disabling DNS prefetching would solve this problem, however it is a fragile solution since once needs to be aware of all the areas in Chrome which issue raw DNS requests. To address this, the next flag, --host-resolver-rules="MAP * ~NOTFOUND , EXCLUDE myproxy", is a catch-all to prevent Chrome from sending any DNS requests over the network. It says that all DNS resolves are to be simply mapped to the (invalid) address 0.0.0.0. The "EXCLUDE" clause make an exception for "myproxy", because otherwise Chrome would be unable to resolve the address of the SOCKS proxy server itself, and all requests would necessarily fail with PROXY_CONNECTION_FAILED.

2024年6月21日星期五

nvidia-smi, not enough memory for the allocation

 [ 1484.096449] __vm_enough_memory: pid: 2966, comm: nvidia-smi, not enough memory for the allocation

[ 1484.096456] __vm_enough_memory: pid: 2966, comm: nvidia-smi, not enough memory for the allocation

[ 1484.096457] __vm_enough_memory: pid: 2966, comm: nvidia-smi, not enough memory for the allocation

[ 1500.015549] __vm_enough_memory: pid: 2967, comm: nvidia-smi, not enough memory for the allocation

[ 1500.015558] __vm_enough_memory: pid: 2967, comm: nvidia-smi, not enough memory for the allocation

[ 1500.015560] __vm_enough_memory: pid: 2967, comm: nvidia-smi, not enough memory for the allocation

[ 1520.960394] __vm_enough_memory: pid: 2970, comm: nvidia-smi, not enough memory for the allocation

[ 1520.960402] __vm_enough_memory: pid: 2970, comm: nvidia-smi, not enough memory for the allocation

[ 1520.960403] __vm_enough_memory: pid: 2970, comm: nvidia-smi, not enough memory for the allocation

[ 1732.930913] __vm_enough_memory: pid: 3027, comm: nvidia-smi, not enough memory for the allocation

[ 1732.930919] __vm_enough_memory: pid: 3027, comm: nvidia-smi, not enough memory for the allocation

[ 1732.930921] __vm_enough_memory: pid: 3027, comm: nvidia-smi, not enough memory for the allocation

2024年6月12日星期三

ogr2ogr 使用sql 从 gpkg 中导出属性表

 ogr2ogr   -f   CSV  aa.csv    mdf.gpkg  -sql "select x, y, '1' as code from table002"

ogr2ogr -f CSV out.csv  -sql "select st_x(pt.geom), st_y(pt.geom), '1' as code from Vertices as pt" in.gpkg

ogr2ogr -f CSV out.csv  -sql "select st_x(pt.geom), st_y(pt.geom), pt.marker as code from Vertices as pt" in.gpkg

输出的csv文件中,最后一列,总是被双引号包起来,怎么去掉呢?

添加选项   -lco STRING_QUOTING=IF_NEEDED

https://gis.stackexchange.com/questions/470855

2024年6月11日星期二

qgis 算法

 QGIS/src/analysis/processing/qgsalgorithmlineintersection.cpp



2024年5月25日星期六

禁用chrome的缓存

 通过wireguard访问webserver,chrome浏览器有的网页能打开,有的打不开,以为网络有问题,反复尝试,都没找到原因。最后发现是wireguard连接不成功,chrome用的竟然是缓存的页面!!!

2024年3月7日星期四

Check Python version

>>> import sys

>>> print(sys.version)

3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]


python3   --version


为什么安装'joinmultiplelines',会调用qgis2web

 Couldn't load plugin 'joinmultiplelines' due to an error when calling its classFactory() method 


TypeError: qRegisterResourceData(int, bytes, bytes, bytes): argument 2 has unexpected type 'str' 

Traceback (most recent call last):

  File "C:\PROGRA~1/QGIS32~1.3/apps/qgis/./python\qgis\utils.py", line 423, in _startPlugin

    plugins[packageName] = package.classFactory(iface)

  File "C:\Users/27096/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\joinmultiplelines\__init__.py", line 3, in classFactory

    from .joinmultiplelines import joinmultiplelines

  File "C:\PROGRA~1/QGIS32~1.3/apps/qgis/./python\qgis\utils.py", line 888, in _import

    mod = _builtin_import(name, globals, locals, fromlist, level)

  File "C:\Users/27096/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\joinmultiplelines\joinmultiplelines.py", line 61, in 

    import resources

  File "C:\PROGRA~1/QGIS32~1.3/apps/qgis/./python\qgis\utils.py", line 888, in _import

    mod = _builtin_import(name, globals, locals, fromlist, level)

  File "C:\Users/27096/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\resources.py", line 1251, in 

    qInitResources()

  File "C:\Users/27096/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis2web\resources.py", line 1242, in qInitResources

    QtCore.qRegisterResourceData(0x01, qt_resource_struct,

TypeError: qRegisterResourceData(int, bytes, bytes, bytes): argument 2 has unexpected type 'str'