# How can I rasterize the polygons of a Shapefile in Julia?

**URL:** <https://discourse.julialang.org/t/how-can-i-rasterize-the-polygons-of-a-shapefile-in-julia/15089>\
**Category:** Geo\
**Tags:** gmt\
**Created:** [September 17, 2018, 7:50pm UTC](https://discourse.julialang.org/t/how-can-i-rasterize-the-polygons-of-a-shapefile-in-julia/15089 "2018-09-17T19:50:29Z")\
**Posts on this page:** 1\
**Showing post:** 17

<div class="post-metadata">

**Author:** ![yeesian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yeesian/32/652_2.png) [@yeesian](https://discourse.julialang.org/u/yeesian)\
**Post date:** [September 19, 2018, 2:42pm UTC](https://discourse.julialang.org/t/how-can-i-rasterize-the-polygons-of-a-shapefile-in-julia/15089/17 "2018-09-19T14:42:33Z")

</div>

```julia
import GDAL
using ArchGDAL; const AG = ArchGDAL

raster = AG.registerdrivers() do
    AG.read("/vsizip/gadm36_ARG_shp.zip/gadm36_ARG_1.shp") do source_ds
        dest_ds = AG.Dataset(GDAL.rasterize(
            "gadm36_ARG_1.mem",
            Ptr{GDAL.GDALDatasetH}(C_NULL),
            source_ds.ptr,
            GDAL.rasterizeoptionsnew([
                "-of", "MEM",
                # "-l", "gadm36_ARG_1", # The layer(s) used for input features.
                "-ts", "250", "250", # target size: "-ts xsize ysize". Set it to whatever you want.
                "-ot", "Byte"
            ], C_NULL), C_NULL))
        result = AG.read(dest_ds)
        AG.destroy(dest_ds)
        result
    end
end

```

---

_[View the full topic](https://discourse.julialang.org/t/how-can-i-rasterize-the-polygons-of-a-shapefile-in-julia/15089)._
