[英]How to load a shapefile in BigQuery? Is there a simpler way to upload polygon data in BigQuery?
I have been trying to load polygon data in BigQuery, but it doesnt seem to work.我一直在尝试在 BigQuery 中加载多边形数据,但它似乎不起作用。
I have tried what Michael Entin explained in his " Loading large spatial features to BigQuery geography " article, but it didnt so well for me.我已经尝试过 Michael Entin 在他的“ 将大型空间特征加载到 BigQuery 地理”一文中解释的内容,但对我来说并没有那么好。
I also have tried what Lak Lakshmanan explained in his " How to load geographic data like shapefiles into BigQuery ", but didnt work either.我也尝试过 Lak Lakshmanan 在他的“ 如何将 shapefile 之类的地理数据加载到 BigQuery中”中解释的内容,但也没有用。
I found it rather confusing having to convert the shapefiles and/or geojsons into a csv to load into BigQuery.我发现必须将 shapefile 和/或 geojson 转换为 csv 以加载到 BigQuery 中相当令人困惑。
Is there any simpler way to upload polygon data in BigQuery?有没有更简单的方法在 BigQuery 中上传多边形数据?
# First of all, I have a shapefile ready to go. The command below will return details about it:
ogrinfo -al -so data/pr_setores_censitarios/shapefile.shp
# Secondly, 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.