Overpass-API icon indicating copy to clipboard operation
Overpass-API copied to clipboard

lat() and lon() for out:csv

Open thewayy opened this issue 7 years ago • 4 comments

Add please the lat() and lon() fieldnames.

Example: [out:csv(num,key,len,type,lat)]; way [highway]({{bbox}}); for (t["surface"]) (   make stat num=count(ways),key=_.val,len=sum(length()),type=u(type(),lat=u(lat() ); out; );

type() and furthermore id() work, but not lat() and lon()

Reason: The csv:custom method doesn't work proper. But similar output functionality is usable with out:csv. However, it lacks the very important lat() and lon() functionality.

thewayy avatar Jul 24 '18 21:07 thewayy

You can use the point evaluator for this purpose:

[out:csv(num,key,len,type,::lat, ::lon)];
way [highway]({{bbox}});
for (t["surface"])
(
  make stat 
     num=count(ways), 
     key=_.val,
     len=sum(length()),
     type=u(type()),
     ::geom = pt(10,20);
  out;
);

lat and lon are exposed as ::lat, and ::lon in the csv output string.

mmd-osm avatar Aug 06 '18 07:08 mmd-osm

My previous example was not exact. For line-by-line output, the coordinates can not be output for each element. This works:

[out:csv(_row;false)][bbox:48,13,48.5,13.5];
node[tourism=museum];
foreach(
  make out _row 
    = "| "  + u(type()) + " | " + u(id()) 
      + " | " + set(t["name"]) + " | " ;
  out;  
);

It would be very helpfull to get the coordinates for each element. But lat(), lon() does not work, for example when adding:

 + u(lat())

thewayy avatar Aug 11 '18 09:08 thewayy

The feature will be added in the next version.

drolbr avatar Mar 21 '19 16:03 drolbr

Commit 4ee748b9dedeb7b5832261f8945b46e12418d38d, part of 0.7.56 release.

mmd-osm avatar Apr 02 '20 19:04 mmd-osm