GDAL/ogr2ogr File Conversion

Hi all,

I’m trying to complete what I thought would be a relatively simple task (although I am new to Julia and coding in general) with GDAL, specifically converting a .shp to a GeoPackage using ogr2ogr.

I’ve followed the available documentation here. Specifically the example:

# convert simple features data between file formats
GDAL.ogr2ogr_path() do ogr2ogr
    run(`$ogr2ogr -f FlatGeobuf output.fgb input.shp`)
end

My current script is:

using GDAL
using SQLite

GDAL.ogr2ogr_path() do ogr2ogr
    run('$ogr2ogr -f GPKG output.gpkg input.shp')
end

Which throws an error: ERROR: syntax: character literal contains multiple characters

I’ve tested the package installation with no issues. Been stumped for a little while. Any help would be greatly appreciated.

Well I’ve figured out it’s because

`

Is different than

'

Could someone please explain to me what exactly that character is? I feel immensely dumb.

' is for Char

`

is for commands.

1 Like

If all you are doing with ogr2ogr is a disk file format conversion why using Julia and not doing it directly on a shell?

I’m going to have to expand the code quite a lot to parse several directories and convert hundreds of files. Just starting out with the small example here.