microsoft / microsoft/GlobalMLBuildingFootprints

Greek data missing

Open
#144 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2k
Forks
277
PR merge metrics
No merged PRs in 30d

Description

Some sections of Greece are missing. It could be the quads do exist but weren't labeled with 'Greece' in the URLs or it could be some GZIP files aren't decompressing properly. I saw a lot of "decompression OK, trailing garbage ignored" complaints from gzip and DuckDB complained "Input is not a GZIP stream" on several GZIP files.

Image

$ wget https://minedbuildings.z5.web.core.windows.net/global-buildings/dataset-links.csv
$ ~/duckdb
CREATE OR REPLACE TABLE mlb AS
    SELECT *,
           region: SPLIT_PART(SPLIT_PART(Url, '/', 7), '=', 2)
    from 'dataset-links.csv';

COPY (
    SELECT Url
    FROM   mlb
    WHERE  region = 'Greece'
) TO 'greece_urls.csv' (HEADER False, DELIMITER ',');
$ cat greece_urls.csv | xargs -P8 -I% wget -c "%"

$ echo "CREATE OR REPLACE TABLE greece (
        height     JSON,
        confidence JSON,
        geometry   GEOMETRY);" \
    | ~/duckdb greece.duckdb

$ for FILENAME in part-*.csv.gz; do
    echo $FILENAME
    gunzip -c $FILENAME > working.csv
    echo "INSERT INTO greece
              SELECT height: a.properties.height::FLOAT,
                     confidence: a.properties.confidence::FLOAT,
                     geometry: ST_GEOMFROMGEOJSON(a.geometry)
              FROM (SELECT a: column0::JSON
                    FROM   READ_CSV('working.csv',
                                    header=false,
                                    columns = {'column0': 'VARCHAR'}))" \
        | ~/duckdb greece.duckdb
  done

$ ~/duckdb greece.duckdb
COPY(
    SELECT   height: height::FLOAT,
             confidence: IF(confidence='-1.0', NULL, (confidence::FLOAT*10)::INT/10),
             geometry,
             bbox:     {'xmin': ST_XMIN(ST_EXTENT(geometry)),
                        'ymin': ST_YMIN(ST_EXTENT(geometry)),
                        'xmax': ST_XMAX(ST_EXTENT(geometry)),
                        'ymax': ST_YMAX(ST_EXTENT(geometry))}
    FROM     greece
    WHERE    ST_Y(ST_CENTROID(geometry)) IS NOT NULL
    ORDER BY HILBERT_ENCODE([ST_Y(ST_CENTROID(geometry)),
                             ST_X(ST_CENTROID(geometry))]::double[2])
) TO 'greece.parquet' (
    FORMAT 'PARQUET',
    CODEC  'ZSTD',
    COMPRESSION_LEVEL 22,
    ROW_GROUP_SIZE 15000);

CREATE OR REPLACE TABLE h3_7_stats AS
    SELECT   h3_7: H3_LATLNG_TO_CELL(
                       bbox.ymin,
                       bbox.xmin,
                       7),
             num_locations: COUNT(*)
    FROM     'greece.parquet'
    GROUP BY 1;

COPY (
    SELECT geometry: ST_ASWKB(H3_CELL_TO_BOUNDARY_WKT(h3_7)::geometry),
           num_locations
    FROM   h3_7_stats
    WHERE  ST_XMIN(geometry::geometry) BETWEEN -179 AND 179
    AND    ST_XMAX(geometry::geometry) BETWEEN -179 AND 179
) TO 'greece.h3_7_stats.parquet' (
        FORMAT 'PARQUET',
        CODEC  'ZSTD',
        COMPRESSION_LEVEL 22,
        ROW_GROUP_SIZE 15000);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with dataset-links.csv and the Greece URLs produced by the DuckDB query, then inspect the downloaded part-*.csv.gz files using the shown gunzip and DuckDB commands. Compare URL coverage with the decompression warnings and identify whether missing sections come from URL labeling or invalid GZIP files. Done means the cause of the missing Greek data is established and the affected inputs or processing path are validated.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
data-engineering, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.