Repository navigation
Expand file tree
/
Copy pathtest_parquet.jl
More file actions
58 lines (48 loc) · 1.9 KB
/
Copy pathtest_parquet.jl
File metadata and controls
58 lines (48 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import GeoParquet as GP
using DataFrames
using GeoMakie
using ColorSchemes
using LibGEOS # For WKB decoding
using GeometryBasics # For geometry handling
using ArchGDAL
data_path = "/home/maarten/Documents/GIT/AlienRoE/data/data_qdgc/data_BE.parquet";
# Read GeoParquet data
gdf = GP.read(data_path)
# Filter rows based on specieskey
filtered_gdf = gdf[.!ismissing.(gdf.specieskey) .&& (gdf.specieskey .== 2435350.0), :]
#==
# Function to convert LibGEOS geometries to GeometryBasics geometries
function convert_to_geometrybasics(geom::LibGEOS.AbstractGeometry)
if geom isa LibGEOS.Polygon
# Convert a single polygon
rings = [GeometryBasics.Point2.(ring.coords[:, 1], ring.coords[:, 2]) for ring in geom.rings]
return GeometryBasics.Polygon(rings...)
elseif geom isa LibGEOS.MultiPolygon
# Convert a multipolygon by iterating over its components
n_geometries = LibGEOS.getngeometry(geom) # Get number of geometries
sub_geometries = [convert_to_geometrybasics(LibGEOS.getgeometry(geom, i - 1)) for i in 1:n_geometries]
return GeometryBasics.MultiPolygon(sub_geometries)
else
error("Unsupported geometry type: $(typeof(geom))")
end
end
# Convert WKB geometries to GeometryBasics geometries
geometries = [
convert_to_geometrybasics(LibGEOS.readgeom(geom.val))
for geom in filtered_gdf.geometry
]
# Extract the 'count' column for coloring
counts = filtered_gdf.occurrences
# Normalize the color scale
normalized_counts = (counts .- minimum(counts)) ./ (maximum(counts) - minimum(counts))
# Create a map with a geographic projection
fig = Figure()
ax = geoaxis(fig[1, 1], projection = :mercator)
# Plot filtered geometries with colors based on 'count'
poly!(ax, geometries,
color = normalized_counts, # Color by normalized count values
colormap = :viridis, # Choose a colormap (e.g., :viridis, :plasma)
transparency = false
)
fig
==#