QGIS won't import this line of WKT and I don't know why - qgis

I have been trying to import a CSV file and QGIS does not like this one line:
"POLYGON((41.8333 54.5203, 41.5 54.5068, 41.434 54.5, 41.1667 54.3396, 40.8333 54.2923, 40.5 54.2192, 40.1667 54.1807, 40.1498 54.1667, 40.0896 53.8333, 40.1667 53.7839, 40.4581 53.5, 40.5 53.4114, 40.7319 53.1667, 40.8333 52.8913, 40.8784 52.8333, 40.8333 52.7964, 40.5073 52.5, 40.5 52.4934, 40.1667 52.4594, 39.8333 52.3378, 39.5 52.313, 39.2507 52.5, 39.1667 52.5114, 38.8333 52.5337, 38.5 52.5125, 38.1667 52.505, 37.9059 52.5, 37.8333 52.4927, 37.8253 52.5, 37.5488 52.8333, 37.5263 53.1667, 37.5221 53.5, 37.5412 53.8333, 37.8333 54.1476, 37.8491 54.1667, 38.1667 54.4656, 38.4594 54.5, 38.5 54.5338, 38.8333 54.7174, 39.1667 54.794, 39.5 54.8166, 39.5741 54.8333, 39.8333 55.058, 40.1298 55.1667, 40.1667 55.2005, 40.5 55.3991, 40.8333 55.4617, 41.1667 55.4447, 41.5 55.4281, 41.8333 55.4139))",9,p666,0
I have no clue what I am doing wrong (or right with all the other entries)...
Sample of an entry QGIS accepts:
"POLYGON((39.8324 52.8333, 39.8333 52.8343, 40.1667 53.1582, 40.5 53.1582, 40.8308 52.8333, 40.8266 52.5, 40.5 52.181, 40.1667 52.1807, 39.8394 52.5, 39.8333 52.8311, 39.8324 52.8333))",7,P9,200,99.98
QGIS only states the entry is not a valid WKT with no further explanation or estimate on where the error is. I have tried the WKT in online services and they do not seem to complain about it...
I tried using the following sites to see if there is anything wrong with my WKT but they all run the WKT just fine:
http://dev.openlayers.org/examples/vector-formats.html
http://arthur-e.github.io/Wicket/sandbox-gmaps3.html
https://clydedacruz.github.io/openstreetmap-wkt-playground/
If anybody has a clue on where is my mistake, I would appreciate.
PS: for the record, I have already spent 2 days trying to figure this out, so fresh eyes are welcome.

The polygon was not closed (meaning the first point should have been repeated as the last point).
A polygon of points a b and c needs to be ((a, b, c, a)) where a is lon lat in point a, and so on.
Example:
POLYGON((0 3, 10 24, -5 -60, 0 3))
It ends and starts with the same point (in the example [0 3]).
The websites I have been testing the wkt were correcting it on my behalf (adding the last point).

Related

Open Street Map using OSMNX: how to retrieve the Hannover subway network?

import osmnx as ox
ox.__version__ # '0.13.0'
I would like to show the subway in Hannover as known in the German subway OSM data on a map using the great OSMNX module. But unlike the New York example no results are returned for:
G = ox.graph_from_place('Hannover, Germany',
retain_all=False, truncate_by_edge=True, simplify=True,
network_type='none', custom_filter='["railway"~"subway"]')
# EmptyOverpassResponse: There are no data elements in the response JSON
I do get results for other similar queries using 'Hannover, Germany' as region. I also do not get subway results for Paris or London. And I do not get results for similar queries like custom_filter='["railway"~"tram"]' or '["railway"~"s-bahn"]' or '["network"~"metro"]'.
Also, if I use the infrastructure keyword argument to select "railway", an extensive gdf is returned:
G = ox.graph_from_place('Hannover, Germany', retain_all=False, truncate_by_edge=True, simplify=True,
network_type='none', infrastructure='way["railway"]')
gdfox = ox.graph_to_gdfs(G, nodes=False, edges=True, node_geometry=True, fill_edge_geometry=True)
gdfox.shape # (4422, 14)
But I cannot identify the subway using the columns returned?:
['u', 'v', 'key', 'osmid', 'service', 'oneway', 'length',
'geometry', 'name', 'maxspeed', 'ref', 'bridge', 'tunnel',
'access']
What I also find strange is that there are only 2 LINESTRINGS returned if I (try to) retrieve all railways using the custom_filter:
G = ox.graph_from_place('Hannover, Germany', retain_all=False, truncate_by_edge=True,
simplify=True, network_type=None, custom_filter='["railway"~""]')
gdfox = ox.graph_to_gdfs(G, nodes=False, edges=True, node_geometry=True, fill_edge_geometry=True)
gdfox.shape # (2, 10) # returns only 2 LINESTRINGS: Altenbekener Damm
I am in the process of removing the infrastructure parameter in favor of a more consistent custom_filter parameter. Will be done in a couple days: https://github.com/gboeing/osmnx/pull/477 (EDIT: done and released in v0.14.0; code snippet below edited accordingly.)
In the meantime, I am not familiar with Hannover but it appears that its passenger rail system is tagged as "tram" and "rail" rather than "subway". Something like this seems to capture it:
import osmnx as ox
ox.config(use_cache=False,
log_console=True,
useful_tags_way=ox.settings.useful_tags_way + ['railway'])
G = ox.graph_from_place('Hannover, Germany',
retain_all=False, truncate_by_edge=True, simplify=True,
custom_filter='["railway"~"tram|rail"]')
len(G) #1776

