Welcome to the geofictician wiki.
User:Luciano/Sandbox/Help:Polygon files
Polygon files are a specific format text file widely used for real-world OSM-based applications. They are discussed on the OSM wiki.
Why polygon files?
Polygon format files are extremely useful when you want to use a utility like osmconvert to pull a territory-specific extract from the planet backup file. This can be a very fast way to load a large area into the JOSM editor - although the drawback is that it's only up-to-date to the most recent backup, so if someone else has edited an area in the meantime, you will run into edit conflicts when you go to upload any changes. Nevertheless, since most of us are working in areas where we are the only person working, this isn't that common, and you can always use the history function of the world map browser to make sure no one else has been working in an area before loading data in this way.
Example
I have a polygon format file for each of the county-equivalents in the Ardisphere. So let's say I want to work on Comuna de Minas. I download the most recent planet backup file. The Comuna de Minas polygon file is called MI_relation004169.poly.
Since I'm using a Windows desktop, at my command prompt window I type:
D:\mapland>osmconvert ogf_20160208_0700.osm.pbf -B="MI_relation004169.poly" --complex-ways -o="oMI.osm"
Then I simply open oMI.osm using JOSM. This is what I see:
Format
The actual polygon file used to generate the extract is just a flat text file with a lot of lat-lon pairs, like this.
relation004169.poly 1 1.25103E+002 -2.29837E+001 1.25104E+002 -2.29834E+001 1.25105E+002 -2.29831E+001 1.25106E+002 -2.29828E+001 1.25107E+002 -2.29826E+001 1.25107E+002 -2.29821E+001 1.25107E+002 -2.29815E+001 1.25108E+002 -2.29808E+001 1.25109E+002 -2.29803E+001 1.25110E+002 -2.29804E+001 1.25111E+002 -2.29802E+001 1.25112E+002 -2.29798E+001 1.25112E+002 -2.29793E+001 1.25113E+002 -2.29794E+001 1.25114E+002 -2.29797E+001 1.25115E+002 -2.29802E+001 1.25116E+002 -2.29806E+001 1.25116E+002 -2.29807E+001 1.25117E+002 -2.29808E+001 1.25117E+002 -2.29808E+001 1.25117E+002 -2.29809E+001 1.25118E+002 -2.29810E+001 1.25119E+002 -2.29817E+001 1.25119E+002 -2.29827E+001 1.25121E+002 -2.29838E+001 1.25122E+002 -2.29850E+001 1.25127E+002 -2.29888E+001 1.25133E+002 -2.29903E+001 1.25138E+002 -2.29919E+001 1.25140E+002 -2.29929E+001 1.25143E+002 -2.29924E+001 1.25146E+002 -2.29903E+001 1.25149E+002 -2.29881E+001 1.25153E+002 -2.29881E+001 1.25156E+002 -2.29883E+001 1.25157E+002 -2.29881E+001 1.25159E+002 -2.29868E+001 1.25159E+002 -2.29878E+001 1.25160E+002 -2.29883E+001 1.25158E+002 -2.29895E+001 1.25157E+002 -2.29904E+001 1.25157E+002 -2.29918E+001 1.25156E+002 -2.29931E+001 1.25158E+002 -2.29931E+001 1.25158E+002 -2.30213E+001 1.25152E+002 -2.30213E+001 1.25152E+002 -2.30313E+001 1.25148E+002 -2.30313E+001 1.25148E+002 -2.30557E+001 1.25150E+002 -2.30561E+001 1.25150E+002 -2.30564E+001 1.25150E+002 -2.30567E+001 1.25151E+002 -2.30571E+001 1.25153E+002 -2.30588E+001 1.25155E+002 -2.30592E+001 1.25155E+002 -2.30599E+001 1.25156E+002 -2.30602E+001 1.25157E+002 -2.30606E+001 1.25158E+002 -2.30609E+001 1.25159E+002 -2.30614E+001 1.25161E+002 -2.30627E+001 1.25162E+002 -2.30630E+001 1.25164E+002 -2.30634E+001 1.25164E+002 -2.30636E+001 1.25165E+002 -2.30640E+001 1.25166E+002 -2.30643E+001 1.25166E+002 -2.30643E+001 1.25173E+002 -2.30667E+001 1.25184E+002 -2.30823E+001 1.25187E+002 -2.30975E+001 1.25197E+002 -2.31107E+001 1.25208E+002 -2.31112E+001 1.25220E+002 -2.31136E+001 1.25263E+002 -2.30133E+001 1.25263E+002 -2.30129E+001 1.25263E+002 -2.30128E+001 1.25289E+002 -2.29531E+001 1.25362E+002 -2.27852E+001 1.25362E+002 -2.27851E+001 1.25362E+002 -2.27850E+001 1.25381E+002 -2.27404E+001 1.25428E+002 -2.26317E+001 1.25505E+002 -2.24529E+001 1.25505E+002 -2.24526E+001 1.25505E+002 -2.24522E+001 1.25511E+002 -2.24401E+001 1.25511E+002 -2.24401E+001 1.25511E+002 -2.24391E+001 1.25511E+002 -2.24391E+001 1.25514E+002 -2.24315E+001 1.25514E+002 -2.24314E+001 1.25514E+002 -2.24314E+001 1.25514E+002 -2.24313E+001 1.25515E+002 -2.24307E+001 1.25519E+002 -2.24197E+001 1.25447E+002 -2.24197E+001 1.25445E+002 -2.24197E+001 1.25444E+002 -2.24197E+001 1.25428E+002 -2.24197E+001 1.25411E+002 -2.24197E+001 1.25413E+002 -2.24276E+001 1.25416E+002 -2.24508E+001 1.25416E+002 -2.24508E+001 1.25415E+002 -2.24504E+001 1.25414E+002 -2.24503E+001 1.25414E+002 -2.24503E+001 1.25413E+002 -2.24499E+001 1.25413E+002 -2.24499E+001 1.25413E+002 -2.24503E+001 1.25412E+002 -2.24506E+001 1.25412E+002 -2.24507E+001 1.25411E+002 -2.24507E+001 1.25410E+002 -2.24506E+001 1.25409E+002 -2.24505E+001 1.25409E+002 -2.24506E+001 1.25409E+002 -2.24510E+001 1.25409E+002 -2.24512E+001 1.25409E+002 -2.24517E+001 1.25408E+002 -2.24520E+001 1.25408E+002 -2.24526E+001 1.25407E+002 -2.24531E+001 1.25407E+002 -2.24534E+001 1.25408E+002 -2.24540E+001 1.25409E+002 -2.24541E+001 1.25409E+002 -2.24543E+001 1.25409E+002 -2.24545E+001 1.25409E+002 -2.24548E+001 1.25410E+002 -2.24553E+001 1.25409E+002 -2.24559E+001 1.25409E+002 -2.24565E+001 1.25409E+002 -2.24568E+001 1.25409E+002 -2.24571E+001 1.25409E+002 -2.24576E+001 1.25409E+002 -2.24579E+001 1.25408E+002 -2.24582E+001 1.25408E+002 -2.24585E+001 1.25407E+002 -2.24589E+001 1.25407E+002 -2.24595E+001 1.25407E+002 -2.24602E+001 1.25406E+002 -2.24606E+001 1.25405E+002 -2.24605E+001 1.25404E+002 -2.24605E+001 1.25404E+002 -2.24609E+001 1.25403E+002 -2.24610E+001 1.25402E+002 -2.24608E+001 1.25402E+002 -2.24609E+001 1.25401E+002 -2.24609E+001 1.25400E+002 -2.24614E+001 1.25399E+002 -2.24613E+001 1.25398E+002 -2.24605E+001 1.25398E+002 -2.24601E+001 1.25397E+002 -2.24598E+001 1.25396E+002 -2.24593E+001 1.25396E+002 -2.24590E+001 1.25394E+002 -2.24590E+001 1.25393E+002 -2.24593E+001 1.25393E+002 -2.24595E+001 1.25391E+002 -2.24592E+001 1.25390E+002 -2.24592E+001 1.25389E+002 -2.24595E+001 1.25388E+002 -2.24600E+001 1.25388E+002 -2.24605E+001 1.25387E+002 -2.24610E+001 1.25387E+002 -2.24615E+001 1.25386E+002 -2.24621E+001 1.25385E+002 -2.24624E+001 1.25384E+002 -2.24619E+001 1.25383E+002 -2.24619E+001 1.25382E+002 -2.24622E+001 1.25381E+002 -2.24624E+001 1.25380E+002 -2.24620E+001 1.25379E+002 -2.24619E+001 1.25378E+002 -2.24620E+001 1.25378E+002 -2.24625E+001 1.25377E+002 -2.24628E+001 1.25377E+002 -2.24636E+001 1.25377E+002 -2.24642E+001 1.25376E+002 -2.24648E+001 1.25375E+002 -2.24655E+001 1.25374E+002 -2.24657E+001 1.25373E+002 -2.24661E+001 1.25372E+002 -2.24659E+001 1.25371E+002 -2.24657E+001 1.25371E+002 -2.24658E+001 1.25370E+002 -2.24655E+001 1.25369E+002 -2.24654E+001 1.25368E+002 -2.24661E+001 1.25368E+002 -2.24666E+001 1.25368E+002 -2.24670E+001 1.25368E+002 -2.24676E+001 1.25368E+002 -2.24678E+001 1.25368E+002 -2.24680E+001 1.25368E+002 -2.24683E+001 1.25368E+002 -2.24688E+001 1.25368E+002 -2.24693E+001 1.25367E+002 -2.24698E+001 1.25366E+002 -2.24707E+001 1.25365E+002 -2.24713E+001 1.25365E+002 -2.24716E+001 1.25365E+002 -2.24722E+001 1.25364E+002 -2.24735E+001 1.25365E+002 -2.24749E+001 1.25365E+002 -2.24761E+001 1.25366E+002 -2.24767E+001 1.25367E+002 -2.24771E+001 1.25368E+002 -2.24769E+001 1.25369E+002 -2.24772E+001 1.25369E+002 -2.24777E+001 1.25370E+002 -2.24785E+001 1.25371E+002 -2.24794E+001 1.25371E+002 -2.24798E+001 1.25372E+002 -2.24802E+001 1.25373E+002 -2.24809E+001 1.25373E+002 -2.24813E+001 1.25373E+002 -2.24821E+001 1.25373E+002 -2.24831E+001 1.25374E+002 -2.24837E+001 1.25375E+002 -2.24838E+001 1.25376E+002 -2.24847E+001 1.25376E+002 -2.24857E+001 1.25376E+002 -2.24866E+001 1.25375E+002 -2.24871E+001 1.25375E+002 -2.24879E+001 1.25375E+002 -2.24885E+001 1.25374E+002 -2.24894E+001 1.25373E+002 -2.24907E+001 1.25372E+002 -2.24918E+001 1.25372E+002 -2.24936E+001 1.25371E+002 -2.24944E+001 1.25371E+002 -2.24953E+001 1.25371E+002 -2.24959E+001 1.25372E+002 -2.24967E+001 1.25374E+002 -2.24976E+001 1.25375E+002 -2.24984E+001 1.25375E+002 -2.24995E+001 1.25376E+002 -2.25001E+001 1.25378E+002 -2.25011E+001 1.25378E+002 -2.25018E+001 1.25379E+002 -2.25029E+001 1.25379E+002 -2.25037E+001 1.25379E+002 -2.25052E+001 1.25378E+002 -2.25068E+001 1.25378E+002 -2.25076E+001 1.25378E+002 -2.25090E+001 1.25378E+002 -2.25101E+001 1.25378E+002 -2.25111E+001 1.25378E+002 -2.25120E+001 1.25378E+002 -2.25130E+001 1.25378E+002 -2.25137E+001 1.25377E+002 -2.25149E+001 1.25377E+002 -2.25162E+001 1.25375E+002 -2.25172E+001 1.25374E+002 -2.25183E+001 1.25372E+002 -2.25193E+001 1.25371E+002 -2.25198E+001 1.25370E+002 -2.25200E+001 1.25368E+002 -2.25203E+001 1.25367E+002 -2.25207E+001 1.25366E+002 -2.25221E+001 1.25366E+002 -2.25238E+001 1.25366E+002 -2.25244E+001 1.25365E+002 -2.25263E+001 1.25364E+002 -2.25266E+001 1.25362E+002 -2.25267E+001 1.25360E+002 -2.25263E+001 1.25359E+002 -2.25263E+001 1.25358E+002 -2.25274E+001 1.25358E+002 -2.25282E+001 1.25358E+002 -2.25298E+001 1.25357E+002 -2.25304E+001 1.25356E+002 -2.25306E+001 1.25354E+002 -2.25303E+001 1.25352E+002 -2.25296E+001 1.25352E+002 -2.25287E+001 1.25351E+002 -2.25281E+001 1.25349E+002 -2.25273E+001 1.25348E+002 -2.25267E+001 1.25347E+002 -2.25260E+001 1.25346E+002 -2.25254E+001 1.25344E+002 -2.25255E+001 1.25343E+002 -2.25258E+001 1.25342E+002 -2.25262E+001 1.25341E+002 -2.25278E+001 1.25340E+002 -2.25286E+001 1.25340E+002 -2.25295E+001 1.25340E+002 -2.25311E+001 1.25338E+002 -2.25322E+001 1.25337E+002 -2.25330E+001 1.25335E+002 -2.25331E+001 1.25334E+002 -2.25333E+001 1.25332E+002 -2.25334E+001 1.25331E+002 -2.25323E+001 1.25330E+002 -2.25320E+001 1.25330E+002 -2.25317E+001 1.25327E+002 -2.25322E+001 1.25326E+002 -2.25326E+001 1.25325E+002 -2.25332E+001 1.25323E+002 -2.25339E+001 1.25323E+002 -2.25345E+001 1.25323E+002 -2.25360E+001 1.25323E+002 -2.25376E+001 1.25322E+002 -2.25394E+001 1.25322E+002 -2.25405E+001 1.25322E+002 -2.25418E+001 1.25322E+002 -2.25432E+001 1.25320E+002 -2.25443E+001 1.25320E+002 -2.25453E+001 1.25319E+002 -2.25456E+001 1.25319E+002 -2.25466E+001 1.25320E+002 -2.25482E+001 1.25322E+002 -2.25490E+001 1.25323E+002 -2.25486E+001 1.25324E+002 -2.25503E+001 1.25323E+002 -2.25518E+001 1.25323E+002 -2.25534E+001 1.25323E+002 -2.25545E+001 1.25322E+002 -2.25550E+001 1.25322E+002 -2.25561E+001 1.25322E+002 -2.25577E+001 1.25321E+002 -2.25595E+001 1.25320E+002 -2.25606E+001 1.25320E+002 -2.25618E+001 1.25320E+002 -2.25633E+001 1.25320E+002 -2.25646E+001 1.25320E+002 -2.25652E+001 1.25321E+002 -2.25663E+001 1.25322E+002 -2.25679E+001 1.25323E+002 -2.25689E+001 1.25325E+002 -2.25692E+001 1.25326E+002 -2.25712E+001 1.25326E+002 -2.25730E+001 1.25327E+002 -2.25752E+001 1.25327E+002 -2.25765E+001 1.25326E+002 -2.25781E+001 1.25326E+002 -2.25797E+001 1.25326E+002 -2.25816E+001 1.25326E+002 -2.25824E+001 1.25325E+002 -2.25844E+001 1.25324E+002 -2.25853E+001 1.25323E+002 -2.25864E+001 1.25322E+002 -2.25877E+001 1.25322E+002 -2.25890E+001 1.25321E+002 -2.25902E+001 1.25322E+002 -2.25909E+001 1.25321E+002 -2.25914E+001 1.25320E+002 -2.25929E+001 1.25319E+002 -2.25941E+001 1.25317E+002 -2.25956E+001 1.25317E+002 -2.25965E+001 1.25316E+002 -2.25974E+001 1.25315E+002 -2.25976E+001 1.25314E+002 -2.25973E+001 1.25312E+002 -2.25971E+001 1.25311E+002 -2.25971E+001 1.25309E+002 -2.25973E+001 1.25308E+002 -2.25964E+001 1.25306E+002 -2.25958E+001 1.25305E+002 -2.25953E+001 1.25304E+002 -2.25945E+001 1.25302E+002 -2.25945E+001 1.25301E+002 -2.25948E+001 1.25301E+002 -2.25957E+001 1.25300E+002 -2.25976E+001 1.25299E+002 -2.25982E+001 1.25298E+002 -2.25989E+001 1.25296E+002 -2.25998E+001 1.25295E+002 -2.26002E+001 1.25293E+002 -2.26000E+001 1.25291E+002 -2.26000E+001 1.25289E+002 -2.25999E+001 1.25288E+002 -2.25998E+001 1.25286E+002 -2.26004E+001 1.25285E+002 -2.26022E+001 1.25283E+002 -2.26046E+001 1.25282E+002 -2.26056E+001 1.25280E+002 -2.26057E+001 1.25277E+002 -2.26065E+001 1.25276E+002 -2.26083E+001 1.25275E+002 -2.26096E+001 1.25274E+002 -2.26112E+001 1.25273E+002 -2.26134E+001 1.25271E+002 -2.26151E+001 1.25268E+002 -2.26159E+001 1.25265E+002 -2.26157E+001 1.25264E+002 -2.26167E+001 1.25262E+002 -2.26175E+001 1.25262E+002 -2.26197E+001 1.25262E+002 -2.26212E+001 1.25261E+002 -2.26241E+001 1.25261E+002 -2.26262E+001 1.25256E+002 -2.26298E+001 1.25253E+002 -2.26310E+001 1.25251E+002 -2.26315E+001 1.25249E+002 -2.26330E+001 1.25247E+002 -2.26342E+001 1.25245E+002 -2.26357E+001 1.25244E+002 -2.26373E+001 1.25244E+002 -2.26398E+001 1.25242E+002 -2.26406E+001 1.25242E+002 -2.26422E+001 1.25243E+002 -2.26429E+001 1.25243E+002 -2.26435E+001 1.25243E+002 -2.26440E+001 1.25241E+002 -2.26464E+001 1.25239E+002 -2.26460E+001 1.25236E+002 -2.26477E+001 1.25233E+002 -2.26494E+001 1.25231E+002 -2.26510E+001 1.25232E+002 -2.26528E+001 1.25231E+002 -2.26545E+001 1.25229E+002 -2.26564E+001 1.25226E+002 -2.26563E+001 1.25224E+002 -2.26557E+001 1.25221E+002 -2.26549E+001 1.25218E+002 -2.26551E+001 1.25217E+002 -2.26545E+001 1.25215E+002 -2.26548E+001 1.25214E+002 -2.26559E+001 1.25213E+002 -2.26591E+001 1.25213E+002 -2.26596E+001 1.25213E+002 -2.26606E+001 1.25111E+002 -2.26692E+001 1.25103E+002 -2.26766E+001 1.25090E+002 -2.26843E+001 1.25082E+002 -2.27241E+001 1.25104E+002 -2.27994E+001 1.25115E+002 -2.28150E+001 1.25108E+002 -2.28259E+001 1.25108E+002 -2.28508E+001 1.25095E+002 -2.28559E+001 1.25082E+002 -2.28723E+001 1.25052E+002 -2.28801E+001 1.25041E+002 -2.28801E+001 1.25022E+002 -2.28864E+001 1.25037E+002 -2.29104E+001 1.25058E+002 -2.29287E+001 1.25062E+002 -2.29427E+001 1.25076E+002 -2.29626E+001 1.25088E+002 -2.29805E+001 1.25103E+002 -2.29837E+001 END END
You can make your own, simply by typing in the data to a text editor like Windows Notepad. That's how I made my first ones. But, nowadays...
Polygons-я-Us
I have added some code to my "polygon overlay map" perl script, which creates a polygon file for each boundary relation examined. If you would like a polygon file for some territory(-ies), I am happy to assist. The chief requirement is that you should have a properly defined boundary relation (closed loop), with a "ref" tag that includes only characters allowed DOS file names (which is used to name the polygon file). Just send me a message with the relation id(s) and I'll post the flat text files here on the wiki and send you a link. You just copy-paste the text I post into a flat, ASCII text file, give it a .poly extension, and happy mapping.