# ArchGDAL, getfeature() error

**URL:** https://discourse.julialang.org/t/archgdal-getfeature-error/41913
**Category:** General Usage
**Tags:** question
**Created:** [June 23, 2020, 4:22am UTC](https://discourse.julialang.org/t/archgdal-getfeature-error/41913 "2020-06-23T04:22:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)
#### Post date: [June 23, 2020, 4:22am UTC](https://discourse.julialang.org/t/archgdal-getfeature-error/41913/1 "2020-06-23T04:22:39Z")

</div>

```julia
hotspot_path = "zoneforhotspot.geojson"
d = ArchGDAL.read(hotspot_path)
layer = ArchGDAL.getlayer(d, 0)
fs = ArchGDAL.getfeature(layer, 1) do f
      ArchGDAL.getgeom(f)  
end
fs

```

```julia
d = ArchGDAL.read(hotspot_path)
layer = ArchGDAL.getlayer(d, 0)

f = ArchGDAL.getfeature(layer, 1) # error here
fs = ArchGDAL.getgeom(f)

```

There is error if I do not use do block.  
The error message is as following.

```julia
MethodError: no method matching getfeature(::ArchGDAL.IFeatureLayer, ::Int64)
Closest candidates are:
  getfeature(!Matched::Function, ::Any...; kwargs...) at /home/liye/.julia/packages/ArchGDAL/ohMpc/src/context.jl:213

Stacktrace:
 [1] top-level scope at In[52]:3

```

Can anyone tell the reason of the error?

---

<div class="post-metadata">

### Author: ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)
#### Post date: [June 23, 2020, 12:15pm UTC](https://discourse.julialang.org/t/archgdal-getfeature-error/41913/2 "2020-06-23T12:15:10Z")

</div>

To me it appears that `getfeature` requires a function as it’s first parameter. That is what:

```julia
fs = ArchGDAL.getfeature(layer, 1) do f
      ArchGDAL.getgeom(f)  
end

```

is doing. It creates a small function that calls `ArchGDAL.getgeom(f)` and passes it in as the first parameter to the method. Later when you do `f = ArchGDAL.getfeature(layer, 1)` there is no function being passed in.

---

<div class="post-metadata">

### Author: ![zhangliye](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhangliye/32/3208_2.png) [@zhangliye](https://discourse.julialang.org/u/zhangliye)
#### Post date: [June 23, 2020, 1:12pm UTC](https://discourse.julialang.org/t/archgdal-getfeature-error/41913/3 "2020-06-23T13:12:45Z")

</div>

It exactly acts as you said. Thank you so much!  
[https://docs.julialang.org/en/v1/manual/functions/#Do-Block-Syntax-for-Function-Arguments-1](https://docs.julialang.org/en/v1/manual/functions/#Do-Block-Syntax-for-Function-Arguments-1)

```julia
# 1 method for generic function "getfeature":
[1] getfeature(f::Function, args...; kwargs...) in ArchGDAL at /home/liye/.julia/packages/ArchGDAL/ohMpc/src/context.jl:213

```
