Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distance(x,x) fails #974

Closed
jariji opened this issue Aug 25, 2022 · 15 comments
Closed

distance(x,x) fails #974

jariji opened this issue Aug 25, 2022 · 15 comments

Comments

@jariji
Copy link

jariji commented Aug 25, 2022

I got this error on GMT.jl v0.42.4

julia version 1.7.1
% gmt --version
6.2.0
> zcta = gmtread("cb_2017_us_zcta510_500k.shp");
> typeof(zcta[1])
GMTdataset{Float64, 2}
> distance(zcta[1],zcta[1])
ERROR: UndefVarError: result not defined
Stacktrace:
 [1] setgeom!(feature::GMT.Gdal.Feature, geom::GMT.Gdal.IGeometry)
   @ GMT.Gdal ~/.julia/packages/GMT/GljzA/src/gdal.jl:852
 [2] gmt2gd(D::Vector{GMTdataset{Float64, 2}}; save::String, geometry::String)
   @ GMT ~/.julia/packages/GMT/GljzA/src/gdal_utils.jl:408
 [3] #gmt2gd#533
   @ ~/.julia/packages/GMT/GljzA/src/gdal_utils.jl:355 [inlined]
 [4] gmt2gd
   @ ~/.julia/packages/GMT/GljzA/src/gdal_utils.jl:355 [inlined]
 [5] helper_2geoms(D1::GMTdataset{Float64, 2}, D2::GMTdataset{Float64, 2})
   @ GMT.Gdal ~/.julia/packages/GMT/GljzA/src/gdal_extensions.jl:508
 [6] #helper_geoms_run_fun#106
   @ ~/.julia/packages/GMT/GljzA/src/gdal_extensions.jl:488 [inlined]
 [7] helper_geoms_run_fun
   @ ~/.julia/packages/GMT/GljzA/src/gdal_extensions.jl:488 [inlined]
 [8] distance(D1::GMTdataset{Float64, 2}, D2::GMTdataset{Float64, 2})
   @ GMT.Gdal ~/.julia/packages/GMT/GljzA/src/gdal_extensions.jl:187
 [9] top-level scope
@joa-quim
Copy link
Member

Hmm, this simple case works for we with the master version

julia> distance(mat2ds([0 1]), mat2ds([0 1]))
0.0

