osmcode / osmcoastline

Extracts coastline data from OpenStreetMap planet file.
https://osmcode.org/osmcoastline/
GNU General Public License v3.0
109 stars 14 forks source link

Add integer lat/lng coordinates to feature tags after clipping to the lat/lng 1-degree tile grid #37

Closed JonMcPherson closed 3 years ago

JonMcPherson commented 4 years ago

I am working to partition the osm water_polygons by their respective tile coordinates as the integer lat/lng degree that they were clipped around. I'm able to derive the tile coordinates from the center point of the polygon's extent/envelope, but this additional complexity and processing has made me wish the tile coordinates were encoded in the feature properties after they are clipped to the grid.

Also, I noticed that the generated multi-polygon features always contain a single polygon even when there are multiple separate polygons contained in the tile. So I am also having to group by the tile coordinates to merge these cases into a single multi-polygon. Of course this would be a minor improvement to have this be done in osmcoastline. Basically just improvements to make it easier to ingest the data as distinct keyed tiles having a single feature rather than the full ~1GB planet water_polygons.shp ShapeFile of non-keyed features.

Example tile at N26W078

coastline-multi-polygon-1 coastline-multi-polygon-2

Edit: Another improvement would be to tag the features for empty ocean tiles that don't model any coastlines. I am currently having to split the ocean tiles from coastline tiles by checking if the geometry only has 5 points which are exactly the same as the extent/envelope of the geometry and having a width and height greater than 1. This allows me to filter out these tiles and interpret no-tile as empty ocean to save some space and time, but if the features were already tagged with this information, then this would be even simpler to ingest and save me some pre-processing work.

joto commented 3 years ago

Are you referring to the split coastline files on osmdata.openstreetmap.de ? Because the osmcoastline program doesn't split the output into a grid. There are the scripts at https://github.com/osmcode/osmcoastline/tree/master/simplify_and_split_postgis and https://github.com/osmcode/osmcoastline/tree/master/simplify_and_split_spatialite which do this and one of which does have X/Y columns, the other doesn't.

But the files you see on osmdata.openstreetmap.de are created by different scripts. I have changed those to add X/Y columns, that sounds like something useful to have.

Using Polygons instead of Multipolygons is done on purpose. Smaller features are easier and faster to handle and to render than larger. So for most users it is better that way.

I am not sure I understand why tagging the empty ocean tiles would be useful. If you only need the coastline itself, you can use the coastline shapefiles instead of the water polygons. But if you can see a simple and fast way to add this to the scripts I'd be willing to cosider a patch.