osm_split icon indicating copy to clipboard operation
osm_split copied to clipboard

Geojson to gpkg on lines failed

Open stefankinell opened this issue 1 year ago • 1 comments

I tried the new release, on the swedish data. It stoped with the following error:

Categorising (lines).. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:22:24
GeoJSON to GPKG (lines).. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   0% -:--:--
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ D:\gen3Data\OSM\osm_split-main\main.py:439 in main                                               │
│                                                                                                  │
│   436 │   │   │   │   # WIP: free(): invalid pointer                                             │
│   437 │   │   │   │   # I'm running a dodgy build from GDAL's main branch                        │
│   438 │   │   │   │   if 'invalid pointer' not in str(exc):                                      │
│ ❱ 439 │   │   │   │   │   raise exc                                                              │
│   440 │   │   │                                                                                  │
│   441 │   │   │   unlink('%s.geojson' % basename)                                                │
│   442                                                                                            │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │            _geojson = 'lines/forest.geojson'                                                 │ │
│ │           _osm_conf = 'osmconf.ini'                                                          │ │
│ │            basename = 'lines/highway/unclassified'                                           │ │
│ │        categorisers = {                                                                      │ │
│ │                       │   'lines': <function lines at 0x0000021D715F6340>,                   │ │
│ │                       │   'multilinestrings': <function multilinestrings at                  │ │
│ │                       0x0000021D715F63E0>,                                                   │ │
│ │                       │   'multipolygons': <function multipolygons at 0x0000021D715F6480>,   │ │
│ │                       │   'points': <function points at 0x0000021D715F6520>,                 │ │
│ │                       │   'other_relations': <function other_relations at                    │ │
│ │                       0x0000021D715F65C0>                                                    │ │
│ │                       }                                                                      │ │
│ │            category = 'forest'                                                               │ │
│ │                 cmd = 'ogr2ogr -f GeoJSON lines/highway/unclassified.gpkg                    │ │
│ │                       lines/highway/unclassified.ge'+5                                       │ │
│ │        file_handles = {                                                                      │ │
│ │                       │   'lines/highway/unclassified.geojson': <_io.TextIOWrapper           │ │
│ │                       name='lines/highway/unclassified.geojson' mode='a' encoding='utf-8'>,  │ │
│ │                       │   'lines/highway/residential.geojson': <_io.TextIOWrapper            │ │
│ │                       name='lines/highway/residential.geojson' mode='a' encoding='utf-8'>,   │ │
│ │                       │   'lines/highway/tertiary.geojson': <_io.TextIOWrapper               │ │
│ │                       name='lines/highway/tertiary.geojson' mode='a' encoding='utf-8'>,      │ │
│ │                       │   'lines/highway/pedestrian.geojson': <_io.TextIOWrapper             │ │
│ │                       name='lines/highway/pedestrian.geojson' mode='a' encoding='utf-8'>,    │ │
│ │                       │   'lines/highway/motorway.geojson': <_io.TextIOWrapper               │ │
│ │                       name='lines/highway/motorway.geojson' mode='a' encoding='utf-8'>,      │ │
│ │                       │   'lines/highway/secondary.geojson': <_io.TextIOWrapper              │ │
│ │                       name='lines/highway/secondary.geojson' mode='a' encoding='utf-8'>,     │ │
│ │                       │   'lines/highway/footway.geojson': <_io.TextIOWrapper                │ │
│ │                       name='lines/highway/footway.geojson' mode='a' encoding='utf-8'>,       │ │
│ │                       │   'lines/highway/service.geojson': <_io.TextIOWrapper                │ │
│ │                       name='lines/highway/service.geojson' mode='a' encoding='utf-8'>,       │ │
│ │                       │   'lines/highway/cycleway.geojson': <_io.TextIOWrapper               │ │
│ │                       name='lines/highway/cycleway.geojson' mode='a' encoding='utf-8'>,      │ │
│ │                       │   'lines/highway/path.geojson': <_io.TextIOWrapper                   │ │
│ │                       name='lines/highway/path.geojson' mode='a' encoding='utf-8'>,          │ │
│ │                       │   ... +748                                                           │ │
│ │                       }                                                                      │ │
│ │              folder = 'lines'                                                                │ │
│ │    geojson_filename = 'lines/highway/unclassified.geojson'                                   │ │
│ │                geom = <LINESTRING (16.03 58.891, 16.03 58.891, 16.03 58.891, 16.029 58.891,  │ │
│ │                       16.029...>                                                             │ │
│ │       geom_category = 'forest'                                                               │ │
│ │           geom_type = None                                                                   │ │
│ │          geom_type_ = 'lines'                                                                │ │
│ │            h3_polys = []                                                                     │ │
│ │            num_rows = 7244803                                                                │ │
│ │             only_h3 = None                                                                   │ │
│ │            osm_file = 'sweden-latest.osm.pbf'                                                │ │
│ │          other_tags = {'landuse': 'forest'}                                                  │ │
│ │  other_tags_no_subs = {'landuse': 'forest'}                                                  │ │
│ │ override_geom_type_ = None                                                                   │ │
│ │   polygon_buildings = False                                                                  │ │
│ │                 rec = (                                                                      │ │
│ │                       │   '"landuse"=>"forest"',                                             │ │
│ │                       │   'LINESTRING (16.0303971 58.8908842, 16.0304777 58.8910277,         │ │
│ │                       16.0301692 58.8912336,'+226                                            │ │
│ │                       )                                                                      │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ D:\gen3Data\OSM\osm_split-main\main.py:434 in main                                               │
│                                                                                                  │
│   431 │   │   │   │   │   'to':   quote(basename + '.gpkg')}                                     │
│   432 │   │   │                                                                                  │
│   433 │   │   │   try:                                                                           │
│ ❱ 434 │   │   │   │   execute(cmd)                                                               │
│   435 │   │   │   except Exception as exc:                                                       │
│   436 │   │   │   │   # WIP: free(): invalid pointer                                             │
│   437 │   │   │   │   # I'm running a dodgy build from GDAL's main branch                        │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │            _geojson = 'lines/forest.geojson'                                                 │ │
│ │           _osm_conf = 'osmconf.ini'                                                          │ │
│ │            basename = 'lines/highway/unclassified'                                           │ │
│ │        categorisers = {                                                                      │ │
│ │                       │   'lines': <function lines at 0x0000021D715F6340>,                   │ │
│ │                       │   'multilinestrings': <function multilinestrings at                  │ │
│ │                       0x0000021D715F63E0>,                                                   │ │
│ │                       │   'multipolygons': <function multipolygons at 0x0000021D715F6480>,   │ │
│ │                       │   'points': <function points at 0x0000021D715F6520>,                 │ │
│ │                       │   'other_relations': <function other_relations at                    │ │
│ │                       0x0000021D715F65C0>                                                    │ │
│ │                       }                                                                      │ │
│ │            category = 'forest'                                                               │ │
│ │                 cmd = 'ogr2ogr -f GeoJSON lines/highway/unclassified.gpkg                    │ │
│ │                       lines/highway/unclassified.ge'+5                                       │ │
│ │        file_handles = {                                                                      │ │
│ │                       │   'lines/highway/unclassified.geojson': <_io.TextIOWrapper           │ │
│ │                       name='lines/highway/unclassified.geojson' mode='a' encoding='utf-8'>,  │ │
│ │                       │   'lines/highway/residential.geojson': <_io.TextIOWrapper            │ │
│ │                       name='lines/highway/residential.geojson' mode='a' encoding='utf-8'>,   │ │
│ │                       │   'lines/highway/tertiary.geojson': <_io.TextIOWrapper               │ │
│ │                       name='lines/highway/tertiary.geojson' mode='a' encoding='utf-8'>,      │ │
│ │                       │   'lines/highway/pedestrian.geojson': <_io.TextIOWrapper             │ │
│ │                       name='lines/highway/pedestrian.geojson' mode='a' encoding='utf-8'>,    │ │
│ │                       │   'lines/highway/motorway.geojson': <_io.TextIOWrapper               │ │
│ │                       name='lines/highway/motorway.geojson' mode='a' encoding='utf-8'>,      │ │
│ │                       │   'lines/highway/secondary.geojson': <_io.TextIOWrapper              │ │
│ │                       name='lines/highway/secondary.geojson' mode='a' encoding='utf-8'>,     │ │
│ │                       │   'lines/highway/footway.geojson': <_io.TextIOWrapper                │ │
│ │                       name='lines/highway/footway.geojson' mode='a' encoding='utf-8'>,       │ │
│ │                       │   'lines/highway/service.geojson': <_io.TextIOWrapper                │ │
│ │                       name='lines/highway/service.geojson' mode='a' encoding='utf-8'>,       │ │
│ │                       │   'lines/highway/cycleway.geojson': <_io.TextIOWrapper               │ │
│ │                       name='lines/highway/cycleway.geojson' mode='a' encoding='utf-8'>,      │ │
│ │                       │   'lines/highway/path.geojson': <_io.TextIOWrapper                   │ │
│ │                       name='lines/highway/path.geojson' mode='a' encoding='utf-8'>,          │ │
│ │                       │   ... +748                                                           │ │
│ │                       }                                                                      │ │
│ │              folder = 'lines'                                                                │ │
│ │    geojson_filename = 'lines/highway/unclassified.geojson'                                   │ │
│ │                geom = <LINESTRING (16.03 58.891, 16.03 58.891, 16.03 58.891, 16.029 58.891,  │ │
│ │                       16.029...>                                                             │ │
│ │       geom_category = 'forest'                                                               │ │
│ │           geom_type = None                                                                   │ │
│ │          geom_type_ = 'lines'                                                                │ │
│ │            h3_polys = []                                                                     │ │
│ │            num_rows = 7244803                                                                │ │
│ │             only_h3 = None                                                                   │ │
│ │            osm_file = 'sweden-latest.osm.pbf'                                                │ │
│ │          other_tags = {'landuse': 'forest'}                                                  │ │
│ │  other_tags_no_subs = {'landuse': 'forest'}                                                  │ │
│ │ override_geom_type_ = None                                                                   │ │
│ │   polygon_buildings = False                                                                  │ │
│ │                 rec = (                                                                      │ │
│ │                       │   '"landuse"=>"forest"',                                             │ │
│ │                       │   'LINESTRING (16.0303971 58.8908842, 16.0304777 58.8910277,         │ │
│ │                       16.0301692 58.8912336,'+226                                            │ │
│ │                       )                                                                      │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ C:\Users\web\AppData\Local\Programs\Python\Python311\Lib\site-packages\shpyx\runner.py:316 in    │
│ run                                                                                              │
│                                                                                                  │
│   313 │   │   result.return_code = p.returncode                                                  │
│   314 │   │                                                                                      │
│   315 │   │   # Verify that the command result is valid, based on the verification configurati   │
│ ❱ 316 │   │   self._verify_result(                                                               │
│   317 │   │   │   result=result,                                                                 │
│   318 │   │   │   verify_return_code=verify_return_code,                                         │
│   319 │   │   │   verify_stderr=verify_stderr,                                                   │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │               args = 'ogr2ogr -f GeoJSON lines/highway/unclassified.gpkg                     │ │
│ │                      lines/highway/unclassified.ge'+5                                        │ │
│ │            cmd_env = {                                                                       │ │
│ │                      │   'ALLUSERSPROFILE': 'C:\\ProgramData',                               │ │
│ │                      │   'APPDATA': 'C:\\Users\\web\\AppData\\Roaming',                      │ │
│ │                      │   'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files',            │ │
│ │                      │   'COMMONPROGRAMFILES(X86)': 'C:\\Program Files (x86)\\Common Files', │ │
│ │                      │   'COMMONPROGRAMW6432': 'C:\\Program Files\\Common Files',            │ │
│ │                      │   'COMPUTERNAME': 'MASKINEN',                                         │ │
│ │                      │   'COMSPEC': 'C:\\WINDOWS\\system32\\cmd.exe',                        │ │
│ │                      │   'DOKANLIBRARY1': 'C:\\Program Files\\Dokan\\Dokan Library-1.5.1\\', │ │
│ │                      │   'DOKANLIBRARY1_LIBRARYPATH_X64': 'C:\\Program Files\\Dokan\\Dokan   │ │
│ │                      Library-1.5.1\\lib\\',                                                  │ │
│ │                      │   'DOKANLIBRARY1_LIBRARYPATH_X86': 'C:\\Program Files\\Dokan\\Dokan   │ │
│ │                      Library-1.5.1\\x86\\lib\\',                                             │ │
│ │                      │   ... +37                                                             │ │
│ │                      }                                                                       │ │
│ │            cmd_str = 'ogr2ogr -f GeoJSON lines/highway/unclassified.gpkg                     │ │
│ │                      lines/highway/unclassified.ge'+5                                        │ │
│ │                env = None                                                                    │ │
│ │           exec_dir = None                                                                    │ │
│ │       final_stderr = b''                                                                     │ │
│ │       final_stdout = b''                                                                     │ │
│ │            log_cmd = None                                                                    │ │
│ │         log_output = None                                                                    │ │
│ │                  p = <Popen: returncode: 3221225781 args: 'ogr2ogr -f GeoJSON                │ │
│ │                      lines/highway/uncla...>                                                 │ │
│ │             result = ShellCmdResult(                                                         │ │
│ │                      │   cmd='ogr2ogr -f GeoJSON lines/highway/unclassified.gpkg             │ │
│ │                      lines/highway/unclassified.ge'+5,                                       │ │
│ │                      │   stdout='',                                                          │ │
│ │                      │   stderr='',                                                          │ │
│ │                      │   all_output='',                                                      │ │
│ │                      │   return_code=3221225781                                              │ │
│ │                      )                                                                       │ │
│ │               self = <shpyx.runner.Runner object at 0x0000021D712E5C10>                      │ │
│ │        stderr_data = b''                                                                     │ │
│ │        stdout_data = b''                                                                     │ │
│ │           tmp_file = <tempfile._TemporaryFileWrapper object at 0x0000021D064ED090>           │ │
│ │           unix_raw = False                                                                   │ │
│ │          use_shell = True                                                                    │ │
│ │   use_signal_names = None                                                                    │ │
│ │ verify_return_code = None                                                                    │ │
│ │      verify_stderr = None                                                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ C:\Users\web\AppData\Local\Programs\Python\Python311\Lib\site-packages\shpyx\runner.py:181 in    │
│ _verify_result                                                                                   │
│                                                                                                  │
│   178 │   │   │   │   f"Error output:\n{result.stderr}\n"                                        │
│   179 │   │   │   │   f"All output:\n{result.all_output}"                                        │
│   180 │   │   │   )                                                                              │
│ ❱ 181 │   │   │   raise ShpyxVerificationError(reason=reason, result=result)                     │
│   182 │                                                                                          │
│   183 │   def run(                                                                               │
│   184 │   │   self,                                                                              │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │             reason = "The command 'ogr2ogr -f GeoJSON lines/highway/unclassified.gpkg        │ │
│ │                      lines/highway/un"+84                                                    │ │
│ │             result = ShellCmdResult(                                                         │ │
│ │                      │   cmd='ogr2ogr -f GeoJSON lines/highway/unclassified.gpkg             │ │
│ │                      lines/highway/unclassified.ge'+5,                                       │ │
│ │                      │   stdout='',                                                          │ │
│ │                      │   stderr='',                                                          │ │
│ │                      │   all_output='',                                                      │ │
│ │                      │   return_code=3221225781                                              │ │
│ │                      )                                                                       │ │
│ │    return_code_str = '3221225781'                                                            │ │
│ │               self = <shpyx.runner.Runner object at 0x0000021D712E5C10>                      │ │
│ │            success = False                                                                   │ │
│ │   use_signal_names = None                                                                    │ │
│ │ verify_return_code = None                                                                    │ │
│ │      verify_stderr = None                                                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ShpyxVerificationError: The command 'ogr2ogr -f GeoJSON lines/highway/unclassified.gpkg lines/highway/unclassified.geojson' failed with return code 3221225781.

Error output:

All output:

I have now a folder lines with geojson-files. No other output.

stefankinell avatar Feb 20 '24 14:02 stefankinell

The script is meant to be run from Ubuntu for Windows, not any of the other Windows shells.

I'll research pure python geojson to gpkg libraries like https://github.com/geomet/geomet which could make osm_split much more portable.

marklit avatar Feb 21 '24 14:02 marklit