Does it work for you? Could you please try the GMT.jl master version?
(I'm stuck with an external dependency breaking, libstdc++, that prevents automatic releases of new versions).

@jariji
Copy link
Author

jariji commented Aug 25, 2022

Master works. Thanks.

@jariji jariji closed this as completed Aug 25, 2022
@jariji jariji reopened this Aug 25, 2022
@jariji
Copy link
Author

jariji commented Aug 25, 2022

Actually, running buffergeo gives that same error, and afterwards running distance gives the error too.

> buffergeo(g, width=100, unit=:km)
ERROR: UndefVarError: result not defined
Stacktrace:
  [1] setgeom!(feature::GMT.Gdal.Feature, geom::GMT.Gdal.IGeometry)
    @ GMT.Gdal ~/.julia/packages/GMT/CRO4V/src/gdal.jl:855
  [2] gmt2gd(D::Vector{GMTdataset{Float64, 2}}; save::String, geometry::String)
    @ GMT ~/.julia/packages/GMT/CRO4V/src/gdal_utils.jl:408
  [3] #gmt2gd#558
    @ ~/.julia/packages/GMT/CRO4V/src/gdal_utils.jl:355 [inlined]
  [4] gmt2gd(D::Matrix{Float64}; save::String, geometry::String)
    @ GMT ~/.julia/packages/GMT/CRO4V/src/gdal_utils.jl:354
  [5] gmt2gd
    @ ~/.julia/packages/GMT/CRO4V/src/gdal_utils.jl:354 [inlined]
  [6] helper_2geoms(D1::Matrix{Float64}, D2::Matrix{Float64})
    @ GMT.Gdal ~/.julia/packages/GMT/CRO4V/src/gdal_extensions.jl:561
  [7] helper_geoms_run_fun(f::typeof(polyunion), D1::Matrix{Float64}, D2::Matrix{Float64}, retds::Bool; gdataset::Bool)
    @ GMT.Gdal ~/.julia/packages/GMT/CRO4V/src/gdal_extensions.jl:541
  [8] #polyunion#96
    @ ~/.julia/packages/GMT/CRO4V/src/gdal_extensions.jl:139 [inlined]
  [9] polyunion(D1::Matrix{Float64}, D2::Matrix{Float64})
    @ GMT.Gdal ~/.julia/packages/GMT/CRO4V/src/gdal_extensions.jl:139
 [10] buffergeo(line::Matrix{Float64}; width::Int64, unit::Symbol, np::Int64, flatstart::Bool, flatend::Bool, proj::String, epsg::Int64, tol::Float64)
    @ GMT ~/.julia/packages/GMT/CRO4V/src/proj_utils.jl:269
 [11] buffergeo(D::Vector{GMTdataset}; width::Int64, unit::Symbol, np::Int64, flatstart::Bool, flatend::Bool, epsg::Int64, tol::Float64)
    @ GMT ~/.julia/packages/GMT/CRO4V/src/proj_utils.jl:247
 [12] top-level scope

@joa-quim
Copy link
Member

There must be a confusion with more than one version installed (though I don't know how that can happen).
gdal.j line 855 (first error in the stack trace) has this.
image

@jariji
Copy link
Author

jariji commented Aug 25, 2022

Pkg.jl failed to install GMT.jl originally so I installed GMT at the system level through my OS.

@joa-quim
Copy link
Member

No problem, that is fine, but the error is coming from apparently old GMT.jl files. There is no setgeom! at gdal.jl:855 in the mater version as you can verify in the repo.

(will try to look better at this later, have visitors by now)

@joa-quim
Copy link
Member

Have you managed to solve this issue?

@jariji
Copy link
Author

jariji commented Aug 28, 2022

Thanks, no, I got what I needed in Geopandas. I don't need it anymore.

@jariji jariji closed this as completed Aug 28, 2022
@jariji
Copy link
Author

jariji commented Oct 21, 2022

I'm trying again and got an error.

julia> versioninfo()
Julia Version 1.8.1
Commit afb6c60d69a (2022-09-06 15:09 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 24 × AMD Ryzen 9 3900XT 12-Core Processor
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, znver2)
  Threads: 12 on 24 virtual cores
Environment:
  LD_LIBRARY_PATH = /nix/store/d3wmyhdwm8dcngil7zibbcxn01lgbd2y-R-4.1.2/lib/R/lib
  JULIA_NUM_THREADS = 12
  JULIA_EDITOR = code


(v1.5) pkg> st GMT
  [5752ebe1] GMT v0.43.0 


julia> distance(zcta[1],zcta[1])
ERROR 10: Pointer 'hDriver' is NULL in 'GDALCreate'.

ERROR 10: Pointer 'hDS' is NULL in 'GDALDatasetCreateLayer'.

ERROR 10: Pointer 'hLayer' is NULL in 'OGR_L_GetLayerDefn'.

ERROR 10: Pointer 'hDefn' is NULL in 'OGR_F_Create'.

ERROR 10: Pointer 'hFeat' is NULL in 'OGR_F_SetGeometry'.

ERROR: UndefVarError: result not defined
Stacktrace:
 [1] setgeom!(feature::GMT.Gdal.Feature, geom::GMT.Gdal.IGeometry)
   @ GMT.Gdal ~/.julia/packages/GMT/5iuho/src/gdal.jl:855
 [2] gmt2gd(D::Vector{GMTdataset{Float64, 2}}; save::String, geometry::String)
   @ GMT ~/.julia/packages/GMT/5iuho/src/gdal_utils.jl:408
 [3] #gmt2gd#578
   @ ~/.julia/packages/GMT/5iuho/src/gdal_utils.jl:355 [inlined]
 [4] gmt2gd
   @ ~/.julia/packages/GMT/5iuho/src/gdal_utils.jl:355 [inlined]
 [5] helper_2geoms(D1::GMTdataset{Float64, 2}, D2::GMTdataset{Float64, 2})
   @ GMT.Gdal ~/.julia/packages/GMT/5iuho/src/gdal_extensions.jl:561
 [6] #helper_geoms_run_fun#108
   @ ~/.julia/packages/GMT/5iuho/src/gdal_extensions.jl:541 [inlined]
 [7] helper_geoms_run_fun
   @ ~/.julia/packages/GMT/5iuho/src/gdal_extensions.jl:538 [inlined]
 [8] distance(D1::GMTdataset{Float64, 2}, D2::GMTdataset{Float64, 2})
   @ GMT.Gdal ~/.julia/packages/GMT/5iuho/src/gdal_extensions.jl:187

@jariji jariji reopened this Oct 21, 2022
@joa-quim
Copy link
Member

Can't get it. This is what I get on Linux too

julia> versioninfo()
Julia Version 1.8.1
Commit afb6c60d69a (2022-09-06 15:09 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
  Threads: 1 on 12 virtual cores

julia> distance(mat2ds([0 1]), mat2ds([0 1]))
0.0

Does it error for you too? How did you install your GMT? Specially GDAL.

@jariji
Copy link
Author

jariji commented Oct 23, 2022

GMT.jl was installed normally with Pkg. GMT 6.2.0 itself was installed via NixOS 21.11.

julia> using GMT

julia> distance(mat2ds([0 1]), mat2ds([0 1]))
0.0

@joa-quim
Copy link
Member

Ah, so please provide a full failing example (with the data used) so that I can investigate.

@jariji
Copy link
Author

jariji commented Oct 24, 2022

The code is just

using GMT
zcta = gmtread("cb_2017_us_zcta510_500k.shp")
distance(zcta[1],zcta[1])

The data is here.
https://www2.census.gov/geo/tiger/GENZ2017/shp/cb_2017_us_zcta510_500k.zip

@joa-quim
Copy link
Member

Still can't reproduce the error.

julia> zcta[1]
Attributes:  Dict("ZCTA5CE10" => "35442", "AFFGEOID10" => "8600000US35442", "AWATER10" => "10838694", "ALAND10" => "610213891", "GEOID10" => "35442")
BoundingBox: [-88.25314999999999, -88.154808, 32.814828, 32.969088]
PROJ: +proj=longlat +datum=NAD83 +no_defs
WKT: GEOGCS["NAD83",
    DATUM["North_American_Datum_1983",
        SPHEROID["GRS 1980",6378137,298.257222101]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433]]
175×2 GMTdataset{Float64, 2}
 Row │      Lon      Lat
     │  Float64  Float64
─────┼───────────────────
   1 │ -88.2526  32.9267
   2 │ -88.2497  32.9324
   3 │ -88.2493  32.9354
   4 │ -88.2517  32.9396
   5 │ -88.2444  32.9428
   6 │ -88.2415  32.9435
   7 │ -88.2232  32.9439
   8 │ -88.2208  32.9437
  ⋮  │    ⋮         ⋮
 169 │ -88.2435  32.9103
 170 │ -88.2465  32.9124
 171 │ -88.2469  32.9141
 172 │ -88.2493  32.914
 173 │ -88.2521  32.92
 174 │ -88.2531  32.9247
 175 │ -88.2526  32.9267
         160 rows omitted

julia> distance(zcta[1],zcta[1])
0.0

But something is still not right. Your error message says

ERROR: UndefVarError: result not defined
Stacktrace:
 [1] setgeom!(feature::GMT.Gdal.Feature, geom::GMT.Gdal.IGeometry)
   @ GMT.Gdal ~/.julia/packages/GMT/5iuho/src/gdal.jl:855

but if you open the gdal.jl file you'll see that line 855, is the second from

	macro ogrerr(code, message)
		return quote
			($(esc(code)) != OGRERR_NONE) && error($message)
		end
	end

and not a call to setgeom! that is defined at line 1909.

@joa-quim
Copy link
Member

Closing this as non-reproducible. Please reopen if any news.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants