yeesian / ArchGDAL.jl

A high level API for GDAL - Geospatial Data Abstraction Library
https://yeesian.github.io/ArchGDAL.jl/stable/
Other
141 stars 27 forks source link

Provide a simple example of projecting geometries #72

Closed yeesian closed 2 years ago

yeesian commented 5 years ago

using https://pcjericks.github.io/py-gdalogr-cookbook/projection.html#reproject-a-layer as an example. e.g. pull out geometries from a shapefile in ArchGDAL using http://gisdata-piercecowa.opendata.arcgis.com/datasets/nonmotorized-transportation-plan

shapes = AG.registerdrivers() do
    AG.read("Nonmotorized_Transportation_Plan.shp") do dataset
        [
            AG.getgeom(feature) for feature in AG.getlayer(dataset, 0)
            if GDAL.getgeometryref(feature.ptr) != C_NULL
        ]
    end
end

from there, to project them, the following should work:

AG.createcoordtrans(AG.importEPSG(2927), AG.importEPSG(4326)) do coordtrans
    AG.transform!.(shapes, coordtrans)
end

alternatively:

AG.transform!.(shapes, AG.importEPSG(4326))
yeesian commented 5 years ago

also mention the situation with WKB/WKT: #77