How to create a new shapefile containing a few points

Ah, you’ll have to specify the spatial reference when defining the layer:

ArchGDAL.create(
        "points.shp",
        driver = ArchGDAL.getdriver("ESRI Shapefile")
    ) do ds
    ArchGDAL.createlayer(
            geom = GDAL.wkbPoint,
            spatialref = ArchGDAL.importEPSG(4326)
        ) do layer
        for (lon,lat) in zip(Lon, Lat)
            ArchGDAL.createfeature(layer) do f
                ArchGDAL.setgeom!(f, ArchGDAL.createpoint(lon, lat))
            end
        end
        ArchGDAL.copy(layer, dataset = ds)
    end
end;

I think some of these capabilities are driver-specific, and I had to experiment to find out too. See e.g.

julia> ArchGDAL.create(
               ArchGDAL.getdriver("ESRI Shapefile")
           ) do ds
           ArchGDAL.listcapability(ds)
           end
Dict{String,Bool} with 6 entries:
  "CreateLayer"                     => true
  "DeleteLayer"                     => true
  "CreateGeomFieldAfterCreateLayer" => false
  "CurveGeometries"                 => false
  "Transactions"                    => false
  "EmulatedTransactions"            => false

julia> ArchGDAL.options(
options(drv::ArchGDAL.Driver) in ArchGDAL at /Users/yeesian/.julia/packages/ArchGDAL/ohMpc/src/driver.jl:48

julia> ArchGDAL.options(ArchGDAL.getdriver("ESRI Shapefile"))
"<CreationOptionList/>"

Vector drivers — GDAL documentation and ESRI Shapefile / DBF — GDAL documentation has more details. I don’t know if there’s a way to programmatically access that kind of information though :stuck_out_tongue:

4 Likes