tools to add buffer to poly

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

tools to add buffer to poly

Florian Lohoff-2

Hi,
i am using poly exports from Wambacher (thanks) to extract pbf
content from a germany export. Now i am trying to use the
admin boundarys from the pbfs which obviously get dropped
when using itself as boundary.

I'd rather not like to buffer them manually by drawing boundarys myself.

So - is there a tool(-chain) for poly -> poly adding some buffer
e.g. 50-100m ?

Flo
--
Florian Lohoff                                                 [hidden email]
        UTF-8 Test: The 🐈 ran after a 🐁, but the 🐁 ran away

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: tools to add buffer to poly

Darafei "Komяpa" Praliaskouski
Hi,

if you have a PostGIS at hand:

select ST_Buffer('POLYGON(lon lat, lon lat, lon lat....)'::geography, 50);

http://www.postgis.net/docs/ST_Buffer.html 

вт, 27 нояб. 2018 г. в 12:12, Florian Lohoff <[hidden email]>:

Hi,
i am using poly exports from Wambacher (thanks) to extract pbf
content from a germany export. Now i am trying to use the
admin boundarys from the pbfs which obviously get dropped
when using itself as boundary.

I'd rather not like to buffer them manually by drawing boundarys myself.

So - is there a tool(-chain) for poly -> poly adding some buffer
e.g. 50-100m ?

Flo
--
Florian Lohoff                                                 [hidden email]
        UTF-8 Test: The 🐈 ran after a 🐁, but the 🐁 ran away
_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
--
Darafei Praliaskouski
Support me: http://patreon.com/komzpa

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: tools to add buffer to poly

Florian Lohoff-2
On Tue, Nov 27, 2018 at 12:14:16PM +0300, Darafei "Komяpa" Praliaskouski wrote:
> Hi,
>
> if you have a PostGIS at hand:

I have.
 
> select ST_Buffer('POLYGON(lon lat, lon lat, lon lat....)'::geography, 50);
>
> http://www.postgis.net/docs/ST_Buffer.html

I know that - That means i need to rexport the admin boundarys from
wambacher as shape. Use shp2pgsql to put them into the postgis,
buffer them and rexport somehow as poly.

I though i would not be the only one having the problem.

I whished osmconvert had a "ready to use" buffer function for
the -B option ;)

Flo
--
Florian Lohoff                                                 [hidden email]
        UTF-8 Test: The 🐈 ran after a 🐁, but the 🐁 ran away

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: tools to add buffer to poly

Jochen123
In reply to this post by Florian Lohoff-2
On Tue, Nov 27, 2018 at 10:10:35AM +0100, Florian Lohoff wrote:
> i am using poly exports from Wambacher (thanks) to extract pbf
> content from a germany export. Now i am trying to use the
> admin boundarys from the pbfs which obviously get dropped
> when using itself as boundary.

What are using to do the extracts? When you use "osmium extract", you
could use the "smart strategy" and configure it to also extract the
boundary (see man page). That should work without extra buffering.

Jochen
--
Jochen Topf  [hidden email]  https://www.jochentopf.com/  +49-351-31778688

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: tools to add buffer to poly

Jochen123
In reply to this post by Florian Lohoff-2
On Tue, Nov 27, 2018 at 10:50:13AM +0100, Florian Lohoff wrote:

> On Tue, Nov 27, 2018 at 12:14:16PM +0300, Darafei "Komяpa" Praliaskouski wrote:
> > Hi,
> >
> > if you have a PostGIS at hand:
>
> I have.
>  
> > select ST_Buffer('POLYGON(lon lat, lon lat, lon lat....)'::geography, 50);
> >
> > http://www.postgis.net/docs/ST_Buffer.html
>
> I know that - That means i need to rexport the admin boundarys from
> wambacher as shape. Use shp2pgsql to put them into the postgis,
> buffer them and rexport somehow as poly.
>
> I though i would not be the only one having the problem.
>
> I whished osmconvert had a "ready to use" buffer function for
> the -B option ;)

Export from PostGIS as GeoJSON and use "osmium extract" which can read
the GeoJSON. Or see my other mail.

Jochen
--
Jochen Topf  [hidden email]  https://www.jochentopf.com/  +49-351-31778688

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: tools to add buffer to poly

Florian Lohoff-2
In reply to this post by Jochen123
On Tue, Nov 27, 2018 at 10:59:00AM +0100, Jochen Topf wrote:
> On Tue, Nov 27, 2018 at 10:10:35AM +0100, Florian Lohoff wrote:
> > i am using poly exports from Wambacher (thanks) to extract pbf
> > content from a germany export. Now i am trying to use the
> > admin boundarys from the pbfs which obviously get dropped
> > when using itself as boundary.
>
> What are using to do the extracts? When you use "osmium extract", you
> could use the "smart strategy" and configure it to also extract the
> boundary (see man page). That should work without extra buffering.

