# Display a variable makes it to be constant ? Rasters.jl bug?

**URL:** <https://discourse.julialang.org/t/display-a-variable-makes-it-to-be-constant-rasters-jl-bug/101157>\
**Category:** Geo\
**Tags:** question, potential-bug, rasters\
**Created:** [July 4, 2023, 9:01am UTC](https://discourse.julialang.org/t/display-a-variable-makes-it-to-be-constant-rasters-jl-bug/101157 "2023-07-04T09:01:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [July 4, 2023, 9:01am UTC](https://discourse.julialang.org/t/display-a-variable-makes-it-to-be-constant-rasters-jl-bug/101157/1 "2023-07-04T09:01:30Z")

</div>

I got something really odd working with `Raster 0.8`, Julia 1.9:

This is ok:

```julia
julia> using Rasters
julia> X = 2
2
julia> X
2
julia> typeof(X)
Int64

```

but (new session):

```julia
julia> using Rasters
julia> X
X
julia> X = 2
ERROR: cannot assign a value to imported variable Dimensions.X from module Main
Stacktrace:
[1] top-level scope
@ REPL[3]:1

```

By the only fact that I do show a variable (that I don’t know where it is coming), I can’t use it any more to rebind it to some other object ?? Rasters.jl bug ?

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [July 4, 2023, 9:13am UTC](https://discourse.julialang.org/t/display-a-variable-makes-it-to-be-constant-rasters-jl-bug/101157/2 "2023-07-04T09:13:07Z")

</div>

Rasters exports the type `X`.

If you dont want that to happen, use `import Rasters` instead

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [July 4, 2023, 9:19am UTC](https://discourse.julialang.org/t/display-a-variable-makes-it-to-be-constant-rasters-jl-bug/101157/3 "2023-07-04T09:19:07Z")

</div>

I think X is a too general-use variable name to be exported by a module (my opinion)

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [July 4, 2023, 9:25am UTC](https://discourse.julialang.org/t/display-a-variable-makes-it-to-be-constant-rasters-jl-bug/101157/4 "2023-07-04T09:25:21Z")

</div>

But you only have the problem because you used `X` before defining it? Why are you doing that if you dont want to use it at all?

If you define your variable first it will work.

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [July 4, 2023, 9:40am UTC](https://discourse.julialang.org/t/display-a-variable-makes-it-to-be-constant-rasters-jl-bug/101157/5 "2023-07-04T09:40:28Z")

</div>

yes, I understood it and indeed it is the workaround I am using, but I think that it is more a workaround. I didn’t expect the X variable to be exported by a module, I just find it odd and that it is something that would surprise new users, but maybe it is just me… by defining it first it works…

---

<div class="post-metadata">

**Author:** ![Raf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raf/32/3383_2.png) [@Raf](https://discourse.julialang.org/u/Raf)\
**Post date:** [July 4, 2023, 10:22am UTC](https://discourse.julialang.org/t/display-a-variable-makes-it-to-be-constant-rasters-jl-bug/101157/6 "2023-07-04T10:22:18Z")

</div>

I agree it may suprise some people at the start, but also its something you learn quite quickly with the julia REPL.

Working with spatial data X and Y dimensions are used constantly, thecrrason theurecexported. There is a case for not using these types any more as you can actually useckeywords in most places:

```julia
raster[X=2] 

```

But there are a bunch of things dimendion type wrappers make easier, like constructing tuples of indices programatically or passing wrapped data into base methods with `dims` keywords.
