如何在 BigQuery 中加载 shapefile?有没有更简单的方法在 BigQuery 中上传多边形数据?

Gui*_*gas 3 gis google-bigquery

我一直在尝试在 BigQuery 中加载多边形数据,但似乎不起作用。

有没有更简单的方法在 BigQuery 中上传多边形数据?

Gui*_*gas 6

设法找到一个简单的解决方案!:)

# First, I convert the shapefile to a geojson:
ogr2ogr -f GeoJSON -t_srs crs:84 data/poligonos_setores_censitarios.geojson data/pr_setores_censitarios

# After, since BigQuery demands json and geojson files to be newline delimited, I modify it a bit:
cat data/poligonos_setores_censitarios.geojson | jq -c ".features[]" > data/poligonos_setores_censitarios_newlinedelimited.geojson

# Then, I upload it to Google Cloud Storage:
gsutil cp data/poligonos_setores_censitarios_newlinedelimited.geojson gs://cloud-storage-bucket01/

# And finally, load it in BigQuery:
bq load --source_format=NEWLINE_DELIMITED_JSON --json_extension=GEOJSON --autodetect mydataset.polygons gs://cloud-storage-bucket01/poligonos_setores_censitarios_newlinedelimited.geojson
Run Code Online (Sandbox Code Playgroud)

  • 很好,是的,现在有了 new-line-delimited-geojson 支持,模式管理变得更简单了。您也可以通过直接导出到 ND-GeoJson 来跳过“jq”,org2org 通过“-f GeoJSONSeq”选项支持它 (2认同)