简体   繁体   English

从具有 (x,y) 特定值的 txt 文件中读取 z 值

[英]reading z value from txt files with specific value of (x,y)

i have txt file with x,y,z coordinates as follows:我有 x,y,z 坐标的 txt 文件,如下所示:

x           y         z        another value
129.000000 -51.000000 3.192000 166 166 166
133.000000 -21.000000 6.982500 171 169 170
134.000000 -51.000000 8.379000 172 170 171
135.000000 -45.000000 8.379000 167 165 166
136.000000 -81.000000 8.578500 160 158 159
137.000000 -51.000000 9.376500 159 157 158
138.000000 -51.000000 9.576000 169 168 167

how to read the value of z when x=20,y=33?当 x=20,y=33 时如何读取 z 的值? I tried using data = numpy.genfromtxt(yourFileName) but it not worked for me我尝试使用data = numpy.genfromtxt(yourFileName)但它对我不起作用

import pandas as pd

from io import StringIO

x = '''x           y         z    v1 v2 v3
129.000000 -51.000000 3.192000 166 166 166
133.000000 -21.000000 6.982500 171 169 170
134.000000 -51.000000 8.379000 172 170 171
135.000000 -45.000000 8.379000 167 165 166
136.000000 -81.000000 8.578500 160 158 159
137.000000 -51.000000 9.376500 159 157 158
138.000000 -51.000000 9.576000 169 168 167'''

out = StringIO(x ) 

df = pd.read_csv( out , delimiter="\s+"  )

print (df.query( "x==138 and y==-51"  ).z.values )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 作法:给定[U,x,y,z]的值(x,y,z)输出U的相关值 - How to: Given a value (x,y,z) from an arry [U,x,y,z] output associated value of U Python combobox 值:如果 x=y 则 x=z - Python combobox value: if x=y then x=z 从数据集中输入 x、y、z 值并将它们分为 2 组(1 或 2) - Inputting x,y,z value from dataset and grouping them into 2 groups (1 or 2) 检查表X的Z列中的值Y - check if value Y in column Z in table X (x,y)对,用于列表中的最大z值 - (x,y) pair for max z value in list Python-如何在表面离散3D点(x,y,z)之后从给定的x,y获取z值 - Python - How to get z value from given x, y after surface discrete 3D points (x,y,z) Python读取X和Y值并分配给Z特定的XY对 - Python reading X and Y values and assigning to Z specific X Y pairs 给定一组在(X,Y,Z)坐标中定义的点,在任意(X,Y)处插值Z值 - Given a set of points defined in (X, Y, Z) coordinates, interpolate Z-value at arbitrary (X, Y) 筛选 pandas dataframe 行,其中具有列 A 和值 X 的特定行具有列 B,其值 Y 大于参数 Z - Filter pandas dataframe rows where a specific row with column A and value X has column B with value Y greater than a parameter Z python shapely:检索LinearRing的x,y,z值 - python shapely: retrieve the x,y,z value of a LinearRing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM