Sort real numbers with sort in unix - sorting

I have txt file with this format
str str real real real
and i want to sort it based on the last column. I typed:
sort -s -g -k 5
but the file is not sorted with the 5th column. I.e the first lines after sorting look like:
[ 40.7243 -74.002 ] [ 40.6456 -73.7764] 20.9447883036 20.962214249 0.017425945409
[ 40.7566 -73.846 ] [ 40.7213 -73.9889] 12.6667858845 12.6773281976 0.0105423130825
[ 39.9815 -74.129 ] [ 44.2278 -76.48 ] 510.533346696 510.821713287 0.288366590938
[ 44.2278 -76.48 ] [ 40.6823 -73.9963] 443.855375141 444.135078426 0.279703285008
[ 39.7813 -75.121 ] [ 40.9335 -73.9 ] 164.718235848 164.850765753 0.132529904956
[ 40.9335 -73.9 ] [ 40.7459 -74.2606] 36.8255062031 36.8561101253 0.0306039222244
[ 39.9553 -75.156 ] [ 41.8296 -72.4828] 306.529624263 306.755220276 0.225596012547
[ 39.3533 -74.445 ] [ 40.7896 -74.466 ] 159.764267824 159.893075536 0.128807712368
[ 40.7896 -74.466 ] [ 40.6897 -74.1794] 26.5863055084 26.6084178441 0.022112335672
[ 40.7734 -73.871 ] [ 40.6726 -74.0066] 16.0110921238 16.0244162595 0.0133241356634
[ 40.7734 -73.871 ] [ 40.7404 -73.9843] 10.2271443583 10.235656793 0.00851243471041
[ 40.3169 -75.131 ] [ 43.1779 -73.0528] 361.914932074 362.167532812 0.252600737907
[ 40.7518 -73.977 ] [ 40.7029 -73.9905] 5.55672319197 5.56134868107 0.00462548910303
[ 40.7439 -73.984 ] [ 40.7259 -73.9948] 2.19927425701 2.20110502049 0.00183076347611
[ 40.7452 -73.977 ] [ 43.042 -76.1361] 311.772529032 312.000945947 0.228416914742
[ 40.7221 -73.95 ] [ 39.8748 -74.9226] 125.253302286 125.355551049 0.102248762774
[ 60.1695 24.95 ] [ 40.6807 -73.9778] 6622.44823647 6333.7345939 288.713642571
[ 39.9414 -75.026 ] [ 40.7405 -74.0059] 124.009549001 124.11082192 0.10127291917
[ 37.5233 -122.254 ] [ 40.7488 -74.0235] 4124.03412435 4055.82258363 68.2115407237
[ 39.8492 -74.973 ] [ 40.6897 -74.1794] 115.218817935 115.313160665 0.0943427295254

What if you print the last column, sort the output and finally remove that column?
awk '{print $NF, $0}' file | sort -s -g | cut -d' ' -f2-
By pieces:
Print the last column in the beginning of the line:
$ awk '{print $NF, $0}' file
0.017425945409 [ 40.7243 -74.002 ] [ 40.6456 -73.7764] 20.9447883036 20.962214249 0.017425945409
0.0105423130825 [ 40.7566 -73.846 ] [ 40.7213 -73.9889] 12.6667858845 12.6773281976 0.0105423130825
0.288366590938 [ 39.9815 -74.129 ] [ 44.2278 -76.48 ] 510.533346696 510.821713287 0.288366590938
0.279703285008 [ 44.2278 -76.48 ] [ 40.6823 -73.9963] 443.855375141 444.135078426 0.279703285008
0.132529904956 [ 39.7813 -75.121 ] [ 40.9335 -73.9 ] 164.718235848 164.850765753 0.132529904956
0.0306039222244 [ 40.9335 -73.9 ] [ 40.7459 -74.2606] 36.8255062031 36.8561101253 0.0306039222244
0.225596012547 [ 39.9553 -75.156 ] [ 41.8296 -72.4828] 306.529624263 306.755220276 0.225596012547
0.128807712368 [ 39.3533 -74.445 ] [ 40.7896 -74.466 ] 159.764267824 159.893075536 0.128807712368
0.022112335672 [ 40.7896 -74.466 ] [ 40.6897 -74.1794] 26.5863055084 26.6084178441 0.022112335672
0.0133241356634 [ 40.7734 -73.871 ] [ 40.6726 -74.0066] 16.0110921238 16.0244162595 0.0133241356634
0.00851243471041 [ 40.7734 -73.871 ] [ 40.7404 -73.9843] 10.2271443583 10.235656793 0.00851243471041
0.252600737907 [ 40.3169 -75.131 ] [ 43.1779 -73.0528] 361.914932074 362.167532812 0.252600737907
0.00462548910303 [ 40.7518 -73.977 ] [ 40.7029 -73.9905] 5.55672319197 5.56134868107 0.00462548910303
0.00183076347611 [ 40.7439 -73.984 ] [ 40.7259 -73.9948] 2.19927425701 2.20110502049 0.00183076347611
0.228416914742 [ 40.7452 -73.977 ] [ 43.042 -76.1361] 311.772529032 312.000945947 0.228416914742
0.102248762774 [ 40.7221 -73.95 ] [ 39.8748 -74.9226] 125.253302286 125.355551049 0.102248762774
288.713642571 [ 60.1695 24.95 ] [ 40.6807 -73.9778] 6622.44823647 6333.7345939 288.713642571
0.10127291917 [ 39.9414 -75.026 ] [ 40.7405 -74.0059] 124.009549001 124.11082192 0.10127291917
68.2115407237 [ 37.5233 -122.254 ] [ 40.7488 -74.0235] 4124.03412435 4055.82258363 68.2115407237
0.0943427295254 [ 39.8492 -74.973 ] [ 40.6897 -74.1794] 115.218817935 115.313160665 0.0943427295254
Sort with your current options:
$ awk '{print $NF, $0}' a | sort -s -g
0.00183076347611 [ 40.7439 -73.984 ] [ 40.7259 -73.9948] 2.19927425701 2.20110502049 0.00183076347611
0.00462548910303 [ 40.7518 -73.977 ] [ 40.7029 -73.9905] 5.55672319197 5.56134868107 0.00462548910303
0.00851243471041 [ 40.7734 -73.871 ] [ 40.7404 -73.9843] 10.2271443583 10.235656793 0.00851243471041
0.0105423130825 [ 40.7566 -73.846 ] [ 40.7213 -73.9889] 12.6667858845 12.6773281976 0.0105423130825
0.0133241356634 [ 40.7734 -73.871 ] [ 40.6726 -74.0066] 16.0110921238 16.0244162595 0.0133241356634
0.017425945409 [ 40.7243 -74.002 ] [ 40.6456 -73.7764] 20.9447883036 20.962214249 0.017425945409
0.022112335672 [ 40.7896 -74.466 ] [ 40.6897 -74.1794] 26.5863055084 26.6084178441 0.022112335672
0.0306039222244 [ 40.9335 -73.9 ] [ 40.7459 -74.2606] 36.8255062031 36.8561101253 0.0306039222244
0.0943427295254 [ 39.8492 -74.973 ] [ 40.6897 -74.1794] 115.218817935 115.313160665 0.0943427295254
0.10127291917 [ 39.9414 -75.026 ] [ 40.7405 -74.0059] 124.009549001 124.11082192 0.10127291917
0.102248762774 [ 40.7221 -73.95 ] [ 39.8748 -74.9226] 125.253302286 125.355551049 0.102248762774
0.128807712368 [ 39.3533 -74.445 ] [ 40.7896 -74.466 ] 159.764267824 159.893075536 0.128807712368
0.132529904956 [ 39.7813 -75.121 ] [ 40.9335 -73.9 ] 164.718235848 164.850765753 0.132529904956
0.225596012547 [ 39.9553 -75.156 ] [ 41.8296 -72.4828] 306.529624263 306.755220276 0.225596012547
0.228416914742 [ 40.7452 -73.977 ] [ 43.042 -76.1361] 311.772529032 312.000945947 0.228416914742
0.252600737907 [ 40.3169 -75.131 ] [ 43.1779 -73.0528] 361.914932074 362.167532812 0.252600737907
0.279703285008 [ 44.2278 -76.48 ] [ 40.6823 -73.9963] 443.855375141 444.135078426 0.279703285008
0.288366590938 [ 39.9815 -74.129 ] [ 44.2278 -76.48 ] 510.533346696 510.821713287 0.288366590938
68.2115407237 [ 37.5233 -122.254 ] [ 40.7488 -74.0235] 4124.03412435 4055.82258363 68.2115407237
288.713642571 [ 60.1695 24.95 ] [ 40.6807 -73.9778] 6622.44823647 6333.7345939 288.713642571
Remove the column:
$ awk '{print $NF, $0}' file | sort -s -g | cut -d' ' -f2-
[ 40.7439 -73.984 ] [ 40.7259 -73.9948] 2.19927425701 2.20110502049 0.00183076347611
[ 40.7518 -73.977 ] [ 40.7029 -73.9905] 5.55672319197 5.56134868107 0.00462548910303
[ 40.7734 -73.871 ] [ 40.7404 -73.9843] 10.2271443583 10.235656793 0.00851243471041
[ 40.7566 -73.846 ] [ 40.7213 -73.9889] 12.6667858845 12.6773281976 0.0105423130825
[ 40.7734 -73.871 ] [ 40.6726 -74.0066] 16.0110921238 16.0244162595 0.0133241356634
[ 40.7243 -74.002 ] [ 40.6456 -73.7764] 20.9447883036 20.962214249 0.017425945409
[ 40.7896 -74.466 ] [ 40.6897 -74.1794] 26.5863055084 26.6084178441 0.022112335672
[ 40.9335 -73.9 ] [ 40.7459 -74.2606] 36.8255062031 36.8561101253 0.0306039222244
[ 39.8492 -74.973 ] [ 40.6897 -74.1794] 115.218817935 115.313160665 0.0943427295254
[ 39.9414 -75.026 ] [ 40.7405 -74.0059] 124.009549001 124.11082192 0.10127291917
[ 40.7221 -73.95 ] [ 39.8748 -74.9226] 125.253302286 125.355551049 0.102248762774
[ 39.3533 -74.445 ] [ 40.7896 -74.466 ] 159.764267824 159.893075536 0.128807712368
[ 39.7813 -75.121 ] [ 40.9335 -73.9 ] 164.718235848 164.850765753 0.132529904956
[ 39.9553 -75.156 ] [ 41.8296 -72.4828] 306.529624263 306.755220276 0.225596012547
[ 40.7452 -73.977 ] [ 43.042 -76.1361] 311.772529032 312.000945947 0.228416914742
[ 40.3169 -75.131 ] [ 43.1779 -73.0528] 361.914932074 362.167532812 0.252600737907
[ 44.2278 -76.48 ] [ 40.6823 -73.9963] 443.855375141 444.135078426 0.279703285008
[ 39.9815 -74.129 ] [ 44.2278 -76.48 ] 510.533346696 510.821713287 0.288366590938
[ 37.5233 -122.254 ] [ 40.7488 -74.0235] 4124.03412435 4055.82258363 68.2115407237
[ 60.1695 24.95 ] [ 40.6807 -73.9778] 6622.44823647 6333.7345939 288.713642571

Related

Why is this geojson not rendering with D3?

I am trying to create a visualization from US county related data. When I use the json data set in online validators and tools the counties render fine. But when I try to render a basic map the screen comes up blank. The svg paths are appended to the svg and their d attribute value looks appropriate to me, here is an example path (corresponding to the first object in the features array in the below listed json):
<path d="M-85.388717,33.913044L-85.391495,33.927068L-85.398837,33.964129L-85.407637,33.964204L-85.407831,33.960548L-85.425444,33.960645L-85.425627,33.957069L-85.495289,33.95691L-85.49582,33.942394L-85.530094,33.941423L-85.531812,33.903049L-85.532482,33.889152L-85.597063,33.889703L-85.601858,33.88975L-85.601913,33.875101L-85.601899,33.874865L-85.637014,33.875944L-85.637012,33.875273L-85.637126,33.846497L-85.636882,33.846495L-85.585201,33.84592L-85.585985,33.802095L-85.603391,33.802344L-85.603465,33.788474L-85.603469,33.787755L-85.62089,33.787944L-85.621019,33.782331L-85.621245,33.773508L-85.638049,33.773339L-85.638586,33.649158L-85.638579,33.648413L-85.64704,33.648772L-85.64719,33.641529L-85.651283,33.64157L-85.651295,33.637972L-85.655549,33.638127L-85.65581,33.627166L-85.674932,33.627254L-85.690684,33.627789L-85.690716,33.625105L-85.69014,33.615815L-85.689954,33.612909L-85.723074,33.613505L-85.72365,33.613491L-85.72367,33.613492L-85.724953,33.613539L-85.724517,33.59943L-85.737379,33.599823L-85.742202,33.600002L-85.742348,33.586553L-85.744118,33.556075L-85.796054,33.55622L-85.796852,33.541849L-85.849839,33.49969L-85.85189,33.498742L-85.852421,33.491644L-85.869308,33.491574L-85.870053,33.476757L-85.887675,33.476768L-85.887782,33.469427L-85.782735,33.469349L-85.782689,33.483638L-85.781244,33.483625L-85.765631,33.483477L-85.765308,33.496862L-85.765427,33.498593L-85.740983,33.498376L-85.680346,33.496623L-85.66722,33.496293L-85.643482,33.495885L-85.627835,33.495624L-85.623645,33.495373L-85.623387,33.495371L-85.565653,33.494992L-85.563763,33.495081L-85.539922,33.494743L-85.527515,33.494608L-85.52513,33.494781L-85.51731,33.494524L-85.501645,33.494456L-85.497455,33.494624L-85.355315,33.49248L-85.352573,33.492438L-85.352576,33.494538L-85.354491,33.498866L-85.351594,33.4996L-85.349958,33.501216L-85.346705,33.501148L-85.344923,33.497608L-85.342544,33.495961L-85.33828,33.4947L-85.331061,33.491014L-85.324856,33.489161L-85.320893,33.488359L-85.316028,33.488267L-85.314852,33.487603L-85.30925,33.483137L-85.308211,33.481579L-85.304439,33.482884L-85.313999,33.529807L-85.314091,33.530218L-85.314843,33.534951L-85.314994,33.535898L-85.31534,33.537646L-85.323792,33.580339L-85.342722,33.675953L-85.344054,33.682684L-85.355252,33.739245L-85.357402,33.750104L-85.360491,33.767958L-85.361844,33.773951L-85.364595,33.788446L-85.376403,33.850656L-85.377426,33.856047L-85.379455,33.866291L-85.380885,33.873508Z"></path>
But, visually there is nothing. I checked adding fill and stroke values, with no results. I also tried scaling the paths up to see if they were rendering too small, the size increased, and the browser dev tools showed a large size, but visually we still have a blank area.
Here is the code I am using to try and produce the map:
./corrected.json
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "GEO_ID": "0500000US01029", "STATE": "01", "COUNTY": "029", "NAME": "Cleburne", "LSAD": "County", "CENSUSAREA": 560.100000 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -85.388717, 33.913044 ], [ -85.380885, 33.873508 ], [ -85.379455, 33.866291 ], [ -85.377426, 33.856047 ], [ -85.376403, 33.850656 ], [ -85.364595, 33.788446 ], [ -85.361844, 33.773951 ], [ -85.360491, 33.767958 ], [ -85.357402, 33.750104 ], [ -85.355252, 33.739245 ], [ -85.344054, 33.682684 ], [ -85.342722, 33.675953 ], [ -85.323792, 33.580339 ], [ -85.315340, 33.537646 ], [ -85.314994, 33.535898 ], [ -85.314843, 33.534951 ], [ -85.314091, 33.530218 ], [ -85.313999, 33.529807 ], [ -85.304439, 33.482884 ], [ -85.308211, 33.481579 ], [ -85.309250, 33.483137 ], [ -85.314852, 33.487603 ], [ -85.316028, 33.488267 ], [ -85.320893, 33.488359 ], [ -85.324856, 33.489161 ], [ -85.331061, 33.491014 ], [ -85.338280, 33.494700 ], [ -85.342544, 33.495961 ], [ -85.344923, 33.497608 ], [ -85.346705, 33.501148 ], [ -85.349958, 33.501216 ], [ -85.351594, 33.499600 ], [ -85.354491, 33.498866 ], [ -85.352576, 33.494538 ], [ -85.352573, 33.492438 ], [ -85.355315, 33.492480 ], [ -85.497455, 33.494624 ], [ -85.501645, 33.494456 ], [ -85.517310, 33.494524 ], [ -85.525130, 33.494781 ], [ -85.527515, 33.494608 ], [ -85.539922, 33.494743 ], [ -85.563763, 33.495081 ], [ -85.565653, 33.494992 ], [ -85.623387, 33.495371 ], [ -85.623645, 33.495373 ], [ -85.627835, 33.495624 ], [ -85.643482, 33.495885 ], [ -85.667220, 33.496293 ], [ -85.680346, 33.496623 ], [ -85.740983, 33.498376 ], [ -85.765427, 33.498593 ], [ -85.765308, 33.496862 ], [ -85.765631, 33.483477 ], [ -85.781244, 33.483625 ], [ -85.782689, 33.483638 ], [ -85.782735, 33.469349 ], [ -85.887782, 33.469427 ], [ -85.887675, 33.476768 ], [ -85.870053, 33.476757 ], [ -85.869308, 33.491574 ], [ -85.852421, 33.491644 ], [ -85.851890, 33.498742 ], [ -85.849839, 33.499690 ], [ -85.796852, 33.541849 ], [ -85.796054, 33.556220 ], [ -85.744118, 33.556075 ], [ -85.742348, 33.586553 ], [ -85.742202, 33.600002 ], [ -85.737379, 33.599823 ], [ -85.724517, 33.599430 ], [ -85.724953, 33.613539 ], [ -85.723670, 33.613492 ], [ -85.723650, 33.613491 ], [ -85.723074, 33.613505 ], [ -85.689954, 33.612909 ], [ -85.690140, 33.615815 ], [ -85.690716, 33.625105 ], [ -85.690684, 33.627789 ], [ -85.674932, 33.627254 ], [ -85.655810, 33.627166 ], [ -85.655549, 33.638127 ], [ -85.651295, 33.637972 ], [ -85.651283, 33.641570 ], [ -85.647190, 33.641529 ], [ -85.647040, 33.648772 ], [ -85.638579, 33.648413 ], [ -85.638586, 33.649158 ], [ -85.638049, 33.773339 ], [ -85.621245, 33.773508 ], [ -85.621019, 33.782331 ], [ -85.620890, 33.787944 ], [ -85.603469, 33.787755 ], [ -85.603465, 33.788474 ], [ -85.603391, 33.802344 ], [ -85.585985, 33.802095 ], [ -85.585201, 33.845920 ], [ -85.636882, 33.846495 ], [ -85.637126, 33.846497 ], [ -85.637012, 33.875273 ], [ -85.637014, 33.875944 ], [ -85.601899, 33.874865 ], [ -85.601913, 33.875101 ], [ -85.601858, 33.889750 ], [ -85.597063, 33.889703 ], [ -85.532482, 33.889152 ], [ -85.531812, 33.903049 ], [ -85.530094, 33.941423 ], [ -85.495820, 33.942394 ], [ -85.495289, 33.956910 ], [ -85.425627, 33.957069 ], [ -85.425444, 33.960645 ], [ -85.407831, 33.960548 ], [ -85.407637, 33.964204 ], [ -85.398837, 33.964129 ], [ -85.391495, 33.927068 ], [ -85.388717, 33.913044 ] ] ] } }
,
{ "type": "Feature", "properties": { "GEO_ID": "0500000US01031", "STATE": "01", "COUNTY": "031", "NAME": "Coffee", "LSAD": "County", "CENSUSAREA": 678.972000 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -86.030441, 31.618939 ], [ -86.004085, 31.619067 ], [ -85.999948, 31.619311 ], [ -85.980098, 31.619189 ], [ -85.926702, 31.618966 ], [ -85.904460, 31.618775 ], [ -85.899202, 31.618729 ], [ -85.878888, 31.618547 ], [ -85.832214, 31.618240 ], [ -85.789142, 31.617964 ], [ -85.789141, 31.587866 ], [ -85.789140, 31.540617 ], [ -85.789308, 31.490925 ], [ -85.789370, 31.487561 ], [ -85.789372, 31.487430 ], [ -85.790294, 31.431467 ], [ -85.789837, 31.385469 ], [ -85.789815, 31.383145 ], [ -85.789594, 31.372698 ], [ -85.789754, 31.358887 ], [ -85.789785, 31.356562 ], [ -85.789866, 31.350574 ], [ -85.790001, 31.342857 ], [ -85.789975, 31.341524 ], [ -85.790064, 31.337277 ], [ -85.790065, 31.336908 ], [ -85.790100, 31.336276 ], [ -85.790116, 31.330082 ], [ -85.790327, 31.323452 ], [ -85.790434, 31.320267 ], [ -85.790525, 31.317495 ], [ -85.791089, 31.297603 ], [ -85.791167, 31.295340 ], [ -85.791243, 31.294184 ], [ -85.791245, 31.294004 ], [ -85.791214, 31.293551 ], [ -85.791218, 31.293252 ], [ -85.791361, 31.291777 ], [ -85.791312, 31.269325 ], [ -85.791291, 31.209854 ], [ -85.791402, 31.196349 ], [ -85.847766, 31.196369 ], [ -85.857352, 31.196367 ], [ -85.857999, 31.196374 ], [ -85.865347, 31.196374 ], [ -85.882227, 31.196339 ], [ -85.938287, 31.196344 ], [ -85.949386, 31.196123 ], [ -85.950142, 31.196242 ], [ -85.960322, 31.195962 ], [ -85.966110, 31.195935 ], [ -85.999042, 31.195777 ], [ -86.013060, 31.195318 ], [ -86.058535, 31.194082 ], [ -86.116734, 31.193015 ], [ -86.116735, 31.183885 ], [ -86.116736, 31.182099 ], [ -86.125405, 31.182057 ], [ -86.125482, 31.192754 ], [ -86.141674, 31.192693 ], [ -86.193476, 31.192213 ], [ -86.194003, 31.211362 ], [ -86.193542, 31.213028 ], [ -86.193846, 31.219589 ], [ -86.193714, 31.243119 ], [ -86.193336, 31.250169 ], [ -86.193546, 31.262915 ], [ -86.193888, 31.283526 ], [ -86.194631, 31.327933 ], [ -86.194779, 31.336812 ], [ -86.195044, 31.352681 ], [ -86.195056, 31.353359 ], [ -86.196091, 31.410348 ], [ -86.196365, 31.425431 ], [ -86.193951, 31.440072 ], [ -86.193973, 31.446586 ], [ -86.194724, 31.524460 ], [ -86.194784, 31.529949 ], [ -86.182098, 31.530047 ], [ -86.156561, 31.530203 ], [ -86.156768, 31.537527 ], [ -86.150314, 31.537601 ], [ -86.143950, 31.537675 ], [ -86.144761, 31.570994 ], [ -86.145895, 31.617741 ], [ -86.124952, 31.618044 ], [ -86.123834, 31.618167 ], [ -86.094925, 31.618405 ], [ -86.058021, 31.618793 ], [ -86.030441, 31.618939 ] ] ] } }
]
}
./maps.html
<html>
<div id="map-container"></div>
<script src="https://d3js.org/d3.v7.min.js"></script>
<script src="https://unpkg.com/topojson#3"></script>
<script src="map.js"></script>
</html>
./map.js
let h = 500;
let w = 960;
path = d3.geoPath();
d3.select("#map-container")
.append("svg")
.attr("id", "map")
.attr("height", h)
.attr("width", w)
.attr("fill", "blue")
.append("title")
.text("Southeastern Region Counties")
.attr("id", "title");
let maplink = "./corrected.json";
Promise.all([d3.json(maplink)]).then(([data]) => {
let paths = d3.select("#map").selectAll("path").data(data.features);
paths.enter().append("path").attr('d', path);
});
I don't see any error message, and haven't located my error in the documentation. What am I missing?
Your coordinates are unprojected, a collection of latitude longitude pairs, but you are treating these coordinates as pixel coordinates. This shows with your resulting path data: M-85.388717,33.913044, a coordinate representing -85° E, 34° N. That the x value, longitude here, is negative means your map is rendered outside the SVG - to its left, hence why it is not visible.
You need to run your latitute longitute pairs through a geographic projection that takes those points on a 3D sphere and projects them to the 2D plane of your SVG. In doing so you'll introduce some degree of distortion, so you may want to try a few projections (though this is often minimal if zoomed in enough, say on a city).
If you do not provide a projection to d3.geoPath() it'll use a null projection which treats input coordinates as pixel coordinates. This won't let you simply shift the map to the right: geographic convention is that latitutes increase as one moves north (typically up on a map), whereas SVG/Canvas convention is that pixel y values increase as one moves down
For example to use an Albers projection you could use:
var projection = d3.geoAlbers();
var path = d3.geoPath().projection(projection);
This gets us half way there: the projection is independent of your features, we need to center and scale the projection appropriately. To do so, after we load the geojson, we can use:
projection.fitSize([width,height],data)
Where data is a geojson object (hence why we don't use data.features).

Laravel 6 import GeoJson to mariadb 10.3

i try to import a geojson file to mariadb but without success.
i have install "grimzy/laravel-mysql-spatial": "^3.0"
In mariadb 10.3 i have a table with fiel call geometry which is a multipolygon type.
i put my geojson file into storage folder with this contains :
{
"type" : "Feature",
"geometry" : {
"type" : "MultiPolygon",
"coordinates" : [
[
[
[ -0.1102826359, 46.0408417066 ],
[ -0.1105248307, 46.0396563022 ],
[ -0.1110213611, 46.0388036639 ],
[ -0.1129798062, 46.0362094235 ],
[ -0.1163671451, 46.03141209 ],
[ -0.1169999535, 46.0306611122 ],
[ -0.1223431941, 46.0274210917 ],
[ -0.127828108, 46.02738696 ],
[ -0.131955472, 46.0263239776 ],
[ -0.1327192268, 46.0260820678 ],
[ -0.1341111631, 46.0254217424 ],
[ -0.1364125327, 46.0221533793 ],
[ -0.1366312892, 46.0211352721 ],
[ -0.1364355706, 46.0196546077 ],
[ -0.137559152, 46.0144992523 ],
[ -0.1406447432, 46.0112045517 ],
[ -0.1435702916, 46.0073563523 ],
[ -0.1448192016, 46.0046802437 ],
[ -0.1457237111, 46.0025868528 ],
[ -0.1443122335, 46.0023953422 ],
[ -0.1424505442, 46.0019288232 ],
[ -0.1410560728, 46.0012420393 ],
[ -0.1391710932, 45.9993693344 ],
[ -0.1373867157, 45.9934546199 ],
[ -0.1368442472, 45.9886806546 ],
[ -0.1367820943, 45.9872278342 ],
[ -0.1338326656, 45.9874915555 ],
[ -0.1324892758, 45.9877161822 ],
[ -0.1309578675, 45.9886354109 ],
[ -0.1282863936, 45.9905603197 ],
[ -0.1268777522, 45.9925728562 ],
[ -0.1251428694, 45.9941248526 ],
[ -0.1234795172, 45.9954125981 ],
[ -0.1218545361, 45.9963297687 ],
[ -0.1190123082, 45.9975129571 ],
[ -0.1173794238, 45.9978823511 ],
[ -0.1135347376, 45.998948798 ],
[ -0.1140048709, 46.0020224567 ],
[ -0.1146495748, 46.0051634093 ],
[ -0.1137408096, 46.0057182993 ],
[ -0.109439723, 46.0066376261 ],
[ -0.1072318555, 46.0058547069 ],
[ -0.0989845556, 46.0055742078 ],
[ -0.0932577159, 46.0108323641 ],
[ -0.0856733123, 46.0115204658 ],
[ -0.0849251337, 46.0113020327 ],
[ -0.0843106562, 46.0113458021 ],
[ -0.0823215103, 46.0126156391 ],
[ -0.0786467339, 46.0150135781 ],
[ -0.076715267, 46.017573127 ],
[ -0.0757766731, 46.0199173397 ],
[ -0.0727775177, 46.0234925804 ],
[ -0.071824253, 46.0238888133 ],
[ -0.0719896303, 46.0246953855 ],
[ -0.0731574813, 46.0248051979 ],
[ -0.0737503565, 46.0265473059 ],
[ -0.0749919333, 46.0283213729 ],
[ -0.0773331769, 46.0301160334 ],
[ -0.0817461309, 46.0333205399 ],
[ -0.087177269, 46.0352688459 ],
[ -0.0893528382, 46.0371191573 ],
[ -0.0914526844, 46.0392769973 ],
[ -0.0950451816, 46.0397647084 ],
[ -0.0987452293, 46.0397717385 ],
[ -0.1074530256, 46.0397522898 ],
[ -0.1095303511, 46.0406740018 ],
[ -0.1102826359, 46.0408417066 ]
]
]
]
},
and in my controller i have add :
use Grimzy\LaravelMysqlSpatial\Types\Point;
use Grimzy\LaravelMysqlSpatial\Types\Polygon;
use Grimzy\LaravelMysqlSpatial\Eloquent;
$example = file_get_contents(storage_path('example.json'));
$data = json_decode($example, true);
$majsigadhe->geometry = DB::raw('MultiPolygonFromText(\'MULTIPOLYGON('.$wkt.'))');
But i have an error : SQLSTATE[42000]: Syntax error or access violation: 1064 Erreur de syntaxe près de ''MULTIPOLYGON([ [45.5672032582 -0.781746338], [45.5681200944 -0.7807820887], [45' à la ligne 1 (SQL: update
Can you help me please !

what is the json mapping to insert geo data into elasticsearch?

what would be the json mapping to insert geo data into elasticsearch ??
if the sample json data as follows:
{ "type": "Feature", "properties": { "ID": 631861455.000000, "address": "1206 UPPER", "city": "la vegas", "state": "AL", "zip_code": "15656", "OGR_GEOMETRY": "POLYGON" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -86.477551331, 32.490605650000099 ], [ -86.477637350999899, 32.4903921820001 ], [ -86.478257247, 32.490565591000099 ], [ -86.478250466, 32.490580239000103 ], [ -86.478243988, 32.490593680000096 ], [ -86.47823751, 32.490607122 ], [ -86.478231749, 32.490619100000096 ], [ -86.478224637, 32.490634065000101 ], [ -86.47821823699999, 32.490647540000097 ], [ -86.478211847999901, 32.490661035000095 ], [ -86.478205478999897, 32.490674526000099 ], [ -86.478202107999891, 32.490681666000093 ], [ -86.478199132, 32.4906880240001 ], [ -86.478192825999898, 32.490701523 ], [ -86.478186533, 32.490715047 ], [ -86.47818320899999, 32.490722209000097 ], [ -86.47818027999989, 32.490728569000098 ], [ -86.478174063, 32.490742125000097 ], [ -86.47816785099999, 32.490755654000097 ], [ -86.47816255799999, 32.490767236000096 ], [ -86.478159053999889, 32.490774513000105 ], [ -86.477551331, 32.490605650000099 ] ] ] } }
Look at Geo point mapping.
You need to define mapping.

Error in importing geojson polygon into RethinkDB

I have following geojson polygon JSON that I'd like to import into rethinkDB. I attempted to use following r.geojson approach to import (refer to Building an earthquake map with RethinkDB and GeoJSON):
r.db("strongloop").table("region").insert(
r.http("91231cd2.ngrok.io/data/geojson/MP14_REGION_WEB_PL_FLAT.json")("features")
.merge(function(zone) {
return {
zone: r.geojson(zone("geometry"))
}
}))
This approach gives me following error:
RqlRuntimeError: Invalid LinearRing. Are there antipodal or duplicate vertices? Is it self-intersecting? in: r.db("strongloop").table("region").insert(r.http("91231cd2.ngrok.io/data/geojson/MP14_REGION_WEB_PL_FLAT.json")("features").merge(function(var_63) { return {zone: r.geojson(var_63("geometry"))}; }))
I suspect it is because the geojson comes from flattened multipolygon (done using geojson.io Meta feature since RethinkDB does not support multipolygon) - but visually, the polygon is what I expected. I've also attempted to use r.polygon approach as following:
r.db("strongloop").table("region").insert(
r.http("91231cd2.ngrok.io/data/geojson/MP14_REGION_WEB_PL_FLAT.json")("features")
.merge(function(zone) {
return {
zone: r.polygon(zone("geometry")("coordinates"))
}
}))
but RethinkDB expects me to give array of points
RqlCompileError: Expected 3 or more arguments but found 1 in: r.db("strongloop").table("region").insert(r.http("91231cd2.ngrok.io/data/geojson/MP14_REGION_WEB_PL_FLAT.json")("features").merge(function(var_64) { return {zone: r.polygon(var_64("geometry")("coordinates"))}; }))
I could not figure out how to extract array of geometry coordinates before passing to r.polygon using code above.
How should I resolve this? Is there any better way?
Check URL
What happens if you do the http request by itself? I tried it and g0t a 404 on that resource. I would run that command first and make sure it works:
r.http("91231cd2.ngrok.io/data/geojson/MP14_REGION_WEB_PL_FLAT.json")
Try r.args
r.polygon expects 3 arguments, but you're passing it one. You might try using r.args to spread those arguments in the function (similar to Function.apply, if you're a JavaScript guy)
r.db("strongloop").table("region").insert(
r.http("91231cd2.ngrok.io/data/geojson/MP14_REGION_WEB_PL_FLAT.json") ("features")
.merge(function(zone) {
return {
zone: r.polygon(r.args(zone("geometry")("coordinates")))
}
}))
Invalid Polygons
It seems that one of your polygons might be invalid. If you use the input from the other answer you posted and you use it the following function, it will work:
r.expr(ARRAY_FROM_OTHER_ANSWER_WITH_POLYGONS).do(function (arr) {
// Remove middle element
return arr.slice(0, 2).add(arr.slice(3, 5))
// Map all elements to polygons
// Make sure you pass an array of LON/LATs into `r.polygon`
.map(function (row) {
return r.polygon(r.args(row('geometry')('coordinates')(0)));
});
})
Perhaps you can insert them one by one and catch the ones that failed.
The folowing query fails:
r.json(r.http('https://gist.githubusercontent.com/tekoadjaib/9e0f0729c050b69b283f/raw/6950765ed4a931b9b208e69a3c39b3114be5c7e3/map.geojson'))('features')
.map(function (row) {
return r.polygon(r.args(row('geometry')('coordinates')(0)))
})
While this one (slicing the first 17 elements) doesn't.
r.json(r.http('https://gist.githubusercontent.com/tekoadjaib/9e0f0729c050b69b283f/raw/6950765ed4a931b9b208e69a3c39b3114be5c7e3/map.geojson'))('features')
.slice(0, 17)
.map(function (row) {
return r.polygon(r.args(row('geometry')('coordinates')(0)))
})
Running this command on RethinkDB Data Explorer
r.http("6f892736.ngrok.io/data/geojson/MP14_REGION_WEB_PL_FLAT.json") ("features")
I received (removed some to fit SO limit)
[
{
"geometry": {
"coordinates": [
[
[
103.84874965353661,
1.363027350968694
],
[
103.84924291873233,
1.362752820720889
],
[
103.84935645049902,
1.362682483934137
],
[
103.84973091592526,
1.362406260504349
],
[
103.84992386166968,
1.362263929416379
],
[
103.85137091514449,
1.361102941278631
],
[
103.85194295836556,
1.360652909851773
],
[
103.8522672818684,
1.360326981650605
],
[
103.82714577966834,
1.241938910658531
],
[
103.82714429349235,
1.241945678019855
]
]
],
"type": "Polygon"
},
"properties": {
"FMEL_UPD_D": "2014/12/05",
"INC_CRC": "F6D4903B6C0B72F8",
"OBJECTID": 1,
"REGION_C": "CR",
"REGION_N": "CENTRAL REGION",
"SHAPE_Area": 136405631.404,
"SHAPE_Leng": 131065.464453,
"X_ADDR": 27836.5573,
"Y_ADDR": 31929.9186
},
"type": "Feature"
},
{
"geometry": {
"coordinates": [
[
[
103.82233409716747,
1.247288081083765
],
[
103.82235533213682,
1.247267117084279
],
[
103.82236522405806,
1.247257351790808
],
[
103.82239090120945,
1.24726873242952
],
[
103.82242101348092,
1.247282079176339
],
[
103.82244356466394,
1.247292075218428
],
[
103.8224842992999,
1.247310126516275
],
[
103.82229812450149,
1.247323592638841
],
[
103.82233409716747,
1.247288081083765
]
]
],
"type": "Polygon"
},
"properties": {
"FMEL_UPD_D": "2014/12/05",
"INC_CRC": "F6D4903B6C0B72F8",
"OBJECTID": 1,
"REGION_C": "CR",
"REGION_N": "CENTRAL REGION",
"SHAPE_Area": 136405631.404,
"SHAPE_Leng": 131065.464453,
"X_ADDR": 27836.5573,
"Y_ADDR": 31929.9186
},
"type": "Feature"
},
{
"geometry": {
"coordinates": [
[
[
103.81270485670082,
1.253738883481215
],
[
103.81270819925057,
1.253736038375202
],
[
103.81271747666578,
1.25372269002029
],
[
103.81272796270179,
1.253696608214719
],
[
103.81272550089241,
1.25367617858827
],
[
103.81271663253291,
1.253660777180855
],
[
103.81268489667742,
1.253637281524639
],
[
103.81271738240808,
1.253596580832204
],
[
103.81272993138482,
1.25358085854482
],
[
103.81277884770714,
1.253527980705921
],
[
103.81280844732579,
1.253491732178708
],
[
103.81284783649771,
1.253444824881476
],
[
103.81289710415396,
1.253390129269173
],
[
103.81268859863616,
1.253749463519217
],
[
103.81269418659909,
1.253747966839359
],
[
103.81269933160983,
1.253743587040128
],
[
103.81270485670082,
1.253738883481215
]
]
],
"type": "Polygon"
},
"properties": {
"FMEL_UPD_D": "2014/12/05",
"INC_CRC": "F6D4903B6C0B72F8",
"OBJECTID": 1,
"REGION_C": "CR",
"REGION_N": "CENTRAL REGION",
"SHAPE_Area": 136405631.404,
"SHAPE_Leng": 131065.464453,
"X_ADDR": 27836.5573,
"Y_ADDR": 31929.9186
},
"type": "Feature"
},
{
"geometry": {
"coordinates": [
[
[
103.81422064298785,
1.252570070111331
],
[
103.81420878069888,
1.252558437176131
],
[
103.8142083125649,
1.252558523991746
],
[
103.81420773751474,
1.252557413427196
],
[
103.81419024508641,
1.252540259301697
],
[
103.81418525918728,
1.252535369363019
],
[
103.81417827319876,
1.252525659143691
],
[
103.81417483815903,
1.252520884975136
],
[
103.81417401960785,
1.25251974727783
],
[
103.8141688845694,
1.252512609990775
],
[
103.81416372167686,
1.252505434720186
],
[
103.81415922015667,
1.252490646509147
],
[
103.81415911592985,
1.252490302849641
],
[
103.81415883649417,
1.252489384917013
],
[
103.81415845013613,
1.252488116994314
],
[
103.8141580341274,
1.252486750495618
],
[
103.8141581823891,
1.252486131910979
],
[
103.81415836569447,
1.252485366819468
],
[
103.81415859033339,
1.252484429898899
],
[
103.81415863076748,
1.252484387394026
],
[
103.81415862268139,
1.252484294244369
],
[
103.81416084480966,
1.252475025422944
],
[
103.81416187994584,
1.25247070708728
],
[
103.81416579397985,
1.252464651487459
],
[
103.81417344413717,
1.25245281611786
],
[
103.81417638235824,
1.25244826989617
],
[
103.81418792868888,
1.252415206393471
],
[
103.81423209597757,
1.252398253489821
],
[
103.8142345678362,
1.252397304828964
],
[
103.81423924468973,
1.252395510602936
],
[
103.8142416716218,
1.252394579124685
],
[
103.81424197622378,
1.252394461559454
],
[
103.81424641316956,
1.252392758672508
],
[
103.81427168974326,
1.252383056828959
],
[
103.81429695645653,
1.252370091131469
],
[
103.81430622571014,
1.252365335143192
],
[
103.81430795807904,
1.252364492287584
],
[
103.81430790237042,
1.252364474199889
],
[
103.8143179156083,
1.252359335670564
],
[
103.81433202075975,
1.252352098139711
],
[
103.81434014977647,
1.252347926362841
],
[
103.81435231859189,
1.252341681810603
],
[
103.81435985727103,
1.252338114145249
],
[
103.81437420681739,
1.25233151509769
],
[
103.81439499523958,
1.252321955205564
],
[
103.81439606179633,
1.252321465047431
],
[
103.81439624419711,
1.252321532876141
],
[
103.81440192381508,
1.25231876917771
],
[
103.81441291824507,
1.252313712952395
],
[
103.81442976570837,
1.252305965378984
],
[
103.81444317808666,
1.252299726261537
],
[
103.81445277979405,
1.252295146626335
],
[
103.81447443170696,
1.252284820742596
],
[
103.8144961555022,
1.252274461397674
],
[
103.81450288101018,
1.252271253663335
],
[
103.81450281451966,
1.252271173174363
],
[
103.81452463535528,
1.252260878944195
],
[
103.81458959107665,
1.25223203649656
],
[
103.81461125376586,
1.252222416920872
],
[
103.81464389561143,
1.252207399268555
],
[
103.81465169486319,
1.252203810803814
],
[
103.81469601222396,
1.252183421305906
],
[
103.81472344798394,
1.252170002532816
],
[
103.81478302601083,
1.252140862505733
],
[
103.81484031637163,
1.252113379257888
],
[
103.81490026635718,
1.25208846442443
],
[
103.81491445851239,
1.252102786050432
],
[
103.81491771565472,
1.252106072536219
],
[
103.81491908860134,
1.25210674629792
],
[
103.81493128425387,
1.252117179139818
],
[
103.8149446623662,
1.2521281301912
],
[
103.81496569689162,
1.252131490055921
],
[
103.81497133065815,
1.25213238993891
],
[
103.81498839193847,
1.252128956184855
],
[
103.81500279627888,
1.252124305136556
],
[
103.8150235712083,
1.252116328782531
],
[
103.81502467283144,
1.252112382141001
],
[
103.8150250430265,
1.252112184992011
],
[
103.81502909456997,
1.252100774646097
],
[
103.81503503665392,
1.252084043029215
],
[
103.81503408874394,
1.252078647580404
],
[
103.81503511578735,
1.25207496772605
],
[
103.81503518952596,
1.252066416954603
],
[
103.81502759086356,
1.252038774077729
],
[
103.81502703827032,
1.252038532608371
],
[
103.81502617751417,
1.252033633656605
],
[
103.81501061513713,
1.252014397701631
],
[
103.81497715415199,
1.251984291152084
],
[
103.81496625504562,
1.251978257151349
],
[
103.8149622584071,
1.251976044141786
],
[
103.8149536020188,
1.251971250945737
],
[
103.8149359747586,
1.25196149181759
],
[
103.81491979321531,
1.251953915836878
],
[
103.8149053934479,
1.251947173693286
],
[
103.81487481213755,
1.251932856472991
],
[
103.81486042674678,
1.251926121564181
],
[
103.8148226958023,
1.251918231615303
],
[
103.8148209230086,
1.251917860813026
],
[
103.81482003795891,
1.251917765848395
],
[
103.8148186775897,
1.251917391431592
],
[
103.81480645223182,
1.251914834704565
],
[
103.81478684994318,
1.251914215075008
],
[
103.81478406270905,
1.25191412733175
],
[
103.81476586212422,
1.251913551121548
],
[
103.81475217215036,
1.251913118737449
],
[
103.81473641375817,
1.251913570807558
],
[
103.81469760451252,
1.25191528611085
],
[
103.81464911173373,
1.251930252101506
],
[
103.81464647993616,
1.251931415096138
],
[
103.81464604415146,
1.251931198949751
],
[
103.81463423207276,
1.251934844360703
],
[
103.81462343982588,
1.251938175059867
],
[
103.81461634052772,
1.251941862105349
],
[
103.81459325275814,
1.251953853820537
],
[
103.81457931114169,
1.251961094067155
],
[
103.81457055045844,
1.251965643864866
],
[
103.81450478872569,
1.251999797642535
],
[
103.81446223335465,
1.252023820888956
],
[
103.81441832030102,
1.2520486110264
],
[
103.8143689396795,
1.25207648681698
],
[
103.81429144309426,
1.252119919289534
],
[
103.81421839961543,
1.252163028029699
],
[
103.81418472441868,
1.252183801048487
],
[
103.81416549402833,
1.252195662559566
],
[
103.81411929141971,
1.252234061560852
],
[
103.81407773413764,
1.252281223893357
],
[
103.81405899059976,
1.252313446282806
],
[
103.81403917762307,
1.252371587767593
],
[
103.81403048853925,
1.252414490782956
],
[
103.81403453146623,
1.252476150424537
],
[
103.81404507986444,
1.252520744745098
],
[
103.81406615890175,
1.252581120314285
],
[
103.81410007800378,
1.252628997652677
],
[
103.81413071763996,
1.252654609498039
],
[
103.81415741467501,
1.252660750333722
],
[
103.81415875168324,
1.252661057827697
],
[
103.81415903202367,
1.252661122944038
],
[
103.81416270520218,
1.25266196764807
],
[
103.81416714302718,
1.252662988708921
],
[
103.81416796517983,
1.252663120752286
],
[
103.81420024580622,
1.252650676021723
],
[
103.8142128693197,
1.252638786426654
],
[
103.8142159252361,
1.252635907855009
],
[
103.81421741504606,
1.252629051874232
],
[
103.81422008102156,
1.252623340828278
],
[
103.81422398521352,
1.252611535275082
],
[
103.8142249584107,
1.252598998973394
],
[
103.81422552184074,
1.252591729690962
],
[
103.81422064298785,
1.252570070111331
]
]
],
"type": "Polygon"
},
"properties": {
"FMEL_UPD_D": "2014/12/05",
"INC_CRC": "F6D4903B6C0B72F8",
"OBJECTID": 1,
"REGION_C": "CR",
"REGION_N": "CENTRAL REGION",
"SHAPE_Area": 136405631.404,
"SHAPE_Leng": 131065.464453,
"X_ADDR": 27836.5573,
"Y_ADDR": 31929.9186
},
"type": "Feature"
},
{
"geometry": {
"coordinates": [
[
[
103.74130389714394,
1.159976941119677
],
[
103.7413428293003,
1.159968251449955
],
[
103.74129985127891,
1.159780169341412
],
[
103.74126091912512,
1.159788858106384
],
[
103.74130389714394,
1.159976941119677
]
]
],
"type": "Polygon"
},
"properties": {
"FMEL_UPD_D": "2014/12/05",
"INC_CRC": "11540153B663CA9B",
"OBJECTID": 5,
"REGION_C": "WR",
"REGION_N": "WEST REGION",
"SHAPE_Area": 257110296.977,
"SHAPE_Leng": 258264.026231,
"X_ADDR": 12896.436,
"Y_ADDR": 33986.5714
},
"type": "Feature"
}
]

Logstash Grok Filter Apache Access Log

I have been looking around here and there, but could not find the working resolution. I try to use Grok Filter inside the Logstash config file to filter Apache-Access log file. The log message looks like this: {"message":"00.00.0.000 - - [dd/mm/YYYY:hh:mm:ii +0000] \"GET /index.html HTTP/1.1\" 200 00"}.
On this moment I could only filter the client ip by using grok { match => [ "message", "%{IP:client_ip}" ] }.
I want to filter:
- The GET method,
- requested page (index.html),
- HTTP/1.1\,
- server response 200
- the last number 00 after 200 inside the message body
Please note that none of these does not work for me :
grok { match => { "message" => "%{COMBINEDAPACHELOG}" } }
or
grok { match => [ "message", "%{COMBINEDAPACHELOG}" ] }
Use the Grok Debugger to get an exact match on your log format. Its the only way.
http://grokdebug.herokuapp.com/
grok {
match => [ "message", "%{IP:client_ip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:apache_timestamp}\] \"%{WORD:method} /%{NOTSPACE:request_page} HTTP/%{NUMBER:http_version}\" %{NUMBER:server_response} " ]
}
Use the following:
filter {
grok {
match => { "message" => "%{COMMONAPACHELOG}" }
}
}
As you can see from your pattern COMBINEDAPACHELOG would fail because there are some missing components:
COMBINEDAPACHELOG %{COMMONAPACHELOG} %{QS:referrer} %{QS:agent}
https://github.com/elastic/logstash/blob/v1.4.2/patterns/grok-patterns
You can use COMBINEDAPACHELOG pattern for this,
%{IPORHOST:clientip} %{USER:ident} %{USER:auth} \[%{HTTPDATE:timestamp}\] "(?:%{WORD:verb} %{NOTSPACE:request}(?: HTTP/%{NUMBER:httpversion})?|%{DATA:rawrequest})" %{NUMBER:response} (?:%{NUMBER:bytes}|-) %{QS:referrer} %{QS:agent}
for instance, consider this sample apache log
111.222.333.123 HOME - [01/Feb/1998:01:08:46 -0800] "GET /bannerad/ad.htm HTTP/1.0" 200 28083
"http://www.referrer.com/bannerad/ba_intro.htm" "Mozilla/4.01
(Macintosh; I; PPC)"
above filter will produce,
{
"clientip": [
[
"111.222.333.123"
]
],
"HOSTNAME": [
[
"111.222.333.123"
]
],
"IP": [
[
null
]
],
"IPV6": [
[
null
]
],
"IPV4": [
[
null
]
],
"ident": [
[
"HOME"
]
],
"USERNAME": [
[
"HOME",
"-"
]
],
"auth": [
[
"-"
]
],
"timestamp": [
[
"01/Feb/1998:01:08:46 -0800"
]
],
"MONTHDAY": [
[
"01"
]
],
"MONTH": [
[
"Feb"
]
],
"YEAR": [
[
"1998"
]
],
"TIME": [
[
"01:08:46"
]
],
"HOUR": [
[
"01"
]
],
"MINUTE": [
[
"08"
]
],
"SECOND": [
[
"46"
]
],
"INT": [
[
"-0800"
]
],
"verb": [
[
"GET"
]
],
"request": [
[
"/bannerad/ad.htm"
]
],
"httpversion": [
[
"1.0"
]
],
"BASE10NUM": [
[
"1.0",
"200",
"28083"
]
],
"rawrequest": [
[
null
]
],
"response": [
[
"200"
]
],
"bytes": [
[
"28083"
]
],
"referrer": [
[
""http://www.referrer.com/bannerad/ba_intro.htm""
]
],
"QUOTEDSTRING": [
[
""http://www.referrer.com/bannerad/ba_intro.htm"",
""Mozilla/4.01 (Macintosh; I; PPC)""
]
],
"agent": [
[
""Mozilla/4.01 (Macintosh; I; PPC)""
]
]
}
can be tested here,
https://grokdebug.herokuapp.com/

Resources