I am extracting addresses adding postcode and city from boundarys if
missing.

Typically i have some nrw pbf around which i cut down to reasonable
test sizes (a city) with osmconvert which strips off the boundary as
the poly to cut down the pbf is the same as the boundary.

Works fine with the hand-crafted simplyfied polys from geofabrik. Using
the automatic generated polys from wambacher from our admin boundarys
drops the boundarys it is cutting with. So my obvious solution would
be to add some buffer to the poly.

I guess i need to have a look at the osmium command line - only using
libosmium so far ;)

Flo
--
Florian Lohoff                                                 [hidden email]
        UTF-8 Test: The 🐈 ran after a 🐁, but the 🐁 ran away

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: tools to add buffer to poly

ikonor
In reply to this post by Florian Lohoff-2
Wambacher's Boundaries Map itself allows to add a buffer if you select
the "bpoly" option.

 From the Help page [1]:

bpoly - OSM polygon file with an enlarged margin (buffer). This is
sometimes advantageous during clipping.
if bpoly is selected, the size of the buffer can be entered in kilometres.


[1]
https://wambachers-osm.website/index.php/projekte/internationale-administrative-grenzen/boundaries-map-4-3-english

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: tools to add buffer to poly

Sebastian Kürten
In reply to this post by Florian Lohoff-2
Hi Florian,

I've been doing this quite frequently for my own projects and have
made the relevant tools available as open source a while ago.

You can find CLI tools in this project:
https://github.com/topobyte/simple-mapfile

I haven't written proper documentation yet, but here is how to create a
buffered polygon from an initial file polygon.wkb and store the
results in a file called buffered.wkb (on Linux):

  ./scripts/SmxCreate --geometry polygon.wkb
                      --output polygon.smx

  ./scripts/SmxBuffer --input polygon.smx
                      --distance 0.01
                      --output buffered.smx

  ./scripts/SmxExportGeometry --input buffered.smx
                              --output buffered.wkb

Make sure to run './gradlew create' before trying to run the scripts.

The input needs to be a plain WKB or WKT file, such as this:
https://github.com/ThatsBerlin/admin-areas/blob/master/bundesland/Berlin.wkb

The process involves creating an intermediary 'smx' file, which is
basically an XML file format that stores a WKB geometry base64-encoded
plus tags like we do in OSM. The buffer operation is available for smx
files and to get back to WKB or WKT you use the reverse operation.

I also have an implementation for reading poly files, but have not
integrated it into the toolchain at this point. I think there are tools
for converting from poly to wkt. I can also reintegrate the poly
import/export functionality if you are interested in using this
solution.

The distance argument is not meters or anything, but degrees which is
not very useful if you need exact bufferes in meters but for my use
cases it always worked to find a proper degree value and just use that
for my buffer polygons.

Best,
Sebastian

On Tue, 27 Nov 2018 10:10:35 +0100
Florian Lohoff <[hidden email]> wrote:

> Hi,
> i am using poly exports from Wambacher (thanks) to extract pbf
> content from a germany export. Now i am trying to use the
> admin boundarys from the pbfs which obviously get dropped
> when using itself as boundary.
>
> I'd rather not like to buffer them manually by drawing boundarys
> myself.
>
> So - is there a tool(-chain) for poly -> poly adding some buffer
> e.g. 50-100m ?
>
> Flo

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev
Reply | Threaded
Open this post in threaded view
|

Re: tools to add buffer to poly

Florian Lohoff-2
In reply to this post by Jochen123
On Tue, Nov 27, 2018 at 10:59:00AM +0100, Jochen Topf wrote:
> On Tue, Nov 27, 2018 at 10:10:35AM +0100, Florian Lohoff wrote:
> > i am using poly exports from Wambacher (thanks) to extract pbf
> > content from a germany export. Now i am trying to use the
> > admin boundarys from the pbfs which obviously get dropped
> > when using itself as boundary.
>
> What are using to do the extracts? When you use "osmium extract", you
> could use the "smart strategy" and configure it to also extract the
> boundary (see man page). That should work without extra buffering.

Replaced "osmconvert -B" with "osmium extract -p" in my processing
pipeline and everything is fine now.

Flo
--
Florian Lohoff                                                 [hidden email]
        UTF-8 Test: The 🐈 ran after a 🐁, but the 🐁 ran away

_______________________________________________
dev mailing list
[hidden email]
https://lists.openstreetmap.org/listinfo/dev

signature.asc (849 bytes) Download Attachment