XML
在我正在工作的项目中,我需要根据用户输入自动创建文档。使用用户输入修改文档的部分xml
对我来说没问题,但我是xml
在 R 中从头开始创建文档的新手
我想知道是否可以使用或包XML
在 R 中生成如下所示的文档。到目前为止,我已经探索了,和函数,但我不熟悉创建此类文件所需的所有语法(完成后应将其保存在本地路径中)XML
xml2
newXMLdoc
xml_new_document
xml_new_root
xml
<session>
<modelVersion>1.0.0</modelVersion>
<products>
<product>
<refNo>1</refNo>
<uri>S1A_IW_GRDH_1SDV_20190818T175529_20190818T175554_028627_033D25_22ED.zip</uri>
<productReaderPlugin>class org.esa.s1tbx.io.sentinel1.Sentinel1ProductReaderPlugIn</productReaderPlugin>
</product>
<product>
<refNo>2</refNo>
<uri>S2A_MSIL1C_20190823T061631_N0208_R034_T42TXS_20190823T081730.zip</uri>
<productReaderPlugin>class org.esa.s2tbx.dataio.s2.ortho.plugins.Sentinel2L1CProduct_Multi_UTM42N_ReaderPlugIn</productReaderPlugin>
</product>
</products>
<views/>
</session>
Run Code Online (Sandbox Code Playgroud) 我有以下带有日期的数据集(YYYY-MM-DD):
> dates
[1] "20180412" "20180424" "20180506" "20180518" "20180530" "20180611" "20180623" "20180705" "20180717" "20180729"
Run Code Online (Sandbox Code Playgroud)
我想将它们转换为:DD-MMM-YYYY,但月份是文本。例如20180412
应该变成12Apr2018
关于如何进行有什么建议吗?
中号
我有以下 numpy 数组:
supervised.shape
(1270, 1847)
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用以下代码将其保存到 GeoTIFF 中rasterio
:
with rasterio.open('/my/path/ReferenceRaster.tif') as src:
ras_meta = src.profile
with rasterio.open('/my/output/path/output_supervised.tif', 'w', **ras_meta) as dst:
dst.write(supervised)
Run Code Online (Sandbox Code Playgroud)
在哪里ras_meta
:
{'driver': 'GTiff', 'dtype': 'float32', 'nodata': None, 'width': 1847, 'height': 1270, 'count': 1, 'crs': CRS.from_epsg(32736), 'transform': Affine(10.0, 0.0, 653847.1979372115,
0.0, -10.0, 7807064.5603836905), 'tiled': False, 'interleave': 'band'}
Run Code Online (Sandbox Code Playgroud)
我面临以下我无法理解的错误,因为参考栅格和我的supervised
数组都相同shape
ValueError: Source shape (1270, 1847) is inconsistent with given indexes 1
Run Code Online (Sandbox Code Playgroud)
知道这里有什么问题吗?我不完全理解错误的含义。
我正在 Windows 计算机中使用以下命令创建 conda env:
conda create -n s1 python=3.6
conda activate s1
conda config --env --add channels conda-forge
conda config --env --set channel_priority strict
Run Code Online (Sandbox Code Playgroud)
然后,我安装geopandas, rasterio, jupyterlab
软件包:
conda install geopandas
conda install jupyterlab
conda install raserio
Run Code Online (Sandbox Code Playgroud)
如果我从终端打开 python 并加载包:
(s1) C:\>python
Python 3.6.13 (default, Sep 7 2021, 06:39:02) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import geopandas
>>> import rasterio
Run Code Online (Sandbox Code Playgroud)
一切正常。但是,如果我打开jupyter lab
:
(s1) C:\>jupyter lab …
Run Code Online (Sandbox Code Playgroud)