i want to get coastline data (in osm defined as spring mean high water level) from an exported osm data file to mask out the land part in an equidistant lon lat grid. I only need the water part and set the land area to some fillvalue. If i can get the polygons for the land (or sea) part i can check whether a point in my equidistant lon lat grid is water or land. This should basically pretty simply stuff.
Yesterday i made a python script which gets lon lat information from the osm file, eg:
<node id=“9351882” lat=“55.0150278” lon=“8.4262778”
This has worked nicely and i made a plot where i can see the coastline. But there seems to be too much information which i don’t need, for example ferry lines or forest data.
Then i found the information that is the tag for the coastline.
Then this includes the following information where suddently lon/lat is missing. I see values as ref=1455316585 which i cannot interpret:
Is there any mathematical formulation which i can apply to my python script to convert those values to lon/lat?
Hi, now i understand what is meant by ref=. This points to a node which comes with lon/lat.
Basically one has to get the following data from the osm file:
I’ll write that python script and will post it here. Maybe some other might find that useful. Basically the script reads netcdf data of a lon/lat array and returns netcdf data with the masked lon/lat field. The final lon/lat grid is then used by a hydrodynamical model.
yesterday i successfully converted the coastline for Sylt Island (Germany) from an .osm file into a masked array with 1 for sea and 0 for land. This masked array can be exported either to ascii or netcdf. The output is a equidistant lon-lat field with a resolution defined by the user. I’m using that netcdf file to mask out land area in my bathymetry for a hydrodynamic numerical model.
The code is written in python.
The first script extracts coastline data from an .osm file (extracted from the ‘extract’ option on openstreetmap.org) and saves each coastline data set (polygone) to ascii. The input to the second script is (i) the desired lon/lat array (WGS84) with the individual resolution needed and (ii) the coastline polygones obtained by the first script. Then the second script uses the “Ray Casting Method” whether a given lon lat position is inside the coastline polygone which would then be a land point.
That’s it. If anybody needs the script please send a mail via the forum. Maybe i even post the scripts here.