How to check if polygon or point are below Y value?

Viewed 50
  • I have a pandas dataframe which contains column of WKT values.
  • The values can be points or polygons
  • I want to filter all the points and polygons which are below y=32.

for example:

print (df['WKT'].head(3))

mistac gives:

    POINT (-3.8891602, 51.1724553)
    POINT (-1.5820313, 53.7162156)
    POLYGON ((-2.2521973 53.1533591, -2.3181152 52.8492299, -1.5490723 52.7695392 -2.2521973 53.1533591
    ))

I want to filter all values below y=52. In my example we will filter the second row: POINT (-3.8891602, 51.1724553)

How can I do it ?

1 Answers

Since your question is full of typo and I don't really know your expected result, I can't give you a decent answer. But you may try this:

def POINT(a, b):
    return b > 52

def POLYGON(a):
    return 0

s = pd.Series([
    'POINT(-3.8891602, 51.1724553)',
    'POINT(-1.5820313, 53.7162156)'])
>>> s.apply(lambda x: eval(x))
0    False
1     True
dtype: bool
Related