Get matrix from one text file

i need get matrix from attached text.
this file:
stk.v.11.0
WrittenBy STK_v11.2.0
BEGIN Attitude
NumberOfAttitudePoints 1441
BlockingFactor 20
InterpolationOrder 1
CentralBody Earth
ScenarioEpoch 1 Sep 2019 07:30:00.000000
Epoch in JDate format: 2458727.81250000000000
Epoch in YYDDD format: 19244.31250000000000
Time of first point: 1 Sep 2019 07:30:00.000000000 UTCG = 2458727.81250000000000 JDate = 19244.31250000000000 YYDDD
CoordinateAxes Fixed
AttitudeTimeQuaternions
0.00000000000000e+00 -6.31921733422396e-01 -3.17293118154861e-01 -3.46458799928973e-01 6.16414065342263e-01
6.00000000000000e+01 -6.43812442721383e-01 -3.36172942616126e-01 -3.26612615262581e-01 6.04828480481266e-01
1.20000000000000e+02 -6.55079207620880e-01 -3.54631351046725e-01 -3.06354155948717e-01 5.92667670562959e-01
1.80000000000000e+02 -6.65707851270427e-01 -3.72650894083426e-01 -2.85703135087044e-01 5.79946623834615e-01
i need seprate this 4 row of matrix and asset it to one matrix variable...
in fact i have bigger matrix than that (that near 1400 rows) i must extract from text file and store it in one variable of matrix...
Use readmatrix and specify the number of lines to skip to get to the matrix data. If the number is fixed at 25 as in your example, then:
>> a = readmatrix('textfile.txt','NumHeaderLines',25)
a =
0 -0.6319 -0.3173 -0.3465 0.6164
60.0000 -0.6438 -0.3362 -0.3266 0.6048
120.0000 -0.6551 -0.3546 -0.3064 0.5927
180.0000 -0.6657 -0.3727 -0.2857 0.5799

how to use if in matlab for 2 matrix condition? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
i have 2 reflection coefficient equations R1 and R2 from K with condition absolute must below 1, i use if command for this situation .But when i plot the graph the absolute reflection coefficient still above 1. (K is matrix with 1 column and 201 row)
R1=K+sqrt(K.^2-1);
R2=K-sqrt(K.^2-1);
if abs(R1)<1
r=R1;
else
r=R2;
end
this is the K in excel
real imaginer
-0.7536 0.0512
-0.802 0.0426
-0.8496 0.0408
-0.8872 0.0327
-0.927 0.0338
-0.9575 0.0242
-0.979 0.0174
-0.9977 0.0113
-10,031 0.0029
-10,012 -0.007
-0.9876 -0.0167
-0.9654 -0.0249
-0.9299 -0.0401
-0.8797 -0.0488
-0.8176 -0.0623
-0.7297 -0.0782
-0.6458 -0.0865
-0.5351 -0.1051
-0.4098 -0.1197
-0.2701 -0.1349
-0.1177 -0.1489
0.0536 -0.1699
0.213 -0.1853
0.3933 -0.1921
0.5519 -0.1857
0.7128 -0.1896
0.8511 -0.1712
0.9468 -0.1452
10,222 -0.0943
10,375 -0.04
10,134 0.0365
0.9361 0.1255
0.8122 0.2168
0.6622 0.3108
0.4657 0.3774
0.2577 0.4497
0.0431 0.4775
-0.1463 0.5093
-0.3442 0.4999
-0.5203 0.4782
-0.6692 0.4417
-0.7781 0.3822
-0.8856 0.3293
-0.9703 0.2615
-10,187 0.193
-10,524 0.1254
-10,614 0.0557
-10,539 -0.0016
-10,297 -0.0698
-0.9879 -0.1212
-0.9355 -0.1829
-0.8721 -0.2298
-0.8011 -0.2783
-0.7232 -0.325
-0.6401 -0.3586
-0.5455 -0.4008
-0.4429 -0.43
-0.3524 -0.4433
-0.2455 -0.4769
-0.1336 -0.4863
-0.0391 -0.5073
0.0779 -0.5105
0.1776 -0.5196
0.2869 -0.5152
0.3893 -0.5084
0.4831 -0.4978
0.5888 -0.4907
0.6822 -0.4574
0.7614 -0.4381
0.8484 -0.4017
0.9098 -0.3585
0.9771 -0.3172
10,268 -0.2607
10,667 -0.2102
10,969 -0.1464
11,115 -0.0724
11,141 -0.0019
10,981 0.0838
10,645 0.1546
10,135 0.2457
0.9409 0.3332
0.8657 0.4061
0.7519 0.4973
0.6426 0.5635
0.5072 0.6302
0.3633 0.6782
0.2148 0.7161
0.0382 0.7573
-0.1051 0.7395
-0.273 0.7359
-0.4273 0.7154
-0.5653 0.6794
-0.6971 0.6279
-0.8202 0.555
-0.905 0.493
-0.9996 0.4155
-10,716 0.3239
-11,006 0.2549
-11,444 0.1479
-11,464 0.0722
-11,493 -0.0031
-11,282 -0.0814
-11,040 -0.1603
-10,645 -0.2219
-10,187 -0.2787
-0.9514 -0.3223
-0.8878 -0.3841
-0.8225 -0.42
-0.7415 -0.4606
-0.6607 -0.4889
-0.5577 -0.5319
-0.482 -0.5512
-0.3775 -0.5614
-0.2918 -0.5798
-0.1621 -0.5712
-0.0979 -0.5917
0.0149 -0.5559
0.1062 -0.5734
0.2142 -0.5648
0.3159 -0.5363
0.3844 -0.5302
0.5019 -0.5066
0.5805 -0.4709
0.6626 -0.4506
0.7482 -0.4117
0.8005 -0.363
0.8799 -0.3378
0.9349 -0.2889
0.9883 -0.2449
10,306 -0.1946
10,643 -0.1373
10,870 -0.1025
10,935 -0.0389
10,840 0.0184
10,732 0.0639
10,333 0.1274
0.9906 0.1739
0.9243 0.2293
0.8455 0.2752
0.7527 0.3035
0.6292 0.3394
0.5384 0.3524
0.3808 0.3845
0.2509 0.4067
0.0931 0.4004
-0.0423 0.3839
-0.2123 0.377
-0.3666 0.3537
-0.4838 0.3309
-0.6157 0.288
-0.7211 0.2604
-0.8322 0.2172
-0.8947 0.1791
-0.9618 0.1366
-10,024 0.0932
-10,299 0.0493
-10,415 0.0099
-10,333 -0.0243
-10,092 -0.0612
-0.9798 -0.0906
-0.9321 -0.1302
-0.8796 -0.1472
-0.8121 -0.17
-0.7414 -0.1886
-0.6649 -0.2019
-0.5907 -0.2149
-0.4793 -0.2271
-0.4011 -0.2224
-0.3121 -0.2408
-0.1948 -0.2343
-0.0997 -0.2322
0.008 -0.2328
0.1304 -0.2224
0.2662 -0.2213
0.4093 -0.2298
0.553 -0.2406
0.7094 -0.3018
0.8613 -0.383
0.9745 -0.5634
0.9796 -0.8226
0.7781 -0.9412
0.6424 -0.8495
0.6264 -0.8147
0.6071 -0.6706
0.6682 -0.6029
0.6759 -0.5596
0.71 -0.5218
0.7479 -0.4825
0.7691 -0.4476
0.8264 -0.4056
0.8412 -0.3912
0.8511 -0.3813
0.8689 -0.3425
0.899 -0.3375
0.8827 -0.3198
0.9024 -0.3164
0.929 -0.2876
0.9106 -0.2855
0.9695 -0.2079
10,342 -0.5353
0.8692 -0.5046
I am not 100% sure exactly what you are asking, but I believe the problem you are experiencing is that r is above 1?
K is an imaginary number, where the first column is the real part and the second column is the imaginary part, do I have that correctly? So the first K value is -0.7536+0.0512i, right?
Ok, so did you perhaps intend to cycle through each position of the R1 matrix and see if each one was less than 1. Because right now what you are doing is saying if any values in the entire R1 vector are less than 1, then r equals to the entire R2 vector.
If you want to go through each position in the vector, you should do this:
R1=K+sqrt(K.^2-1);
R2=K-sqrt(K.^2-1);
l=length(R1);
for p=1:l
if abs(R1(p))<1
r(p)=R1(p);
else
r(p)=R2(p);
end
end

How to extract data set from a text file?

Am quite new in the Unix field and I am currently trying to extract data set from a text file. I tried with sed, grep, awk but it seems to only work with extracting lines, but I want to extract an entire dataset... Here is an example of file from which I'd like to extract the 2 data sets (figures after the lines "R.Time Intensity")
[Header]
Application Name LabSolutions
Version 5.87
Data File Name C:\LabSolutions\Data\Antoine\170921_AC_FluoSpectra\069_WT3a derivatized lignin LiCl 430_GPC_FOREVER_430_049.lcd
Output Date 2017-10-12
Output Time 12:07:32
[Configuration]
Instrument Name BOTAN127-Instrument1
Instrument # 1
Line # 1
# of Detectors 3
Detector ID Detector A Detector B PDA
Detector Name Detector A Detector B PDA
# of Channels 1 1 2
[LC Chromatogram(Detector A-Ch1)]
Interval(msec) 500
# of Points 9603
Start Time(min) 0,000
End Time(min) 80,017
Intensity Units mV
Intensity Multiplier 0,001
Ex. Wavelength(nm) 405
Em. Wavelength(nm) 430
R.Time (min) Intensity
0,00000 -709779
0,00833 -709779
0,01667 17
0,02500 3
0,03333 7
0,04167 19
0,05000 9
0,05833 5
0,06667 2
0,07500 24
0,08333 48
[LC Chromatogram(Detector B-Ch1)]
Interval(msec) 500
# of Points 9603
Start Time(min) 0,000
End Time(min) 80,017
Intensity Units mV
Intensity Multiplier 0,001
R.Time (min) Intensity
0,00000 149
0,00833 149
0,01667 -1
I would greatly appreciate any idea. Thanks in advance.
Antoine
awk '/^[^0-9]/&&d{d=0} /R.Time/{d=1}d' file
Brief explanation,
Set d as a flag to determine print line or not
/^[^0-9]/&&d{d=0}: if regex ^[^0-9] matched && d==1, disabled d
/R.Time/{d=1}: if string "R.Time" searched, enabled d
awk '/R.Time/,/LC/' file|grep -v -E "R.Time|LC"
grep part will remove the R.Time and LC lines that come as a part of the output from awk
I think it's a job for sed.
sed '/R.Time/!d;:A;N;/\n$/!bA' infile

Matlab: parsing large segmented data with empty strings

I have a complex data text file to parse, my first problem is some of the strings values are missing (such as row 5 column 4 shown in Data below, I tried using treatAsEmpty with 8 blank spaces but it didn't work it keeps moving the B from the 5th row over and not registering the rest of the row [To be honest I don't need that column, if you can show me how to ignore it that would solve this problem]).
textscan(fileName .'%4d %4d %4d %8s \t %1s %2d \b %2s %7s %5d %*[^\n]','delimiter','\r','treatAsEmpty',' ','EmptyValue',-Inf);
Data:
0439 0444 0441 S09E44SF A 13 ES 3.7E-04 10230
0727 0736 0732 S27W23SF A 29 ES 1.2E-03 10226
0937 0945 0942 S29W16SF A 23 ES 8.8E-04 10226
2000 2016 2008 S28W27SF C 23 ES 1.8E-03 10226
2134 2217 2153 B 27 ES 4.8E-02 10229
0032 0042 0037 S25W27SF C 45 ES 2.1E-03 10226
0142 0147 0145 S09E35SF C 14 ES 4.1E-04 10230
0536 0555 0541 S09E33SF C 16 ES 1.6E-03 10230
0214 0312 0252 N23W422F A 11 ES 2.3E-02 10223
My second problem is, the blank space that is row 6 and row 10. I need to get rows 1-5 in cells (1x9), rows 7-9 in cells (2x9), row 11 in cells (3x9), etc.